-
Notifications
You must be signed in to change notification settings - Fork 837
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
Kraken: Fix sending trades to the websocket DataHandler #1813
Kraken: Fix sending trades to the websocket DataHandler #1813
Conversation
When the tradeFeed is enabled, send the trades down the DataHandler Add TestWSProcessTrades
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 @Beadko! Just some minor things I saw.
@@ -531,7 +531,10 @@ func (k *Kraken) wsProcessTrades(response []any, pair currency.Pair) error { | |||
if !ok { | |||
return errors.New("received invalid trade data") | |||
} | |||
if !k.IsSaveTradeDataEnabled() { | |||
saveTradeData := k.IsSaveTradeDataEnabled() | |||
tradeFeed := k.IsTradeFeedEnabled() |
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.
OOS: Just highlighting this as trade feed enabled is not necessary as it's a subscription customisation. No change needed.
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 Bea!
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.
Thank you Beadko!
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.
ch ACK. 🚀
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.
tACK
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.
Great work 🎉
I think there's more than just nits here, so marking for changes.
Send individual trades down the DataHandler Send multiple trades in test Test error if the trade length is too short Nits
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.
Great work; Looks good to me 🎉
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.
Changes ACK!
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 the PR @Beadko! Just some minor nits
exchanges/kraken/kraken_test.go
Outdated
i := 1 - len(k.Websocket.DataHandler) | ||
exp := trade.Data{Exchange: k.Name, CurrencyPair: spotTestPair} | ||
require.NoErrorf(t, json.Unmarshal([]byte(expJSON[i]), &exp), "Must not error unmarshalling json %d: %s", i, expJSON[i]) | ||
require.Equalf(t, exp, v, "Trade [%d] should be correct", i) |
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.
require.Equalf(t, exp, v, "Trade [%d] should be correct", i) | |
require.Equalf(t, exp, v, "Trade [%d] must be correct", i) |
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.
done
common/common.go
Outdated
@@ -72,6 +72,7 @@ var ( | |||
ErrUnknownError = errors.New("unknown error") | |||
ErrGettingField = errors.New("error getting field") | |||
ErrSettingField = errors.New("error setting field") | |||
ErrParsingWSField = errors.New("error parsing WS field") |
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.
ErrParsingWSField = errors.New("error parsing WS field") | |
ErrParsingWSField = errors.New("error parsing websocket field") |
This wasn't your doing, but I'd prefer that we don't use acronyms for error messages
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.
No worries, I originally wrote "websocket" but changed it when I saw the original errors 😄 . Updated
exchanges/bitfinex/bitfinex_test.go
Outdated
@@ -1997,7 +1997,7 @@ func TestGetErrResp(t *testing.T) { | |||
seen++ | |||
switch seen { | |||
case 1: // no event | |||
assert.ErrorIs(t, testErr, errParsingWSField, "Message with no event Should get correct error type") | |||
assert.ErrorIs(t, testErr, common.ErrParsingWSField, "Message with no event Should get correct error type") |
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.
assert.ErrorIs(t, testErr, common.ErrParsingWSField, "Message with no event Should get correct error type") | |
assert.ErrorIs(t, testErr, common.ErrParsingWSField, "Message with no event should get correct error type") |
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.
done
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!
PR Description
Currently, the Kraken trades are not streaming via the websocket.
Fix: when the tradeFeed is set to
true
, send the data down to the WebSocket DataHandler. Add a test.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