mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +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
|
||||
|
||||
3
go.sum
3
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=
|
||||
|
||||
Reference in New Issue
Block a user