currency: Adds matching lookup table built from available pairs (#1312)

* currency: Add pair matching update (cherry-pick)

* exchange/currency: Add tests and update func

* linter fix, also if using json unmarshal functionality stop usage of string conversion without delimiter

* gemini: fix test

* currency/manager: potential optimisation

* exchanges: purge derive from wrapper cases and add warning comment

* glorious: nits

* glorious: nits

* linter: fix

* glorious: nits

* whoops

* whoops

* glorious: nits continued

* glorious: diff THANKS!

* hitbtc: fix update tradable pairs strings splitting. continue if not enabled tickers update pair.

* glorious: nits

* linter: fix

* Update exchanges/exmo/exmo_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* bitstamp: fix test when 32 biterinos architecturinos

* capture more strings for speed

* swapsies because whos running 32bit \0/?

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2023-10-18 11:57:27 +11:00
committed by GitHub
parent d3bf4a460a
commit ceef7a14e0
32 changed files with 621 additions and 264 deletions

View File

@@ -4328,10 +4328,18 @@ func (ok *Okx) GetAssetsFromInstrumentTypeOrID(instType, instrumentID string) ([
switch {
case len(splitSymbol) == 2:
resp := make([]asset.Item, 0, 2)
if err := ok.CurrencyPairs.IsAssetPairEnabled(asset.Spot, pair); err == nil {
enabled, err := ok.IsPairEnabled(pair, asset.Spot)
if err != nil {
return nil, err
}
if enabled {
resp = append(resp, asset.Spot)
}
if err := ok.CurrencyPairs.IsAssetPairEnabled(asset.Margin, pair); err == nil {
enabled, err = ok.IsPairEnabled(pair, asset.Margin)
if err != nil {
return nil, err
}
if enabled {
resp = append(resp, asset.Margin)
}
if len(resp) > 0 {
@@ -4340,15 +4348,27 @@ func (ok *Okx) GetAssetsFromInstrumentTypeOrID(instType, instrumentID string) ([
case len(splitSymbol) > 2:
switch splitSymbol[len(splitSymbol)-1] {
case "SWAP", "swap":
if err := ok.CurrencyPairs.IsAssetPairEnabled(asset.PerpetualSwap, pair); err == nil {
enabled, err := ok.IsPairEnabled(pair, asset.PerpetualSwap)
if err != nil {
return nil, err
}
if enabled {
return []asset.Item{asset.PerpetualSwap}, nil
}
case "C", "P", "c", "p":
if err := ok.CurrencyPairs.IsAssetPairEnabled(asset.Options, pair); err == nil {
enabled, err := ok.IsPairEnabled(pair, asset.Options)
if err != nil {
return nil, err
}
if enabled {
return []asset.Item{asset.Options}, nil
}
default:
if err := ok.CurrencyPairs.IsAssetPairEnabled(asset.Futures, pair); err == nil {
enabled, err := ok.IsPairEnabled(pair, asset.Futures)
if err != nil {
return nil, err
}
if enabled {
return []asset.Item{asset.Futures}, nil
}
}