mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-06 12:30:59 +08:00
fix: normalize symbol comparison to prevent duplicate data in AI input
Use market.Normalize() for both position and candidate symbols to handle different formats (ETH vs ETHUSDT), ensuring positions are correctly excluded from candidate list.
This commit is contained in:
@@ -986,14 +986,17 @@ func (e *StrategyEngine) BuildUserPrompt(ctx *Context) string {
|
||||
// Candidate coins (exclude coins already in positions to avoid duplicate data)
|
||||
positionSymbols := make(map[string]bool)
|
||||
for _, pos := range ctx.Positions {
|
||||
positionSymbols[pos.Symbol] = true
|
||||
// Normalize symbol to handle both "ETH" and "ETHUSDT" formats
|
||||
normalizedSymbol := market.Normalize(pos.Symbol)
|
||||
positionSymbols[normalizedSymbol] = true
|
||||
}
|
||||
|
||||
sb.WriteString(fmt.Sprintf("## Candidate Coins (%d coins)\n\n", len(ctx.MarketDataMap)))
|
||||
displayedCount := 0
|
||||
for _, coin := range ctx.CandidateCoins {
|
||||
// Skip if this coin is already a position (data already shown in positions section)
|
||||
if positionSymbols[coin.Symbol] {
|
||||
normalizedCoinSymbol := market.Normalize(coin.Symbol)
|
||||
if positionSymbols[normalizedCoinSymbol] {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user