mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 23:16:49 +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:
@@ -186,23 +186,18 @@ func TestUpdateTicker(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTickers(t *testing.T) {
|
||||
avail, err := h.GetAvailablePairs(asset.Spot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = h.CurrencyPairs.StorePairs(asset.Spot, avail, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = h.UpdateTickers(context.Background(), asset.Spot)
|
||||
err := h.UpdateTickers(context.Background(), asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
for j := range avail {
|
||||
_, err = h.FetchTicker(context.Background(), avail[j], asset.Spot)
|
||||
enabled, err := h.GetEnabledPairs(asset.Spot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for j := range enabled {
|
||||
_, err = h.FetchTicker(context.Background(), enabled[j], asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -291,9 +291,9 @@ func (h *HitBTC) FetchTradablePairs(ctx context.Context, _ asset.Item) (currency
|
||||
|
||||
pairs := make([]currency.Pair, len(symbols))
|
||||
for x := range symbols {
|
||||
quote := strings.Replace(symbols[x].ID, symbols[x].BaseCurrency, "", 1)
|
||||
index := strings.Index(symbols[x].ID, symbols[x].QuoteCurrency)
|
||||
var pair currency.Pair
|
||||
pair, err = currency.NewPairFromStrings(symbols[x].BaseCurrency, quote)
|
||||
pair, err = currency.NewPairFromStrings(symbols[x].ID[:index], symbols[x].ID[index:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -322,23 +322,18 @@ func (h *HitBTC) UpdateTickers(ctx context.Context, a asset.Item) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
avail, err := h.GetAvailablePairs(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enabled, err := h.GetEnabledPairs(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for x := range tick {
|
||||
pair, err := avail.DeriveFrom(tick[x].Symbol)
|
||||
var pair currency.Pair
|
||||
var enabled bool
|
||||
pair, enabled, err = h.MatchSymbolCheckEnabled(tick[x].Symbol, a, false)
|
||||
if err != nil {
|
||||
return err
|
||||
if !errors.Is(err, currency.ErrPairNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !enabled.Contains(pair, true) {
|
||||
if !enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user