bbgo_origin/pkg/strategy/tri/symbols.sh

34 lines
952 B
Bash
Raw Normal View History

2023-07-05 07:51:16 +00:00
#!/bin/bash
echo '// Code generated by "bash symbols.sh"; DO NOT EDIT.' > symbols.go
echo 'package tri' >> symbols.go
max_symbols=$(curl -s https://max-api.maicoin.com/api/v2/markets | jq -r '.[].id | ascii_upcase')
binance_symbols=$(curl -s https://api.binance.com/api/v3/exchangeInfo | jq -r '.symbols[].symbol | ascii_upcase')
symbols=$(echo "$max_symbols$binance_symbols" | sort | uniq | grep -v -E '^[0-9]' | grep -v "DOWNUSDT" | grep -v "UPUSDT")
echo "$symbols" | perl -l -n -e 'BEGIN { print "const (" } END { print ")" } print qq{\t$_ = "$_"}' >> symbols.go
cat <<DOC >> symbols.go
var symbols = []string{
$(echo -e "$symbols" | tr '\n' ',')
}
func toSymbol(s string) string {
for _, symbol := range symbols {
if s == symbol {
return symbol
}
}
return s
}
func compileSymbols(symbols []string) []string {
var ss = make([]string, len(symbols))
for i, s := range symbols {
ss[i] = toSymbol(s)
}
return ss
}
DOC