Bybit: Add subscription configuration for spot (#1601)

* Bybit: Subscription configuration for spot

* Bybit: Enable candles ws sub by default

* Orderbook: Use a RW mutex for depth

* Orderbook: Fix race on depth.VerifyOrderbook

Despite being protected by an ob level mutex, this needed to privatise
and protect the option var.
This commit is contained in:
Gareth Kirwan
2024-11-05 06:05:38 +01:00
committed by GitHub
parent 8fe909d44d
commit 199d30d442
11 changed files with 251 additions and 163 deletions

View File

@@ -171,7 +171,7 @@ func (w *Orderbook) Update(u *orderbook.Update) error {
}
var ret *orderbook.Base
if book.ob.VerifyOrderbook {
if book.ob.VerifyOrderbook() {
// This is used here so as to not retrieve book if verification is off.
// On every update, this will retrieve and verify orderbook depth.
ret, err = book.ob.Retrieve()
@@ -333,17 +333,12 @@ func (w *Orderbook) LoadSnapshot(book *orderbook.Base) error {
holder.updateID = book.LastUpdateID
err = holder.ob.LoadSnapshot(book.Bids,
book.Asks,
book.LastUpdateID,
book.LastUpdated,
book.UpdatePushedAt,
false)
err = holder.ob.LoadSnapshot(book.Bids, book.Asks, book.LastUpdateID, book.LastUpdated, book.UpdatePushedAt, false)
if err != nil {
return err
}
if holder.ob.VerifyOrderbook {
if holder.ob.VerifyOrderbook() {
// This is used here so as to not retrieve book if verification is off.
// Checks to see if orderbook snapshot that was deployed has not been
// altered in any way