mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-27 01:05:15 +00:00
34 lines
952 B
Bash
34 lines
952 B
Bash
#!/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
|