-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
orderbook: Check assignment of time values and reject if not set #1318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice QA PR! First round of nitterinos
exchanges/bitmex/bitmex.go
Outdated
@@ -111,6 +111,8 @@ const ( | |||
bitMEXPriceIndexID = "MRCXXX" | |||
bitMEXLendingPremiumIndexID = "MRRXXX" | |||
bitMEXVolatilityIndexID = "MRIXXX" | |||
|
|||
timeLayout = "2006-01-02T15:04:05.999Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can rid this since Go std can handle it natively
exchanges/bitmex/bitmex_types.go
Outdated
Side string `json:"side"` | ||
Size int64 `json:"size"` | ||
Symbol string `json:"symbol"` | ||
Timestamp string `json:"timestamp"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timestamp string `json:"timestamp"` | |
Timestamp time.Time `json:"timestamp"` |
@@ -862,7 +863,7 @@ func TestWsOrderbook(t *testing.T) { | |||
pressXToJSON = []byte(`{ | |||
"type": "l2update", | |||
"product_id": "BTC-USD", | |||
"time": "2019-08-14T20:42:27.265Z", | |||
"time": "2023-08-15T06:46:57.933713Z"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"time": "2023-08-15T06:46:57.933713Z"", | |
"time": "2023-08-15T06:46:57.933713Z", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦅
@@ -441,6 +441,7 @@ type WebsocketOrderbookSnapshot struct { | |||
Type string `json:"type"` | |||
Bids [][2]string `json:"bids"` | |||
Asks [][2]string `json:"asks"` | |||
Time string `json:"time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time string `json:"time"` | |
Time time.Time `json:"time"` |
exchanges/coinbasepro/coinbasepro.go
Outdated
@@ -50,6 +50,8 @@ const ( | |||
coinbaseproWithdrawalCrypto = "withdrawals/crypto" | |||
coinbaseproCoinbaseAccounts = "coinbase-accounts" | |||
coinbaseproTrailingVolume = "users/self/trailing-volume" | |||
|
|||
timeLayout = "2006-01-02T15:04:05.999999Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can rid this as Go can handle this
exchanges/hitbtc/hitbtc_types.go
Outdated
Sequence int64 `json:"sequence"` | ||
Symbol string `json:"symbol"` | ||
Sequence int64 `json:"sequence"` | ||
Timestamp string `json:"timestamp"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timestamp string `json:"timestamp"` | |
Timestamp time.Time `json:"timestamp"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely
🕊️
@@ -265,7 +269,7 @@ func (b *BTSE) wsHandleData(respRaw []byte) error { | |||
}) | |||
} | |||
return trade.AddTradesToBuffer(b.Name, trades...) | |||
case strings.Contains(topic, "orderBookL2Api"): | |||
case strings.Contains(topic, "orderBookL2Api"): // TODO: Fix orderbook updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTSE websocket orderbook not working. 🤷
exchanges/orderbook/depth_test.go
Outdated
@@ -253,7 +264,7 @@ func TestInvalidate(t *testing.T) { | |||
t.Fatalf("received: '%v' but expected: '%v'", err, ErrOrderbookInvalid) | |||
} | |||
|
|||
if err.Error() != "testexchange BTCWABI spot orderbook data integrity compromised Reason: [random reason]" { | |||
if err.Error() != "testexchange BTCWABI spot Reason: [orderbook data integrity compromised, random reason]" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if something else comes up, make this errors.Is
@@ -391,6 +391,20 @@ func (p *Poloniex) WsProcessOrderbookSnapshot(data []interface{}) error { | |||
errTypeAssertionFailure) | |||
} | |||
|
|||
if len(data) < 3 { | |||
return errNotEnoughData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should wrap this error with the above pair at least to help know that maybe its a terrible currency
if update.UpdateTime.IsZero() { | ||
return fmt.Errorf("%s %s %s %w", | ||
d.exchange, | ||
d.pair, | ||
d.asset, | ||
errLastUpdatedNotSet) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add coverage
if update.UpdateTime.IsZero() { | ||
return fmt.Errorf("%s %s %s %w", | ||
d.exchange, | ||
d.pair, | ||
d.asset, | ||
errLastUpdatedNotSet) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add coverage
if update.UpdateTime.IsZero() { | ||
return fmt.Errorf("%s %s %s %w", | ||
d.exchange, | ||
d.pair, | ||
d.asset, | ||
errLastUpdatedNotSet) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add coverage
exchanges/orderbook/depth.go
Outdated
d.pair, | ||
d.asset, | ||
errLastUpdatedNotSet) | ||
} | ||
tn := getNow() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed now we have an update time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nar not really, Last updated is more a time for when the update occurred at a matching engine level on the external exchange. This time is for the stack nodes when it gets pushed onto the stack to be re-used later more like an insertion time so it can be clean if its never been used. Either way the times are going to be like a second or two out depending on colocation from exchange and processing time. Default allowance is 30 seconds so might as well use it and reduce allocation. 🤷 🦅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks ACK!
…asher-corp#1318) * orderbook: Check assignment of time values and reject if not set. * linter: fix * buffer: additional linter winter fixter * Implement through pending exchanges * finished push * linty: minty * gomod: tidy * thrasher: nits * glorious: nits * orderbook: purge type now in favour of external call allocation * orderbook: push last param * orderbook: only 1 unlock call is needed --------- Co-authored-by: Ryan O'Hara-Reid <[email protected]>
PR Description
From PR #1315 some timestamps where not set. To maintain adequate data quality this should be strictly set and this PR rejects all snapshots and updates without a time value.
NOTES:
Fixes # (issue)
Type of change
Please delete options that are not relevant and add an
x
in[]
as item is complete.How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.
Checklist