mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-10 14:27:00 +08:00
feat: data-driven autopilot profitability tuning + edge profile panel
Analysis of 410 live closed trades found the edge is real but was being destroyed by execution: gross +$267 vs $245 fees; trades held <1h were net negative (the <15m bucket alone: -$48 on $66 fees) while 1h+ holds carried +$78; shorts lost $72 while longs made $94 — and both the prompt and the engine were manufacturing those losers. Changes, each tied to the data: - Prompt: removed the 'MUST open at least one long AND one short every cycle' mandate (forced weak-signal shorts); direction is now data-driven with 'never open just to balance the book'. Added fee-awareness (round trip ≈ 0.1% notional, require expected move ≥ 3x cost) and aligned the hold discipline with the backend throttle. - Forced book-balance opens now require |board z-score| ≥ 0.75 — the engine previously force-opened full-size 10x positions on near-neutral signals with hardcoded confidence 70. DirectionalCandidates now carries scores. - Min AI-managed hold raised 45m → 60m (the 15-60m bucket still bled after the earlier throttle landed). - Legacy prompt hygiene: vergex path drops long-only-era custom prompts and zh-era configs fall back wholesale to built-in English sections — fixes the two long-failing kernel prompt tests. - New Edge Profile dashboard panel: net after fees by hold-time bucket and side, computed from recent closed trades, with an automatic takeaway line — the fee/churn regression detector, always visible. Fixed the HistoricalPosition timestamp types (epoch ms, not strings).
This commit is contained in:
@@ -877,16 +877,24 @@ func minInt(a, b int) int {
|
||||
return b
|
||||
}
|
||||
|
||||
// DirectionalCandidates returns bullish (long) and bearish (short) candidate
|
||||
// symbols from the most recent Vergex signal ranking, each ordered by upstream
|
||||
// rank (strongest first). Only populated for vergex_signal coin sources, since
|
||||
// that is the only source carrying a per-symbol directional bias.
|
||||
func (e *StrategyEngine) DirectionalCandidates() (bullish []string, bearish []string) {
|
||||
// DirectionalCandidate is a Vergex board candidate with its directional
|
||||
// signal strength (the board z-score; sign follows the bias direction).
|
||||
type DirectionalCandidate struct {
|
||||
Symbol string
|
||||
Score float64
|
||||
}
|
||||
|
||||
// DirectionalCandidates returns bullish (long) and bearish (short) candidates
|
||||
// from the most recent Vergex signal ranking, each ordered by upstream rank
|
||||
// (strongest first) and carrying the signal score so callers can require a
|
||||
// minimum strength. Only populated for vergex_signal coin sources, since that
|
||||
// is the only source carrying a per-symbol directional bias.
|
||||
func (e *StrategyEngine) DirectionalCandidates() (bullish []DirectionalCandidate, bearish []DirectionalCandidate) {
|
||||
if e == nil || len(e.vergexRankingCache) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
type ranked struct {
|
||||
sym string
|
||||
cand DirectionalCandidate
|
||||
rank int
|
||||
}
|
||||
rankKey := func(r int) int {
|
||||
@@ -900,20 +908,21 @@ func (e *StrategyEngine) DirectionalCandidates() (bullish []string, bearish []st
|
||||
if item == nil {
|
||||
continue
|
||||
}
|
||||
entry := ranked{DirectionalCandidate{Symbol: sym, Score: item.Score}, item.Rank}
|
||||
switch strings.ToLower(strings.TrimSpace(item.Bias)) {
|
||||
case "bearish", "short", "sell":
|
||||
br = append(br, ranked{sym, item.Rank})
|
||||
br = append(br, entry)
|
||||
case "bullish", "long", "buy":
|
||||
bl = append(bl, ranked{sym, item.Rank})
|
||||
bl = append(bl, entry)
|
||||
}
|
||||
}
|
||||
sort.SliceStable(bl, func(i, j int) bool { return rankKey(bl[i].rank) < rankKey(bl[j].rank) })
|
||||
sort.SliceStable(br, func(i, j int) bool { return rankKey(br[i].rank) < rankKey(br[j].rank) })
|
||||
for _, r := range bl {
|
||||
bullish = append(bullish, r.sym)
|
||||
bullish = append(bullish, r.cand)
|
||||
}
|
||||
for _, r := range br {
|
||||
bearish = append(bearish, r.sym)
|
||||
bearish = append(bearish, r.cand)
|
||||
}
|
||||
return bullish, bearish
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user