-
Notifications
You must be signed in to change notification settings - Fork 822
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
Kucoin: Implement GetFuturesTickers, update UpdateTickers and enhance test coverage #1431
Kucoin: Implement GetFuturesTickers, update UpdateTickers and enhance test coverage #1431
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.
Thanks for opening this PR! This looks great. Just some minor things I came across.
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. 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.
Thanks @Beadko , the new endpoint and tests look great! A nit wrt to efficiency however
0e77547
to
9819129
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1431 +/- ##
==========================================
+ Coverage 43.35% 43.82% +0.46%
==========================================
Files 366 363 -3
Lines 147087 143963 -3124
==========================================
- Hits 63774 63086 -688
+ Misses 75489 73288 -2201
+ Partials 7824 7589 -235
|
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 opening this PR, however I'm not sure if it fits right now
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! Have some more feedback
0539eb8
to
cadd396
Compare
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.
Latest builds have a data race:
==================
WARNING: DATA RACE
Write at 0x00c000bfad30 by goroutine 452:
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.(*Kucoin).GetFuturesTickers.func1()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_wrapper.go:388 +0x2d1
Previous write at 0x00c000bfad30 by goroutine 453:
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.(*Kucoin).GetFuturesTickers.func1()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_wrapper.go:388 +0x2d1
Goroutine 452 (running) created at:
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.(*Kucoin).GetFuturesTickers()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_wrapper.go:384 +0x238
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.TestGetFuturesTickers()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_test.go:120 +0x64
testing.tRunner()
/opt/hostedtoolcache/go/1.21.6/x64/src/testing/testing.go:1595 +0x261
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.21.6/x64/src/testing/testing.go:1648 +0x44
Goroutine 453 (finished) created at:
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.(*Kucoin).GetFuturesTickers()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_wrapper.go:384 +0x238
github.com/thrasher-corp/gocryptotrader/exchanges/kucoin.TestGetFuturesTickers()
/home/runner/work/gocryptotrader/gocryptotrader/exchanges/kucoin/kucoin_test.go:120 +0x64
testing.tRunner()
/opt/hostedtoolcache/go/1.21.6/x64/src/testing/testing.go:1595 +0x261
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.21.6/x64/src/testing/testing.go:1648 +0x44
==================
--- FAIL: TestGetFuturesTickers (0.29s)
testing.go:1465: race detected during execution of test
--- FAIL: TestGetTicker (0.18s)
testing.go:1465: race detected during execution of test
--- FAIL: TestGetFuturesCurrentFundingRate (0.31s)
testing.go:1465: race detected during execution of test
--- FAIL: TestUpdateTickers (0.97s)
testing.go:1465: race detected during execution of test
FAIL
coverage: 38.8% of statements
Amended the error to fix the race issue |
Unfortunately there is still racing issues: https://github.com/thrasher-corp/gocryptotrader/actions/runs/7694212313/job/20964544279?pr=1431 |
That second race looks to be impacting master and not related to this PR as I just noticed it on a deps upgrade: https://github.com/thrasher-corp/gocryptotrader/actions/runs/7691800287/job/20957671281#step:9:394 |
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.
Just one nit and then this looks good to go
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 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.
Good stuff 2 minor things.
exchanges/kucoin/kucoin_wrapper.go
Outdated
if tick, err2 := ku.GetFuturesTicker(ctx, p.String()); err2 != nil { | ||
errC <- err2 | ||
} else { | ||
tickersC <- &ticker.Price{ |
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.
Bid size and ask size not set
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.
diff --git a/exchanges/kucoin/kucoin_wrapper.go b/exchanges/kucoin/kucoin_wrapper.go
index 0ac27b210..8aa921e70 100644
--- a/exchanges/kucoin/kucoin_wrapper.go
+++ b/exchanges/kucoin/kucoin_wrapper.go
@@ -375,6 +375,8 @@ func (ku *Kucoin) GetFuturesTickers(ctx context.Context) ([]*ticker.Price, error
Last: tick.Price.Float64(),
Bid: tick.BestBidPrice.Float64(),
Ask: tick.BestAskPrice.Float64(),
+ AskSize: tick.BestAskSize,
+ BidSize: tick.BestBidSize,
Volume: tick.Size,
Pair: p,
LastUpdated: tick.FilledTime.Time(),
exchanges/kucoin/kucoin_wrapper.go
Outdated
@@ -347,6 +347,62 @@ func (ku *Kucoin) UpdateTradablePairs(ctx context.Context, forceUpdate bool) err | |||
return nil | |||
} | |||
|
|||
// GetFuturesTickers does n * REST requests based on enabled pairs of the futures asset type | |||
func (ku *Kucoin) GetFuturesTickers(ctx context.Context) ([]*ticker.Price, error) { |
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.
Suggestion: shift to kucoin_futures.go as is not technically mapped to exchange.IBotInterfaceface
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! Thanks for making those changes!
go func() { | ||
defer wg.Done() | ||
|
||
if tick, err2 := ku.GetFuturesTicker(ctx, p.String()); err2 != nil { |
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.
Something I noticed that's outside of scope, but definitely in your interest is that the function ku.GetFuturesTicker
now has a rate limit weight of 2, versus it using the default of 1. Given that this is a request per ticker, this could impact you.
On further inspection I think this is impacting a few Kucoin Futures endpoints and the numbers seem a bit whack, so I'm fine with continuing on, with the idea to relook at this in future
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.
re-tACK, thanks @Beadko !
PR Description
Kucoin UpdateTickers returning incorrect values on futures.
Create the test to prove the concept.
Create a function GetFuturesTickers as the data is not available via the API call.
Expand the testing.
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