mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +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:
@@ -48,22 +48,6 @@ func TestMain(m *testing.M) {
|
||||
|
||||
e.API.AuthenticatedSupport = true
|
||||
e.SetCredentials(APIKey, APISecret, "", "", "", "")
|
||||
|
||||
err = e.UpdateTradablePairs(context.Background(), false)
|
||||
if err != nil {
|
||||
log.Fatal("Exmo UpdateTradablePairs error", err)
|
||||
}
|
||||
|
||||
avail, err := e.GetAvailablePairs(asset.Spot)
|
||||
if err != nil {
|
||||
log.Fatal("Exmo GetAvailablePairs error", err)
|
||||
}
|
||||
|
||||
err = e.CurrencyPairs.StorePairs(asset.Spot, avail, true)
|
||||
if err != nil {
|
||||
log.Fatal("Exmo StorePairs error", err)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@@ -513,18 +497,19 @@ func TestUpdateTicker(t *testing.T) {
|
||||
|
||||
func TestUpdateTickers(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := e.UpdateTickers(context.Background(), asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
avail, err := e.GetAvailablePairs(asset.Spot)
|
||||
enabled, err := e.GetEnabledPairs(asset.Spot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for x := range avail {
|
||||
_, err := ticker.GetTicker(e.Name, avail[x], asset.Spot)
|
||||
for x := range enabled {
|
||||
_, err := ticker.GetTicker(e.Name, enabled[x], asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -206,28 +206,21 @@ func (e *EXMO) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error
|
||||
|
||||
// UpdateTickers updates the ticker for all currency pairs of a given asset type
|
||||
func (e *EXMO) UpdateTickers(ctx context.Context, a asset.Item) error {
|
||||
avail, err := e.GetAvailablePairs(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enabled, err := e.GetEnabledPairs(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := e.GetTicker(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var enabled bool
|
||||
for symbol, tick := range result {
|
||||
var pair currency.Pair
|
||||
pair, err = avail.DeriveFrom(strings.Replace(symbol, "_", "", 1))
|
||||
pair, enabled, err = e.MatchSymbolCheckEnabled(symbol, asset.Spot, true)
|
||||
if err != nil {
|
||||
return err
|
||||
if !errors.Is(err, currency.ErrPairNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !enabled.Contains(pair, true) {
|
||||
if !enabled {
|
||||
continue
|
||||
}
|
||||
err = ticker.ProcessTicker(&ticker.Price{
|
||||
|
||||
Reference in New Issue
Block a user