mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 15:10:59 +00:00
orderbook: change Base struct name to Book (#1914)
* orderbook: change Base struct name to Snapshot * linter: fix * Update exchanges/exchange.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/depth.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Snapshot -> Book * Tranche(s) -> Level(s) * Tranche(s) -> Level(s) * rm tranche ref * linter: fix * linter: rides again * update tests * Update exchange/websocket/buffer/buffer.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update backtester/eventhandlers/exchange/slippage/slippage.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchange/websocket/buffer/buffer.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchange/websocket/buffer/buffer.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * fixup tests * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/orderbook/orderbook_types.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * gk: nits and rm stuff that is not needed * Update exchanges/orderbook/orderbook_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * gk: nits --------- Co-authored-by: shazbert <ryan.oharareid@thrasher.io> Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -400,13 +400,13 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
|
||||
|
||||
switch action {
|
||||
case bitmexActionInitialData:
|
||||
book := orderbook.Base{
|
||||
Asks: make(orderbook.Tranches, 0, len(data)),
|
||||
Bids: make(orderbook.Tranches, 0, len(data)),
|
||||
book := orderbook.Book{
|
||||
Asks: make(orderbook.Levels, 0, len(data)),
|
||||
Bids: make(orderbook.Levels, 0, len(data)),
|
||||
}
|
||||
|
||||
for i := range data {
|
||||
item := orderbook.Tranche{
|
||||
item := orderbook.Level{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
@@ -439,10 +439,10 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
|
||||
return err
|
||||
}
|
||||
|
||||
asks := make([]orderbook.Tranche, 0, len(data))
|
||||
bids := make([]orderbook.Tranche, 0, len(data))
|
||||
asks := make([]orderbook.Level, 0, len(data))
|
||||
bids := make([]orderbook.Level, 0, len(data))
|
||||
for i := range data {
|
||||
nItem := orderbook.Tranche{
|
||||
nItem := orderbook.Level{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
|
||||
@@ -387,14 +387,14 @@ func (b *Bitmex) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item
|
||||
}
|
||||
|
||||
// UpdateOrderbook updates and returns the orderbook for a currency pair
|
||||
func (b *Bitmex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
func (b *Bitmex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Book, error) {
|
||||
if p.IsEmpty() {
|
||||
return nil, currency.ErrCurrencyPairEmpty
|
||||
}
|
||||
if err := b.CurrencyPairs.IsAssetEnabled(assetType); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
book := &orderbook.Base{
|
||||
book := &orderbook.Book{
|
||||
Exchange: b.Name,
|
||||
Pair: p,
|
||||
Asset: assetType,
|
||||
@@ -419,17 +419,17 @@ func (b *Bitmex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
|
||||
return book, err
|
||||
}
|
||||
|
||||
book.Asks = make(orderbook.Tranches, 0, len(orderbookNew))
|
||||
book.Bids = make(orderbook.Tranches, 0, len(orderbookNew))
|
||||
book.Asks = make(orderbook.Levels, 0, len(orderbookNew))
|
||||
book.Bids = make(orderbook.Levels, 0, len(orderbookNew))
|
||||
for i := range orderbookNew {
|
||||
switch {
|
||||
case strings.EqualFold(orderbookNew[i].Side, order.Sell.String()):
|
||||
book.Asks = append(book.Asks, orderbook.Tranche{
|
||||
book.Asks = append(book.Asks, orderbook.Level{
|
||||
Amount: float64(orderbookNew[i].Size),
|
||||
Price: orderbookNew[i].Price,
|
||||
})
|
||||
case strings.EqualFold(orderbookNew[i].Side, order.Buy.String()):
|
||||
book.Bids = append(book.Bids, orderbook.Tranche{
|
||||
book.Bids = append(book.Bids, orderbook.Level{
|
||||
Amount: float64(orderbookNew[i].Size),
|
||||
Price: orderbookNew[i].Price,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user