mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 23:16:53 +00:00
orderbook: consolidate slice array types to orderbook package (#1992)
* orderbook: consolidate slice array types to orderbook package * Update exchanges/bybit/bybit_types.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * linter: fix and add test * cranktakular: nits * cranktakular: nits * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/gateio/gateio_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * gk: nits consolidation * gk: rm unifySpotOrderbook func * gk: nit but different * linter: fix * gk: nits * glorious: nits * Update exchanges/binance/binance.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/binance/binance_cfutures.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/binanceus/binanceus.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * thrasher-:nits * thrasher-: more nit --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -373,24 +373,14 @@ func (e *Exchange) processOrderbookUpdate(ctx context.Context, incoming []byte,
|
||||
if err := json.Unmarshal(incoming, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
asks := make([]orderbook.Level, len(data.Asks))
|
||||
for x := range data.Asks {
|
||||
asks[x].Price = data.Asks[x][0].Float64()
|
||||
asks[x].Amount = data.Asks[x][1].Float64()
|
||||
}
|
||||
bids := make([]orderbook.Level, len(data.Bids))
|
||||
for x := range data.Bids {
|
||||
bids[x].Price = data.Bids[x][0].Float64()
|
||||
bids[x].Amount = data.Bids[x][1].Float64()
|
||||
}
|
||||
return e.wsOBUpdateMgr.ProcessOrderbookUpdate(ctx, e, data.FirstUpdateID, &orderbook.Update{
|
||||
UpdateID: data.LastUpdateID,
|
||||
UpdateTime: data.UpdateTime.Time(),
|
||||
LastPushed: lastPushed,
|
||||
Pair: data.Pair,
|
||||
Asset: asset.Spot,
|
||||
Asks: asks,
|
||||
Bids: bids,
|
||||
Asks: data.Asks.Levels(),
|
||||
Bids: data.Bids.Levels(),
|
||||
AllowEmpty: true,
|
||||
})
|
||||
}
|
||||
@@ -401,17 +391,6 @@ func (e *Exchange) processOrderbookSnapshot(incoming []byte, lastPushed time.Tim
|
||||
return err
|
||||
}
|
||||
|
||||
asks := make([]orderbook.Level, len(data.Asks))
|
||||
for x := range data.Asks {
|
||||
asks[x].Price = data.Asks[x][0].Float64()
|
||||
asks[x].Amount = data.Asks[x][1].Float64()
|
||||
}
|
||||
bids := make([]orderbook.Level, len(data.Bids))
|
||||
for x := range data.Bids {
|
||||
bids[x].Price = data.Bids[x][0].Float64()
|
||||
bids[x].Amount = data.Bids[x][1].Float64()
|
||||
}
|
||||
|
||||
for _, a := range standardMarginAssetTypes {
|
||||
if enabled, _ := e.CurrencyPairs.IsPairEnabled(data.CurrencyPair, a); enabled {
|
||||
if err := e.Websocket.Orderbook.LoadSnapshot(&orderbook.Book{
|
||||
@@ -420,8 +399,8 @@ func (e *Exchange) processOrderbookSnapshot(incoming []byte, lastPushed time.Tim
|
||||
Asset: a,
|
||||
LastUpdated: data.UpdateTime.Time(),
|
||||
LastPushed: lastPushed,
|
||||
Bids: bids,
|
||||
Asks: asks,
|
||||
Bids: data.Bids.Levels(),
|
||||
Asks: data.Asks.Levels(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user