orderbook: Refactor package structure for simplicity and efficiency (#1465)

* initial purge and benchmarks proof before rn overhaul

* rn LinkedList -> Tranche(s) and purge references

* roll out acrost exchanges

* linterino

* rn silly billy label

* linter strikes AAAAAGAIN!

* fix some things

* rm comment

* Add actual comparison from master to branch benchmark for sorting algorithms

* lower case via git mv YAAY!

* drop code

* convert type name

* glorious: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2024-05-14 15:51:34 +10:00
committed by GitHub
parent 2a92878afc
commit 4cd4fb06b4
76 changed files with 1575 additions and 2824 deletions

View File

@@ -476,12 +476,12 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
switch action {
case bitmexActionInitialData:
book := orderbook.Base{
Asks: make(orderbook.Items, 0, len(data)),
Bids: make(orderbook.Items, 0, len(data)),
Asks: make(orderbook.Tranches, 0, len(data)),
Bids: make(orderbook.Tranches, 0, len(data)),
}
for i := range data {
item := orderbook.Item{
item := orderbook.Tranche{
Price: data[i].Price,
Amount: float64(data[i].Size),
ID: data[i].ID,
@@ -514,10 +514,10 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
return err
}
asks := make([]orderbook.Item, 0, len(data))
bids := make([]orderbook.Item, 0, len(data))
asks := make([]orderbook.Tranche, 0, len(data))
bids := make([]orderbook.Tranche, 0, len(data))
for i := range data {
nItem := orderbook.Item{
nItem := orderbook.Tranche{
Price: data[i].Price,
Amount: float64(data[i].Size),
ID: data[i].ID,

View File

@@ -458,17 +458,17 @@ func (b *Bitmex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
return book, err
}
book.Asks = make(orderbook.Items, 0, len(orderbookNew))
book.Bids = make(orderbook.Items, 0, len(orderbookNew))
book.Asks = make(orderbook.Tranches, 0, len(orderbookNew))
book.Bids = make(orderbook.Tranches, 0, len(orderbookNew))
for i := range orderbookNew {
switch {
case strings.EqualFold(orderbookNew[i].Side, order.Sell.String()):
book.Asks = append(book.Asks, orderbook.Item{
book.Asks = append(book.Asks, orderbook.Tranche{
Amount: float64(orderbookNew[i].Size),
Price: orderbookNew[i].Price,
})
case strings.EqualFold(orderbookNew[i].Side, order.Buy.String()):
book.Bids = append(book.Bids, orderbook.Item{
book.Bids = append(book.Bids, orderbook.Tranche{
Amount: float64(orderbookNew[i].Size),
Price: orderbookNew[i].Price,
})