bbgo_origin/pkg/exchange/okex/convert.go

18 lines
565 B
Go

package okex
import "strings"
func toGlobalSymbol(symbol string) string {
return strings.ReplaceAll(symbol, "-", "")
}
//go:generate sh -c "echo \"package okex\nvar symbolMap = map[string]string{\n\" $(curl -s -L 'https://okex.com/api/v5/public/instruments?instType=SPOT' | jq -r '.data[] | \"\\(.instId | sub(\"-\" ; \"\") | tojson ): \\( .instId | tojson),\n\"') \"\n}\" > symbols.go"
func toLocalSymbol(symbol string) string {
if s, ok := symbolMap[symbol]; ok {
return s
}
log.Errorf("failed to look up local symbol from %s", symbol)
return symbol
}