mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 23:16:53 +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:
@@ -2529,8 +2529,8 @@ func (by *Bybit) GetBrokerEarning(ctx context.Context, businessType, cursor stri
|
||||
return resp.List, by.SendAuthHTTPRequestV5(ctx, exchange.RestSpot, http.MethodGet, "/v5/broker/earning-record", params, nil, &resp, defaultEPL)
|
||||
}
|
||||
|
||||
func processOB(ob [][2]types.Number) []orderbook.Tranche {
|
||||
o := make([]orderbook.Tranche, len(ob))
|
||||
func processOB(ob [][2]types.Number) []orderbook.Level {
|
||||
o := make([]orderbook.Level, len(ob))
|
||||
for x := range ob {
|
||||
o[x].Price = ob[x][0].Float64()
|
||||
o[x].Amount = ob[x][1].Float64()
|
||||
|
||||
@@ -1741,8 +1741,8 @@ type ServerTime struct {
|
||||
// Orderbook stores the orderbook data
|
||||
type Orderbook struct {
|
||||
UpdateID int64
|
||||
Bids []orderbook.Tranche
|
||||
Asks []orderbook.Tranche
|
||||
Bids []orderbook.Level
|
||||
Asks []orderbook.Level
|
||||
Symbol string
|
||||
GenerationTime time.Time
|
||||
}
|
||||
|
||||
@@ -707,20 +707,19 @@ func (by *Bybit) wsProcessOrderbook(assetType asset.Item, resp *WebsocketRespons
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
asks := make([]orderbook.Tranche, len(result.Asks))
|
||||
asks := make([]orderbook.Level, len(result.Asks))
|
||||
for i := range result.Asks {
|
||||
asks[i].Price = result.Asks[i][0].Float64()
|
||||
asks[i].Amount = result.Asks[i][1].Float64()
|
||||
}
|
||||
bids := make([]orderbook.Tranche, len(result.Bids))
|
||||
bids := make([]orderbook.Level, len(result.Bids))
|
||||
for i := range result.Bids {
|
||||
bids[i].Price = result.Bids[i][0].Float64()
|
||||
bids[i].Amount = result.Bids[i][1].Float64()
|
||||
}
|
||||
|
||||
if resp.Type == "snapshot" {
|
||||
return by.Websocket.Orderbook.LoadSnapshot(&orderbook.Base{
|
||||
return by.Websocket.Orderbook.LoadSnapshot(&orderbook.Book{
|
||||
Pair: cp,
|
||||
Exchange: by.Name,
|
||||
Asset: assetType,
|
||||
|
||||
@@ -477,7 +477,7 @@ func (by *Bybit) UpdateTicker(ctx context.Context, p currency.Pair, assetType as
|
||||
}
|
||||
|
||||
// UpdateOrderbook updates and returns the orderbook for a currency pair
|
||||
func (by *Bybit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
|
||||
func (by *Bybit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Book, error) {
|
||||
if p.IsEmpty() {
|
||||
return nil, currency.ErrCurrencyPairEmpty
|
||||
}
|
||||
@@ -506,22 +506,22 @@ func (by *Bybit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
book := &orderbook.Base{
|
||||
book := &orderbook.Book{
|
||||
Exchange: by.Name,
|
||||
Pair: p,
|
||||
Asset: assetType,
|
||||
VerifyOrderbook: by.CanVerifyOrderbook,
|
||||
Bids: make([]orderbook.Tranche, len(orderbookNew.Bids)),
|
||||
Asks: make([]orderbook.Tranche, len(orderbookNew.Asks)),
|
||||
Bids: make([]orderbook.Level, len(orderbookNew.Bids)),
|
||||
Asks: make([]orderbook.Level, len(orderbookNew.Asks)),
|
||||
}
|
||||
for x := range orderbookNew.Bids {
|
||||
book.Bids[x] = orderbook.Tranche{
|
||||
book.Bids[x] = orderbook.Level{
|
||||
Amount: orderbookNew.Bids[x].Amount,
|
||||
Price: orderbookNew.Bids[x].Price,
|
||||
}
|
||||
}
|
||||
for x := range orderbookNew.Asks {
|
||||
book.Asks[x] = orderbook.Tranche{
|
||||
book.Asks[x] = orderbook.Level{
|
||||
Amount: orderbookNew.Asks[x].Amount,
|
||||
Price: orderbookNew.Asks[x].Price,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user