refactor binance symbol resolver
This commit is contained in:
@@ -3,11 +3,47 @@ package binancex
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"me.thuanle/bbot/internal/configs/binance"
|
||||
"me.thuanle/bbot/internal/data"
|
||||
"me.thuanle/bbot/internal/utils/stringx"
|
||||
)
|
||||
|
||||
func Token2FutureSymbols(token string) []string {
|
||||
return Token2Symbols(token)
|
||||
var syms []string
|
||||
if !stringx.IsAlphaNumeric(token) {
|
||||
return syms
|
||||
}
|
||||
|
||||
token = strings.ToUpper(token)
|
||||
|
||||
for _, prefix := range checkingPrefixList {
|
||||
prefix = strings.ToUpper(prefix)
|
||||
|
||||
s := prefix + token
|
||||
|
||||
if data.Market.IsFuturesPair(s) {
|
||||
syms = append(syms, s)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, suffix := range binance.SymbolSuffixList {
|
||||
suffix = strings.ToUpper(suffix)
|
||||
abbr := strings.ToUpper(binance.SymbolSuffixMap[suffix])
|
||||
|
||||
sym := s + suffix
|
||||
if data.Market.IsFuturesPair(sym) {
|
||||
syms = append(syms, sym)
|
||||
continue
|
||||
}
|
||||
|
||||
symAbr, found := stringx.ReplaceSuffix(s, abbr, suffix)
|
||||
if found && data.Market.IsFuturesPair(symAbr) {
|
||||
syms = append(syms, symAbr)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return syms
|
||||
}
|
||||
|
||||
func Token2SpotSymbols(token string) []string {
|
||||
|
||||
Reference in New Issue
Block a user