diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index 4a9b2d7b..e5713ac5 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -966,6 +966,7 @@ func (b *Bitfinex) WsInsertSnapshot(p currency.Pair, assetType asset.Item, books book.Pair = p book.ExchangeName = b.Name book.NotAggregated = true + book.HasChecksumValidation = true book.IsFundingRate = fundingRate return b.Websocket.Orderbook.LoadSnapshot(&book) } diff --git a/exchanges/ftx/ftx_test.go b/exchanges/ftx/ftx_test.go index 322fd207..354fb6bb 100644 --- a/exchanges/ftx/ftx_test.go +++ b/exchanges/ftx/ftx_test.go @@ -25,7 +25,7 @@ const ( apiSecret = "" canManipulateRealOrders = false spotPair = "FTT/BTC" - futuresPair = "LEO-0327" + futuresPair = "DOGE-PERP" testToken = "ADAMOON" btcusd = "BTC/USD" ) diff --git a/exchanges/ftx/ftx_websocket.go b/exchanges/ftx/ftx_websocket.go index 1430549f..3902f2be 100644 --- a/exchanges/ftx/ftx_websocket.go +++ b/exchanges/ftx/ftx_websocket.go @@ -506,12 +506,13 @@ func (f *FTX) WsProcessPartialOB(data *WsOrderbookData, p currency.Pair, a asset } newOrderBook := orderbook.Base{ - Asks: asks, - Bids: bids, - AssetType: a, - LastUpdated: timestampFromFloat64(data.Time), - Pair: p, - ExchangeName: f.Name, + Asks: asks, + Bids: bids, + AssetType: a, + LastUpdated: timestampFromFloat64(data.Time), + Pair: p, + ExchangeName: f.Name, + HasChecksumValidation: true, } return f.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/kraken/kraken_websocket.go b/exchanges/kraken/kraken_websocket.go index 235af73d..015ec5e3 100644 --- a/exchanges/kraken/kraken_websocket.go +++ b/exchanges/kraken/kraken_websocket.go @@ -847,6 +847,7 @@ func (k *Kraken) wsProcessOrderBookPartial(channelData *WebsocketChannelData, as } base.LastUpdated = highestLastUpdate base.ExchangeName = k.Name + base.HasChecksumValidation = true return k.Websocket.Orderbook.LoadSnapshot(&base) } diff --git a/exchanges/okgroup/okgroup_websocket.go b/exchanges/okgroup/okgroup_websocket.go index 423b123e..381f5d9f 100644 --- a/exchanges/okgroup/okgroup_websocket.go +++ b/exchanges/okgroup/okgroup_websocket.go @@ -678,12 +678,13 @@ func (o *OKGroup) WsProcessPartialOrderBook(wsEventData *WebsocketOrderBook, ins } newOrderBook := orderbook.Base{ - Asks: asks, - Bids: bids, - AssetType: a, - LastUpdated: wsEventData.Timestamp, - Pair: instrument, - ExchangeName: o.Name, + Asks: asks, + Bids: bids, + AssetType: a, + LastUpdated: wsEventData.Timestamp, + Pair: instrument, + ExchangeName: o.Name, + HasChecksumValidation: true, } return o.Websocket.Orderbook.LoadSnapshot(&newOrderBook) } diff --git a/exchanges/orderbook/orderbook.go b/exchanges/orderbook/orderbook.go index 22632e09..ff11e77d 100644 --- a/exchanges/orderbook/orderbook.go +++ b/exchanges/orderbook/orderbook.go @@ -275,9 +275,11 @@ func (b *Base) Process() error { b.LastUpdated = time.Now() } - err := b.Verify() - if err != nil { - return err + if !b.HasChecksumValidation { + err := b.Verify() + if err != nil { + return err + } } return service.Update(b) diff --git a/exchanges/orderbook/orderbook_types.go b/exchanges/orderbook/orderbook_types.go index 6b980a99..eb3b33a9 100644 --- a/exchanges/orderbook/orderbook_types.go +++ b/exchanges/orderbook/orderbook_types.go @@ -79,10 +79,15 @@ type Base struct { LastUpdateID int64 `json:"lastUpdateId"` AssetType asset.Item `json:"assetType"` ExchangeName string `json:"exchangeName"` + // NotAggregated defines whether an orderbook can contain duplicate prices // in a payload NotAggregated bool `json:"-"` IsFundingRate bool `json:"fundingRate"` + + // HasChecksumValidation defines an allowance to bypass internal + // verification if the book has been verified by checksum. + HasChecksumValidation bool `json:"-"` } type byOBPrice []Item diff --git a/go.sum b/go.sum index 0b5ae0a6..41037df8 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= -github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gofrs/uuid v3.4.0+incompatible h1:d3y9DuA2LnGr8hiQ+1dPQrNsydLvutmRq9cjULPWYZQ= github.com/gofrs/uuid v3.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=