Skip to content

Commit

Permalink
fixup! GateIO: Split asset.Futures into CoinM and USDT
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Jan 25, 2025
1 parent 570c96e commit 2e76870
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions exchanges/gateio/gateio_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ func (g *Gateio) UpdateOrderbook(ctx context.Context, p currency.Pair, a asset.I
if err != nil {
return nil, err
}
var orderbookNew *Orderbook
var o *Orderbook
switch a {
case asset.Spot, asset.Margin, asset.CrossMargin:
var available bool
Expand All @@ -686,15 +686,19 @@ func (g *Gateio) UpdateOrderbook(ctx context.Context, p currency.Pair, a asset.I
if a != asset.Spot && !available {
return nil, fmt.Errorf("%v instrument %v does not have orderbook data", a, p)
}
orderbookNew, err = g.GetOrderbook(ctx, p.String(), "", 0, true)
case asset.CoinMarginedFutures:
orderbookNew, err = g.GetFuturesOrderbook(ctx, currency.BTC, p.String(), "", 0, true)
case asset.USDTMarginedFutures:
orderbookNew, err = g.GetFuturesOrderbook(ctx, currency.USDT, p.String(), "", 0, true)
case asset.DeliveryFutures:
orderbookNew, err = g.GetDeliveryOrderbook(ctx, currency.USDT, "", p, 0, true)
o, err = g.GetOrderbook(ctx, p.String(), "", 0, true)
case asset.CoinMarginedFutures, asset.USDTMarginedFutures, asset.DeliveryFutures:
settle, err := getSettlementCurrency(a, p)
if err != nil {
return nil, err
}
if a == asset.DeliveryFutures {
o, err = g.GetDeliveryOrderbook(ctx, settle, "", p, 0, true)

Check failure on line 696 in exchanges/gateio/gateio_wrapper.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to err (ineffassign)
} else {
o, err = g.GetFuturesOrderbook(ctx, settle, p.String(), "", 0, true)

Check failure on line 698 in exchanges/gateio/gateio_wrapper.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to err (ineffassign)
}
case asset.Options:
orderbookNew, err = g.GetOptionsOrderbook(ctx, p, "", 0, true)
o, err = g.GetOptionsOrderbook(ctx, p, "", 0, true)
default:
return nil, fmt.Errorf("%w %v", asset.ErrNotSupported, a)
}
Expand All @@ -706,21 +710,21 @@ func (g *Gateio) UpdateOrderbook(ctx context.Context, p currency.Pair, a asset.I
Asset: a,
VerifyOrderbook: g.CanVerifyOrderbook,
Pair: p.Upper(),
LastUpdateID: orderbookNew.ID,
LastUpdated: orderbookNew.Update.Time(),
LastUpdateID: o.ID,
LastUpdated: o.Update.Time(),
}
book.Bids = make(orderbook.Tranches, len(orderbookNew.Bids))
for x := range orderbookNew.Bids {
book.Bids = make(orderbook.Tranches, len(o.Bids))
for x := range o.Bids {
book.Bids[x] = orderbook.Tranche{
Amount: orderbookNew.Bids[x].Amount,
Price: orderbookNew.Bids[x].Price.Float64(),
Amount: o.Bids[x].Amount,
Price: o.Bids[x].Price.Float64(),
}
}
book.Asks = make(orderbook.Tranches, len(orderbookNew.Asks))
for x := range orderbookNew.Asks {
book.Asks = make(orderbook.Tranches, len(o.Asks))
for x := range o.Asks {
book.Asks[x] = orderbook.Tranche{
Amount: orderbookNew.Asks[x].Amount,
Price: orderbookNew.Asks[x].Price.Float64(),
Amount: o.Asks[x].Amount,
Price: o.Asks[x].Price.Float64(),
}
}
err = book.Process()
Expand Down

0 comments on commit 2e76870

Please sign in to comment.