Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions exchanges/binance/binance_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,39 +341,31 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
return err
}

pairs, err := e.GetEnabledPairs(a)
if err != nil {
return err
}

for i := range pairs {
for y := range tick {
pairFmt, err := e.FormatExchangeCurrency(pairs[i], a)
if err != nil {
for y := range tick {
pair, err := e.MatchSymbolWithAvailablePairs(tick[y].Symbol, a, true)
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
}
continue
}

if tick[y].Symbol != pairFmt.String() {
continue
}

err = ticker.ProcessTicker(&ticker.Price{
Last: tick[y].LastPrice.Float64(),
High: tick[y].HighPrice.Float64(),
Low: tick[y].LowPrice.Float64(),
Bid: tick[y].BidPrice.Float64(),
Ask: tick[y].AskPrice.Float64(),
Volume: tick[y].Volume.Float64(),
QuoteVolume: tick[y].QuoteVolume.Float64(),
Open: tick[y].OpenPrice.Float64(),
Close: tick[y].PrevClosePrice.Float64(),
Pair: pairFmt,
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
return err
}
err = ticker.ProcessTicker(&ticker.Price{
Last: tick[y].LastPrice.Float64(),
High: tick[y].HighPrice.Float64(),
Low: tick[y].LowPrice.Float64(),
Bid: tick[y].BidPrice.Float64(),
Ask: tick[y].AskPrice.Float64(),
Volume: tick[y].Volume.Float64(),
QuoteVolume: tick[y].QuoteVolume.Float64(),
Open: tick[y].OpenPrice.Float64(),
Close: tick[y].PrevClosePrice.Float64(),
Pair: pair,
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
return err
}
}
case asset.USDTMarginedFutures:
Expand Down
24 changes: 10 additions & 14 deletions exchanges/bitfinex/bitfinex_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,15 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
return err
}

var errs error
for key, val := range t {
pair, enabled, err := e.MatchSymbolCheckEnabled(key[1:], a, true)
if err != nil && !errors.Is(err, currency.ErrPairNotFound) {
errs = common.AppendError(errs, err)
continue
}
if !enabled {
continue
pair, err := e.MatchSymbolWithAvailablePairs(key[1:], a, true)
if err != nil {
if errors.Is(err, currency.ErrPairNotFound) {
continue
}
return err
}

err = ticker.ProcessTicker(&ticker.Price{
if err := ticker.ProcessTicker(&ticker.Price{
Last: val.Last,
High: val.High,
Low: val.Low,
Expand All @@ -310,12 +307,11 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
Pair: pair,
AssetType: a,
ExchangeName: e.Name,
})
if err != nil {
errs = common.AppendError(errs, err)
}); err != nil {
return err
}
}
return errs
return nil
}

// UpdateTicker updates and returns the ticker for a currency pair
Expand Down
27 changes: 11 additions & 16 deletions exchanges/bitmex/bitmex_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
return err
}

var enabled bool
instruments:
for j := range tick {
var pair currency.Pair
Expand All @@ -309,13 +308,10 @@ instruments:
if tick[j].Typ != futuresID {
continue instruments
}
pair, enabled, err = e.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
pair, err = e.MatchSymbolWithAvailablePairs(tick[j].Symbol, a, false)
case asset.Index:
switch tick[j].Typ {
case bitMEXBasketIndexID,
bitMEXPriceIndexID,
bitMEXLendingPremiumIndexID,
bitMEXVolatilityIndexID:
case bitMEXBasketIndexID, bitMEXPriceIndexID, bitMEXLendingPremiumIndexID, bitMEXVolatilityIndexID:
default:
continue instruments
}
Expand All @@ -324,28 +320,28 @@ 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, enabled, err = e.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
pair, err = e.MatchSymbolWithAvailablePairs(tick[j].Symbol, a, false)
case asset.PerpetualContract:
if tick[j].Typ != perpetualContractID {
continue instruments
}
pair, enabled, err = e.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
pair, err = e.MatchSymbolWithAvailablePairs(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, enabled, err = e.MatchSymbolCheckEnabled(tick[j].Symbol, a, false)
pair, err = e.MatchSymbolWithAvailablePairs(tick[j].Symbol, a, false)
}

if err != nil && !errors.Is(err, currency.ErrPairNotFound) {
if err != nil {
if errors.Is(err, currency.ErrPairNotFound) {
continue
}
return err
}
if !enabled {
continue
}

err = ticker.ProcessTicker(&ticker.Price{
if err := ticker.ProcessTicker(&ticker.Price{
Last: tick[j].LastPrice,
High: tick[j].HighPrice,
Low: tick[j].LowPrice,
Expand All @@ -358,8 +354,7 @@ instruments:
ExchangeName: e.Name,
OpenInterest: tick[j].OpenInterest,
AssetType: a,
})
if err != nil {
}); err != nil {
return err
}
}
Expand Down
6 changes: 1 addition & 5 deletions exchanges/btcmarkets/btcmarkets_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (e *Exchange) UpdateTradablePairs(ctx context.Context) error {

// UpdateTickers updates the ticker for all currency pairs of a given asset type
func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
allPairs, err := e.GetEnabledPairs(a)
allPairs, err := e.GetAvailablePairs(a)
if err != nil {
return err
}
Expand All @@ -217,10 +217,6 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
return err
}

if len(allPairs) != len(tickers) {
return errors.New("enabled pairs differ from returned tickers")
}

for x := range tickers {
if err := ticker.ProcessTicker(&ticker.Price{
Pair: tickers[x].MarketID,
Expand Down
10 changes: 0 additions & 10 deletions exchanges/bybit/bybit_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,6 @@ func (e *Exchange) UpdateTradablePairs(ctx context.Context) error {

// UpdateTickers updates the ticker for all currency pairs of a given asset type
func (e *Exchange) UpdateTickers(ctx context.Context, assetType asset.Item) error {
enabled, err := e.GetEnabledPairs(assetType)
if err != nil {
return err
}
format, err := e.GetPairFormat(assetType, false)
if err != nil {
return err
Expand All @@ -532,9 +528,6 @@ func (e *Exchange) UpdateTickers(ctx context.Context, assetType asset.Item) erro
if err != nil {
continue
}
if !enabled.Contains(pair, true) {
continue
}
err = ticker.ProcessTicker(&ticker.Price{
Last: ticks.List[x].LastPrice.Float64(),
High: ticks.List[x].HighPrice24H.Float64(),
Expand Down Expand Up @@ -564,9 +557,6 @@ func (e *Exchange) UpdateTickers(ctx context.Context, assetType asset.Item) erro
if err != nil {
continue
}
if !enabled.Contains(pair, true) {
continue
}
err = ticker.ProcessTicker(&ticker.Price{
Last: ticks.List[x].LastPrice.Float64(),
High: ticks.List[x].HighPrice24H.Float64(),
Expand Down
17 changes: 6 additions & 11 deletions exchanges/exmo/exmo_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,15 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
return err
}

var enabled bool
for symbol, tick := range result {
var pair currency.Pair
pair, enabled, err = e.MatchSymbolCheckEnabled(symbol, asset.Spot, true)
pair, err := e.MatchSymbolWithAvailablePairs(symbol, asset.Spot, true)
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
if errors.Is(err, currency.ErrPairNotFound) {
continue
}
return err
}
Comment on lines 166 to 171

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

When e.MatchSymbolCheckEnabled returns a currency.ErrPairNotFound error, the loop should continue to the next ticker. Currently, it proceeds with a zero-value pair, which will cause ticker.ProcessTicker to fail and halt all ticker updates for the exchange.

		if err != nil {
			if !errors.Is(err, currency.ErrPairNotFound) {
				return err
			}
			continue
		}

if !enabled {
continue
}
err = ticker.ProcessTicker(&ticker.Price{
if err := ticker.ProcessTicker(&ticker.Price{
Pair: pair,
Last: tick.Last,
Ask: tick.Sell,
Expand All @@ -184,8 +180,7 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
LastUpdated: tick.Updated.Time(),
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
}); err != nil {
return err
}
}
Expand Down
4 changes: 4 additions & 0 deletions exchanges/gateio/gateio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,10 @@ func TestUpdateTickers(t *testing.T) {
t.Parallel()
for _, a := range e.GetAssetTypes(false) {
err := e.UpdateTickers(t.Context(), a)
if a == asset.Options {
assert.ErrorIs(t, err, common.ErrFunctionNotSupported)
continue
}
assert.NoErrorf(t, err, "UpdateTickers should not error for %s", a)
}
}
Expand Down
30 changes: 1 addition & 29 deletions exchanges/gateio/gateio_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,35 +578,7 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
}
return errs
case asset.Options:
pairs, err := e.GetEnabledPairs(a)
if err != nil {
return err
}
for i := range pairs {
underlying, err := e.GetUnderlyingFromCurrencyPair(pairs[i])
if err != nil {
return err
}
tickers, err := e.GetOptionsTickers(ctx, underlying.String())
if err != nil {
return err
}
for x := range tickers {
err = ticker.ProcessTicker(&ticker.Price{
Last: tickers[x].LastPrice.Float64(),
Ask: tickers[x].Ask1Price.Float64(),
AskSize: tickers[x].Ask1Size,
Bid: tickers[x].Bid1Price.Float64(),
BidSize: tickers[x].Bid1Size,
Pair: tickers[x].Name,
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
return err
}
}
}
return common.ErrFunctionNotSupported
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UpdateTickers now returns common.ErrFunctionNotSupported for asset.Options, but Gateio's wrapper tests currently assert UpdateTickers does not error for all assets returned by GetAssetTypes(false) (see exchanges/gateio/gateio_test.go:1768-1773). To keep CI green, either maintain Options support here, or update the exchange/test expectations to treat Options UpdateTickers as unsupported.

Suggested change
return common.ErrFunctionNotSupported
// Options tickers are currently treated as a supported no-op.
// This ensures UpdateTickers does not return an error for all
// assets returned by GetAssetTypes(false), including Options.
return nil

Copilot uses AI. Check for mistakes.
default:
return fmt.Errorf("%w asset type: %v", asset.ErrNotSupported, a)
}
Expand Down
19 changes: 6 additions & 13 deletions exchanges/hitbtc/hitbtc_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,14 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
}

for x := range tick {
var pair currency.Pair
var enabled bool
pair, enabled, err = e.MatchSymbolCheckEnabled(tick[x].Symbol, a, false)
pair, err := e.MatchSymbolWithAvailablePairs(tick[x].Symbol, a, false)
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
if errors.Is(err, currency.ErrPairNotFound) {
continue
}
return err
}
Comment on lines 224 to 229

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

When e.MatchSymbolCheckEnabled returns a currency.ErrPairNotFound error, the loop should continue to the next ticker. Currently, it proceeds with a zero-value pair, which will cause ticker.ProcessTicker to fail and halt all ticker updates for the exchange.

Suggested change
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
}
}
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
}
continue
}


if !enabled {
continue
}

err = ticker.ProcessTicker(&ticker.Price{
if err := ticker.ProcessTicker(&ticker.Price{
Last: tick[x].Last,
High: tick[x].High,
Low: tick[x].Low,
Expand All @@ -244,8 +238,7 @@ func (e *Exchange) UpdateTickers(ctx context.Context, a asset.Item) error {
LastUpdated: tick[x].Timestamp,
ExchangeName: e.Name,
AssetType: a,
})
if err != nil {
}); err != nil {
return err
}
}
Expand Down
Loading
Loading