-
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
Okx: Fix sending trades to the websocket DataHandler #1833
base: master
Are you sure you want to change the base?
Conversation
Update the test to process trades for each asset type Add raw trade data from OKX Update the timestamp in the method
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!
exchanges/okx/okx_test.go
Outdated
instrumentID := "BTC-USDT" | ||
assets, err := ok.getAssetsFromInstrumentID(instrumentID) |
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.
instrumentID := "BTC-USDT" | |
assets, err := ok.getAssetsFromInstrumentID(instrumentID) | |
assets, err := ok.getAssetsFromInstrumentID("BTC-USDT") |
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.
amended
exchanges/okx/okx_test.go
Outdated
require.Len(t, ok.Websocket.DataHandler, total, | ||
"Must see correct number of trades") |
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.Len(t, ok.Websocket.DataHandler, total, | |
"Must see correct number of trades") | |
require.Len(t, ok.Websocket.DataHandler, total, "Must see correct number of trades") |
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
exchanges/okx/okx_test.go
Outdated
for _, a := range assets { | ||
receivedTrades[a] = []trade.Data{} | ||
} |
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 remove this
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.
removed
exchanges/okx/okx_test.go
Outdated
require.Len(t, trades, len(exp), | ||
"Should have received %d trades for asset %v", len(exp), assetType) |
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.Len(t, trades, len(exp), | |
"Should have received %d trades for asset %v", len(exp), assetType) | |
require.Len(t, trades, len(exp), "Should have received %d trades for asset %v", len(exp), assetType) |
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
exchanges/okx/okx_test.go
Outdated
trades, exists := receivedTrades[assetType] | ||
require.True(t, exists, "Should have received trades for asset %v", assetType) |
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.
This exists check is handled below by the trades length check and can be removed
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.
removed
exchanges/okx/okx_test.go
Outdated
require.Equal(t, expected, trade, | ||
"Trade %d (TID: %s) for asset %v should match expected data", | ||
i, trade.TID, assetType) |
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.Equal(t, expected, trade, | |
"Trade %d (TID: %s) for asset %v should match expected data", | |
i, trade.TID, assetType) | |
require.Equal(t, expected, trade, "Trade %d (TID: %s) for asset %v should match expected data", i, trade.TID, assetType) |
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
return trade.AddTradesToBuffer(trades...) | ||
if tradeFeed { | ||
for i := range trades { | ||
ok.Websocket.DataHandler <- trades[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.
OOS: In trade.go under method Update
we are passing the entire slice which can be updated to only send through individual updates. If you want to use this function to cut down on some code you are more than welcome. ok.Websocket.Trade.Update(...)
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.
Will leave this out of this PR if that's ok
PR Description
Trades are not being sent down to the websocket DataHandler because the IsTradeFeedEnabled is not set.
Additional changes:
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