gocryptotrader icon indicating copy to clipboard operation
gocryptotrader copied to clipboard

Kraken: Subscription improvements

Open gbjk opened this issue 1 year ago β€’ 11 comments

  • Move UpdateTradablePairs to a test This should not happen in TestMain just because it's a requirement for most tests. It should just be a non-parallel early test. That allows unit tests to run quickly without calling it, and allows proper clear failures
  • Separate auth and non-auth ws tests
  • Move SeedAssets from Setup to Start Having SeedAssets in Setup is cruel and unusual because it calls the API. Most other interactive data seeding happens in Start. This made it so that fixing and creating unit tests for Kraken was painfully slow, particularly on flaky internet.
  • Use Websocket subscriptionChannels instead of local slice
  • Remove ChannelID - Deprecated in docs I went both ways on this N+ times. ChannelID is great, but the bottom line is that it's deprecated, and not available in auth channels. By moving away from it we futureproof, and there's no downside really. Note that with or without
  • Simplify ping handlers and hardcodes message
  • Add Depth as configurable orderbook channel param
  • Simplify auth/non-auth channel updates

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] Improvement (non-functional improvements)

How has this been tested

  • [x] go test ./... -race
  • [x] golangci-lint run

gbjk avatar Oct 01 '23 09:10 gbjk

Rebased against master. Fixes for races and Unsub loops added.

gbjk avatar Oct 10 '23 07:10 gbjk

Rebased on master and pulled in the latest changes from the bitfinex PR's websockets improvements.

Note: There's a failure on Bitfinex here which is fixed in it's own PR.

gbjk avatar Oct 21 '23 08:10 gbjk

@shazbert This is ready for review; Please remove the label.

Rebased on master already.

gbjk avatar Nov 02 '23 06:11 gbjk

Just some errors running instance:

Ah damn it. When I rebased on your checkSubscriptions() recently I introduced an earlier EnsureKeyed. That breaks the "don't double up" check in Kraken's own ensureKeyed, which in hindsight wasn't very robust.

Okay. On it.

gbjk avatar Nov 11 '23 04:11 gbjk

@shazbert Thanks for that.

Fixed 20d8288

gbjk avatar Nov 11 '23 04:11 gbjk

I'm done fiddling this PR again. I know I circled back to fix the cancelOrder handling on this. @shazbert Commits 52f1d68..7cdf6e9 are the new ones; Sorry to add to this after your review.

gbjk avatar Dec 28 '23 03:12 gbjk

Thanks for letting me know, will check them out

shazbert avatar Dec 28 '23 03:12 shazbert

Codecov Report

Attention: 235 lines in your changes are missing coverage. Please review.

Comparison is base (59916a7) 43.32% compared to head (71f3cf5) 43.32%. Report is 4 commits behind head on master.

:exclamation: Current head 71f3cf5 differs from pull request most recent head a28851a. Consider uploading reports for the commit a28851a to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1358      +/-   ##
==========================================
- Coverage   43.32%   43.32%   -0.01%     
==========================================
  Files         366      366              
  Lines      146950   146995      +45     
==========================================
+ Hits        63672    63679       +7     
- Misses      75464    75475      +11     
- Partials     7814     7841      +27     
Files Coverage Ξ”
common/common.go 94.05% <100.00%> (+1.13%) :arrow_up:
exchanges/stream/websocket.go 82.75% <100.00%> (ΓΈ)
exchanges/bitfinex/bitfinex_wrapper.go 37.22% <0.00%> (+0.28%) :arrow_up:
exchanges/kraken/kraken_wrapper.go 37.36% <31.81%> (-1.73%) :arrow_down:
exchanges/kraken/kraken_websocket.go 46.75% <51.76%> (+14.85%) :arrow_up:

... and 13 files with indirect coverage changes

codecov[bot] avatar Jan 11 '24 02:01 codecov[bot]

@gloriousCode Thank you πŸ™ Changes made. Let me know if you're happy and I'll fixup down before Adrian's review

gbjk avatar Jan 15 '24 10:01 gbjk

@gloriousCode Build issue fixed; Ready for you

gbjk avatar Jan 17 '24 07:01 gbjk

Structure currently means 1 req per channel/pair for Kraken, so we could better handle failures. That's not performant enough by a long way with --enableallpairs.

Currently re-structuring slightly Pair πŸ‘‰ Pairs natively in Subscription.

gbjk avatar Jan 21 '24 03:01 gbjk

Will re-open this fresh. It's too cluttered and different to just force push and pretend nothing happened.

gbjk avatar Mar 22 '24 04:03 gbjk