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:
Ryan O'Hara-Reid
2025-06-16 17:09:25 +10:00
committed by GitHub
parent fd021d364a
commit 2958e64afe
93 changed files with 1259 additions and 1391 deletions

View File

@@ -652,7 +652,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if err != nil {
return err
}
asks := make(orderbook.Tranches, 0, len(orderbookData.Asks))
asks := make(orderbook.Levels, 0, len(orderbookData.Asks))
for x := range orderbookData.Asks {
if len(orderbookData.Asks[x]) != 3 {
return errMalformedData
@@ -665,12 +665,12 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if !okay {
return fmt.Errorf("%w, invalid amount", errMalformedData)
}
asks = append(asks, orderbook.Tranche{
asks = append(asks, orderbook.Level{
Price: price,
Amount: amount,
})
}
bids := make(orderbook.Tranches, 0, len(orderbookData.Bids))
bids := make(orderbook.Levels, 0, len(orderbookData.Bids))
for x := range orderbookData.Bids {
if len(orderbookData.Bids[x]) != 3 {
return errMalformedData
@@ -685,7 +685,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if !okay {
return fmt.Errorf("%w, invalid amount", errMalformedData)
}
bids = append(bids, orderbook.Tranche{
bids = append(bids, orderbook.Level{
Price: price,
Amount: amount,
})
@@ -696,7 +696,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
switch orderbookData.Type {
case "snapshot":
return d.Websocket.Orderbook.LoadSnapshot(&orderbook.Base{
return d.Websocket.Orderbook.LoadSnapshot(&orderbook.Book{
Exchange: d.Name,
VerifyOrderbook: d.CanVerifyOrderbook,
LastUpdated: orderbookData.Timestamp.Time(),
@@ -721,7 +721,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if err != nil {
return err
}
asks := make(orderbook.Tranches, 0, len(orderbookData.Asks))
asks := make(orderbook.Levels, 0, len(orderbookData.Asks))
for x := range orderbookData.Asks {
if len(orderbookData.Asks[x]) != 2 {
return errMalformedData
@@ -736,12 +736,12 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if !okay {
return fmt.Errorf("%w, invalid amount", errMalformedData)
}
asks = append(asks, orderbook.Tranche{
asks = append(asks, orderbook.Level{
Price: price,
Amount: amount,
})
}
bids := make([]orderbook.Tranche, 0, len(orderbookData.Bids))
bids := make([]orderbook.Level, 0, len(orderbookData.Bids))
for x := range orderbookData.Bids {
if len(orderbookData.Bids[x]) != 2 {
return errMalformedData
@@ -756,7 +756,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if !okay {
return fmt.Errorf("%w, invalid amount", errMalformedData)
}
bids = append(bids, orderbook.Tranche{
bids = append(bids, orderbook.Level{
Price: price,
Amount: amount,
})
@@ -764,7 +764,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if len(asks) == 0 && len(bids) == 0 {
return nil
}
return d.Websocket.Orderbook.LoadSnapshot(&orderbook.Base{
return d.Websocket.Orderbook.LoadSnapshot(&orderbook.Book{
Asks: asks,
Bids: bids,
Pair: cp,

View File

@@ -288,7 +288,7 @@ func (d *Deribit) UpdateTicker(ctx context.Context, p currency.Pair, assetType a
}
// UpdateOrderbook updates and returns the orderbook for a currency pair
func (d *Deribit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {
func (d *Deribit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Book, error) {
p, err := d.FormatExchangeCurrency(p, assetType)
if err != nil {
return nil, err
@@ -303,28 +303,28 @@ func (d *Deribit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetTyp
if err != nil {
return nil, err
}
book := &orderbook.Base{
book := &orderbook.Book{
Exchange: d.Name,
Pair: p,
Asset: assetType,
VerifyOrderbook: d.CanVerifyOrderbook,
}
book.Asks = make(orderbook.Tranches, 0, len(obData.Asks))
book.Asks = make(orderbook.Levels, 0, len(obData.Asks))
for x := range obData.Asks {
if obData.Asks[x][0] == 0 || obData.Asks[x][1] == 0 {
continue
}
book.Asks = append(book.Asks, orderbook.Tranche{
book.Asks = append(book.Asks, orderbook.Level{
Price: obData.Asks[x][0],
Amount: obData.Asks[x][1],
})
}
book.Bids = make(orderbook.Tranches, 0, len(obData.Bids))
book.Bids = make(orderbook.Levels, 0, len(obData.Bids))
for x := range obData.Bids {
if obData.Bids[x][0] == 0 || obData.Bids[x][1] == 0 {
continue
}
book.Bids = append(book.Bids, orderbook.Tranche{
book.Bids = append(book.Bids, orderbook.Level{
Price: obData.Bids[x][0],
Amount: obData.Bids[x][1],
})