Skip to content

Commit

Permalink
skip orderbook depth with incomplete price
Browse files Browse the repository at this point in the history
  • Loading branch information
samuael committed Feb 7, 2025
1 parent c7d5199 commit 4b0b891
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions exchanges/okx/okx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,24 +569,28 @@ func (ok *Okx) UpdateOrderbook(ctx context.Context, pair currency.Pair, assetTyp
VerifyOrderbook: ok.CanVerifyOrderbook,
}
book.Bids = make(orderbook.Tranches, 0, len(spreadOrderbook[y].Bids))
for a := range spreadOrderbook[y].Bids {
for b := range spreadOrderbook[y].Bids {
// Skip order book bid depths where the price value is zero.
if spreadOrderbook[y].Bids[a][0].Float64() == 0 {
if spreadOrderbook[y].Bids[b][0].Float64() == 0 {
continue
}
book.Bids[a].Price = spreadOrderbook[y].Bids[a][0].Float64()
book.Bids[a].Amount = spreadOrderbook[y].Bids[a][1].Float64()
book.Bids[a].OrderCount = spreadOrderbook[y].Bids[a][2].Int64()
book.Bids = append(book.Bids, orderbook.Tranche{
Price: spreadOrderbook[y].Bids[b][0].Float64(),
Amount: spreadOrderbook[y].Bids[b][1].Float64(),
OrderCount: spreadOrderbook[y].Bids[b][2].Int64(),
})
}
book.Asks = make(orderbook.Tranches, 0, len(spreadOrderbook[y].Asks))
for a := range spreadOrderbook[y].Asks {
// Skip order book ask depths where the price value is zero.
if spreadOrderbook[y].Asks[a][0].Float64() == 0 {
continue
}
book.Asks[a].Price = spreadOrderbook[y].Asks[a][0].Float64()
book.Asks[a].Amount = spreadOrderbook[y].Asks[a][1].Float64()
book.Asks[a].OrderCount = spreadOrderbook[y].Asks[a][2].Int64()
book.Asks = append(book.Asks, orderbook.Tranche{
Price: spreadOrderbook[y].Asks[a][0].Float64(),
Amount: spreadOrderbook[y].Asks[a][1].Float64(),
OrderCount: spreadOrderbook[y].Asks[a][2].Int64(),
})
}
err = book.Process()
if err != nil {
Expand Down

0 comments on commit 4b0b891

Please sign in to comment.