okex: add local symbol convert function

This commit is contained in:
c9s 2021-05-26 02:37:28 +08:00
parent 016c60796d
commit 364e6fc990
3 changed files with 16 additions and 0 deletions

View File

@ -5,3 +5,12 @@ import "strings"
func toGlobalSymbol(symbol string) string {
return strings.ReplaceAll(symbol, "-", "")
}
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
}

View File

@ -9,6 +9,8 @@ import (
"github.com/sirupsen/logrus"
)
//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"
// OKB is the platform currency of OKEx, pre-allocate static string here
const OKB = "OKB"

File diff suppressed because one or more lines are too long