mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 15:10:15 +00:00
Exchanges: Bypass websocket book validation (#613)
* Exchanges: Bypass websocket book validation on exchanges when checksum is implemented, fix FTX test, go mod tidy * Orderbook: Change orderbook base field name
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
apiSecret = ""
|
||||
canManipulateRealOrders = false
|
||||
spotPair = "FTT/BTC"
|
||||
futuresPair = "LEO-0327"
|
||||
futuresPair = "DOGE-PERP"
|
||||
testToken = "ADAMOON"
|
||||
btcusd = "BTC/USD"
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user