mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +00:00
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:
@@ -1098,6 +1098,7 @@ func TestGetHistoricTrades(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
cp := currency.NewPair(currency.ETH, currency.USD)
|
||||
_, err := b.UpdateTicker(context.Background(), cp, asset.PerpetualContract)
|
||||
if err != nil {
|
||||
|
||||
@@ -364,11 +364,7 @@ func (b *Bitmex) UpdateTickers(ctx context.Context, a asset.Item) error {
|
||||
return err
|
||||
}
|
||||
|
||||
enabled, err := b.GetEnabledPairs(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var enabled bool
|
||||
instruments:
|
||||
for j := range tick {
|
||||
var pair currency.Pair
|
||||
@@ -377,7 +373,7 @@ instruments:
|
||||
if tick[j].Typ != futuresID {
|
||||
continue instruments
|
||||
}
|
||||
pair, err = enabled.DeriveFrom(tick[j].Symbol)
|
||||
pair, enabled, err = b.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
|
||||
case asset.Index:
|
||||
switch tick[j].Typ {
|
||||
case bitMEXBasketIndexID,
|
||||
@@ -392,23 +388,27 @@ instruments:
|
||||
// contain an underscore. Calling DeriveFrom will then error and
|
||||
// the instruments will be missed.
|
||||
tick[j].Symbol = strings.Replace(tick[j].Symbol, currency.UnderscoreDelimiter, "", 1)
|
||||
pair, err = enabled.DeriveFrom(tick[j].Symbol)
|
||||
pair, enabled, err = b.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
|
||||
case asset.PerpetualContract:
|
||||
if tick[j].Typ != perpetualContractID {
|
||||
continue instruments
|
||||
}
|
||||
pair, err = enabled.DeriveFrom(tick[j].Symbol)
|
||||
pair, enabled, err = b.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
|
||||
case asset.Spot:
|
||||
if tick[j].Typ != spotID {
|
||||
continue instruments
|
||||
}
|
||||
tick[j].Symbol = strings.Replace(tick[j].Symbol, currency.UnderscoreDelimiter, "", 1)
|
||||
pair, err = enabled.DeriveFrom(tick[j].Symbol)
|
||||
pair, enabled, err = b.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if !errors.Is(err, currency.ErrPairNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user