fix: resolve spot and futures symbols via shared resolver
Introduce a shared token symbol resolver for spot and futures lookups while keeping alpha lookup independent, restoring prefix/remap handling and preserving spot-only fallback behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package binancex
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"me.thuanle/bbot/internal/data"
|
||||
)
|
||||
|
||||
func Token2FutureSymbols(token string) []string {
|
||||
return Token2Symbols(token)
|
||||
}
|
||||
|
||||
func Token2SpotSymbols(token string) []string {
|
||||
futureSymbols := Token2FutureSymbols(token)
|
||||
spots := make([]string, 0, len(futureSymbols)+1)
|
||||
seen := make(map[string]struct{}, len(futureSymbols)+1)
|
||||
|
||||
for _, futureSymbol := range futureSymbols {
|
||||
spotSymbol := Future2SpotSymbol(futureSymbol)
|
||||
if _, ok := seen[spotSymbol]; ok {
|
||||
continue
|
||||
}
|
||||
seen[spotSymbol] = struct{}{}
|
||||
spots = append(spots, spotSymbol)
|
||||
}
|
||||
|
||||
spotOnly := strings.ToUpper(token) + "USDT"
|
||||
if data.Market.IsSpotPair(spotOnly) {
|
||||
if _, ok := seen[spotOnly]; !ok {
|
||||
spots = append(spots, spotOnly)
|
||||
}
|
||||
}
|
||||
|
||||
return spots
|
||||
}
|
||||
Reference in New Issue
Block a user