Compare commits
2 Commits
2c5a9e23bf
...
7001ba00b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 7001ba00b4 | |||
| a9d5d070c4 |
Generated
-8
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/crypto-price-bot.iml" filepath="$PROJECT_DIR$/.idea/crypto-price-bot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +1,9 @@
|
||||
package binance
|
||||
|
||||
var SymbolPrefixList = []string{"1000000", "1000", "1M"}
|
||||
|
||||
var SymbolSuffixList = []string{"USDT", "USDC"}
|
||||
|
||||
var SymbolSuffixMap = map[string]string{
|
||||
"USDT": "",
|
||||
"USDC": "c",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,7 +14,8 @@ func Symbol2Token(sym string) string {
|
||||
for _, prefix := range binance.SymbolPrefixList {
|
||||
token, _ = strings.CutPrefix(token, prefix)
|
||||
}
|
||||
for suffix, abbr := range binance.SymbolSuffixMap {
|
||||
for _, suffix := range binance.SymbolSuffixList {
|
||||
abbr := binance.SymbolSuffixMap[suffix]
|
||||
var f bool
|
||||
token, f = stringx.ReplaceSuffix(token, suffix, abbr)
|
||||
if f {
|
||||
@@ -28,57 +29,12 @@ var (
|
||||
checkingPrefixList = append(binance.SymbolPrefixList, "")
|
||||
)
|
||||
|
||||
func testSym(sym string) bool {
|
||||
return data.Market.IsFuturesPair(sym)
|
||||
}
|
||||
|
||||
func Token2Symbols(token string) []string {
|
||||
var syms []string
|
||||
if !stringx.IsAlphaNumeric(token) {
|
||||
return syms
|
||||
}
|
||||
|
||||
token = strings.ToUpper(token)
|
||||
|
||||
for _, prefix := range checkingPrefixList {
|
||||
prefix = strings.ToUpper(prefix)
|
||||
|
||||
s := prefix + token
|
||||
|
||||
//no suffix
|
||||
if testSym(s) {
|
||||
syms = append(syms, s)
|
||||
continue
|
||||
}
|
||||
|
||||
for suffix, abbr := range binance.SymbolSuffixMap {
|
||||
suffix = strings.ToUpper(suffix)
|
||||
abbr = strings.ToUpper(abbr)
|
||||
|
||||
//suffix
|
||||
sym := s + suffix
|
||||
if testSym(sym) {
|
||||
syms = append(syms, sym)
|
||||
continue
|
||||
}
|
||||
|
||||
//suffix abbr
|
||||
symAbr, found := stringx.ReplaceSuffix(s, abbr, suffix)
|
||||
if found && testSym(symAbr) {
|
||||
syms = append(syms, symAbr)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return syms
|
||||
}
|
||||
|
||||
func IsToken(s string) bool {
|
||||
// First check regular symbols
|
||||
if len(Token2Symbols(s)) > 0 {
|
||||
if len(Token2FutureSymbols(s)) > 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
// Then check Alpha tokens
|
||||
s = strings.ToUpper(s)
|
||||
return data.Market.IsAlphaToken(s)
|
||||
|
||||
Reference in New Issue
Block a user