mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 15:10:59 +00:00
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:
@@ -291,17 +291,17 @@ func (b *Bithumb) UpdateOrderbook(ctx context.Context, p currency.Pair, assetTyp
|
||||
return book, err
|
||||
}
|
||||
|
||||
book.Bids = make(orderbook.Items, len(orderbookNew.Data.Bids))
|
||||
book.Bids = make(orderbook.Tranches, len(orderbookNew.Data.Bids))
|
||||
for i := range orderbookNew.Data.Bids {
|
||||
book.Bids[i] = orderbook.Item{
|
||||
book.Bids[i] = orderbook.Tranche{
|
||||
Amount: orderbookNew.Data.Bids[i].Quantity,
|
||||
Price: orderbookNew.Data.Bids[i].Price,
|
||||
}
|
||||
}
|
||||
|
||||
book.Asks = make(orderbook.Items, len(orderbookNew.Data.Asks))
|
||||
book.Asks = make(orderbook.Tranches, len(orderbookNew.Data.Asks))
|
||||
for i := range orderbookNew.Data.Asks {
|
||||
book.Asks[i] = orderbook.Item{
|
||||
book.Asks[i] = orderbook.Tranche{
|
||||
Amount: orderbookNew.Data.Asks[i].Quantity,
|
||||
Price: orderbookNew.Data.Asks[i].Price,
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ const (
|
||||
)
|
||||
|
||||
func (b *Bithumb) processBooks(updates *WsOrderbooks) error {
|
||||
bids := make([]orderbook.Item, 0, len(updates.List))
|
||||
asks := make([]orderbook.Item, 0, len(updates.List))
|
||||
bids := make([]orderbook.Tranche, 0, len(updates.List))
|
||||
asks := make([]orderbook.Tranche, 0, len(updates.List))
|
||||
for x := range updates.List {
|
||||
i := orderbook.Item{Price: updates.List[x].Price, Amount: updates.List[x].Quantity}
|
||||
i := orderbook.Tranche{Price: updates.List[x].Price, Amount: updates.List[x].Quantity}
|
||||
if updates.List[x].OrderSide == "bid" {
|
||||
bids = append(bids, i)
|
||||
continue
|
||||
@@ -426,16 +426,16 @@ func (b *Bithumb) SeedLocalCache(ctx context.Context, p currency.Pair) error {
|
||||
// SeedLocalCacheWithBook seeds the local orderbook cache
|
||||
func (b *Bithumb) SeedLocalCacheWithBook(p currency.Pair, o *Orderbook) error {
|
||||
var newOrderBook orderbook.Base
|
||||
newOrderBook.Bids = make(orderbook.Items, len(o.Data.Bids))
|
||||
newOrderBook.Bids = make(orderbook.Tranches, len(o.Data.Bids))
|
||||
for i := range o.Data.Bids {
|
||||
newOrderBook.Bids[i] = orderbook.Item{
|
||||
newOrderBook.Bids[i] = orderbook.Tranche{
|
||||
Amount: o.Data.Bids[i].Quantity,
|
||||
Price: o.Data.Bids[i].Price,
|
||||
}
|
||||
}
|
||||
newOrderBook.Asks = make(orderbook.Items, len(o.Data.Asks))
|
||||
newOrderBook.Asks = make(orderbook.Tranches, len(o.Data.Asks))
|
||||
for i := range o.Data.Asks {
|
||||
newOrderBook.Asks[i] = orderbook.Item{
|
||||
newOrderBook.Asks[i] = orderbook.Tranche{
|
||||
Amount: o.Data.Asks[i].Quantity,
|
||||
Price: o.Data.Asks[i].Price,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user