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

@@ -317,7 +317,7 @@ func getAllActiveOrderbooks(m iExchangeManager) []EnabledExchangeOrderbooks {
orderbookData := make([]EnabledExchangeOrderbooks, 0, len(exchanges))
for _, e := range exchanges {
var orderbooks []orderbook.Base
var orderbooks []orderbook.Book
for _, a := range e.GetAssetTypes(true) {
pairs, err := e.GetEnabledPairs(a)
if err != nil {

View File

@@ -129,7 +129,7 @@ type AllEnabledExchangeOrderbooks struct {
// orderbooks
type EnabledExchangeOrderbooks struct {
ExchangeName string `json:"exchangeName"`
ExchangeValues []orderbook.Base `json:"exchangeValues"`
ExchangeValues []orderbook.Book `json:"exchangeValues"`
}
// AllEnabledExchangeCurrencies holds the enabled exchange currencies

View File

@@ -3138,13 +3138,13 @@ func TestGetOrderbookMovement(t *testing.T) {
t.Fatal(err)
}
bid := []orderbook.Tranche{
bid := []orderbook.Level{
{Price: 10, Amount: 1},
{Price: 9, Amount: 1},
{Price: 8, Amount: 1},
{Price: 7, Amount: 1},
}
ask := []orderbook.Tranche{
ask := []orderbook.Level{
{Price: 11, Amount: 1},
{Price: 12, Amount: 1},
{Price: 13, Amount: 1},
@@ -3239,13 +3239,13 @@ func TestGetOrderbookAmountByNominal(t *testing.T) {
t.Fatal(err)
}
bid := []orderbook.Tranche{
bid := []orderbook.Level{
{Price: 10, Amount: 1},
{Price: 9, Amount: 1},
{Price: 8, Amount: 1},
{Price: 7, Amount: 1},
}
ask := []orderbook.Tranche{
ask := []orderbook.Level{
{Price: 11, Amount: 1},
{Price: 12, Amount: 1},
{Price: 13, Amount: 1},
@@ -3333,13 +3333,13 @@ func TestGetOrderbookAmountByImpact(t *testing.T) {
t.Fatal(err)
}
bid := []orderbook.Tranche{
bid := []orderbook.Level{
{Price: 10, Amount: 1},
{Price: 9, Amount: 1},
{Price: 8, Amount: 1},
{Price: 7, Amount: 1},
}
ask := []orderbook.Tranche{
ask := []orderbook.Level{
{Price: 11, Amount: 1},
{Price: 12, Amount: 1},
{Price: 13, Amount: 1},

View File

@@ -77,7 +77,7 @@ type iBot interface {
type iCurrencyPairSyncer interface {
IsRunning() bool
PrintTickerSummary(*ticker.Price, string, error)
PrintOrderbookSummary(*orderbook.Base, string, error)
PrintOrderbookSummary(*orderbook.Book, string, error)
WebsocketUpdate(string, currency.Pair, asset.Item, syncItemType, error) error
}

View File

@@ -815,7 +815,7 @@ const (
)
// PrintOrderbookSummary outputs orderbook results
func (m *SyncManager) PrintOrderbookSummary(result *orderbook.Base, protocol string, err error) {
func (m *SyncManager) PrintOrderbookSummary(result *orderbook.Book, protocol string, err error) {
if m == nil || atomic.LoadInt32(&m.started) == 0 {
return
}

View File

@@ -176,25 +176,25 @@ func TestPrintOrderbookSummary(t *testing.T) {
assert.NoError(t, err)
atomic.StoreInt32(&m.started, 1)
m.PrintOrderbookSummary(&orderbook.Base{
m.PrintOrderbookSummary(&orderbook.Book{
Pair: currency.NewPair(currency.AUD, currency.USD),
}, "REST", nil)
m.fiatDisplayCurrency = currency.USD
m.PrintOrderbookSummary(&orderbook.Base{
m.PrintOrderbookSummary(&orderbook.Book{
Pair: currency.NewPair(currency.AUD, currency.USD),
}, "REST", nil)
m.fiatDisplayCurrency = currency.JPY
m.PrintOrderbookSummary(&orderbook.Base{
m.PrintOrderbookSummary(&orderbook.Book{
Pair: currency.NewPair(currency.AUD, currency.USD),
}, "REST", nil)
m.PrintOrderbookSummary(&orderbook.Base{
m.PrintOrderbookSummary(&orderbook.Book{
Pair: currency.NewPair(currency.AUD, currency.USD),
}, "REST", common.ErrNotYetImplemented)
m.PrintOrderbookSummary(&orderbook.Base{
m.PrintOrderbookSummary(&orderbook.Book{
Pair: currency.NewPair(currency.AUD, currency.USD),
}, "REST", errors.New("test"))

View File

@@ -214,7 +214,7 @@ func TestWebsocketRoutineManagerHandleData(t *testing.T) {
}
assert.ErrorIs(t, err, classificationError.Err)
err = m.websocketDataHandler(exchName, &orderbook.Base{
err = m.websocketDataHandler(exchName, &orderbook.Book{
Exchange: "Bitstamp",
Pair: currency.NewBTCUSD(),
})