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
exchanges: Kucoin Update #1438
base: master
Are you sure you want to change the base?
exchanges: Kucoin Update #1438
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 the improvement! Just two things I noticed on first glance. Also there is an issue with websocket orderbook syncs when running tests.
Kucoin error processing update - initiating new orderbook sync via REST: initial websocket orderbook sync failure for pair BTC-USDT and asset margin
exchanges/kucoin/kucoin_websocket.go
Outdated
return err | ||
} | ||
return ku.Subscribe(subscriptions) | ||
// return 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.
rm
exchanges/kucoin/kucoin.go
Outdated
case kline.OneWeek: | ||
return "1week", nil | ||
default: | ||
intervalMap := map[kline.Interval]string{ |
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.go b/exchanges/kucoin/kucoin.go
index 11eb3895a..78bab48f8 100644
--- a/exchanges/kucoin/kucoin.go
+++ b/exchanges/kucoin/kucoin.go
@@ -1721,10 +1721,11 @@ func (ku *Kucoin) SendAuthHTTPRequest(ctx context.Context, ePath exchange.URL, e
return resp.GetError()
}
+var intervalMap = map[kline.Interval]string{
+ kline.OneMin: "1min", kline.ThreeMin: "3min", kline.FiveMin: "5min", kline.FifteenMin: "15min", kline.ThirtyMin: "30min", kline.OneHour: "1hour", kline.TwoHour: "2hour", kline.FourHour: "4hour", kline.SixHour: "6hour", kline.EightHour: "8hour", kline.TwelveHour: "12hour", kline.OneDay: "1day", kline.OneWeek: "1week",
+}
+
func (ku *Kucoin) intervalToString(interval kline.Interval) (string, error) {
- intervalMap := map[kline.Interval]string{
- kline.OneMin: "1min", kline.ThreeMin: "3min", kline.FiveMin: "5min", kline.FifteenMin: "15min", kline.ThirtyMin: "30min", kline.OneHour: "1hour", kline.TwoHour: "2hour", kline.FourHour: "4hour", kline.SixHour: "6hour", kline.EightHour: "8hour", kline.TwelveHour: "12hour", kline.OneDay: "1day", kline.OneWeek: "1week",
- }
intervalString, okay := intervalMap[interval]
if !okay {
return "", kline.ErrUnsupportedInterval
diff --git a/exchanges/kucoin/kucoin_test.go b/exchanges/kucoin/kucoin_test.go
index 46e8d603e..560647320 100644
--- a/exchanges/kucoin/kucoin_test.go
+++ b/exchanges/kucoin/kucoin_test.go
@@ -2598,3 +2598,12 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
}
}
}
+
+func BenchmarkXxx(b *testing.B) {
+ for x := 0; x < b.N; x++ {
+ _, err := ku.intervalToString(kline.OneWeek)
+ if err != nil {
+ b.Fatal(err)
+ }
+ }
+}
You're allocating on every call.
Old:
3082915 370.7 ns/op 896 B/op 1 allocs/op
New:
223317469 5.501 ns/op 0 B/op 0 allocs/op
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 Sam!
… into kucoin_update
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1438 +/- ##
==========================================
- Coverage 37.75% 37.58% -0.18%
==========================================
Files 411 411
Lines 147817 148614 +797
==========================================
+ Hits 55815 55863 +48
- Misses 84218 84990 +772
+ Partials 7784 7761 -23
|
… into kucoin_update
… into kucoin_update
… into kucoin_update
… into kucoin_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.
Just happened to have been the first thing I looked at 😅
Do you think you could review and implement the latest changes to the API? If not, happy for a new PR for Kucoin's changes, but at least could you remove deprecated functions?
exchanges/kucoin/kucoin.go
Outdated
if size == 0 { | ||
return nil, errors.New("size can not be zero") | ||
} | ||
params := make(map[string]interface{}) |
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 endpoint is deprecated:
https://www.kucoin.com/announcement/the-kucoin-api-upgrade-has-been-completed-2023-09
- Deprecated: Place Isolated Borrow Order, abandon the "POST /api/v1/isolated/borrow" interface and replace it with the "POST /api/v3/margin/borrow" interface
I think there are more updates for Kucoin than in this PR
Well, Well, Well ... It is 26 endpoint 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.
linter and spell checker needs to be fixed
… into kucoin_update
… into kucoin_update
… into kucoin_update
Selam Everyone
This pull request incorporates extensive revisions to type definitions, rate limiters, request endpoints, and functions within the websocket handlers. Additionally, I've addressed linter issues and conducted unit tests.
Fixes # (issue)
Type of change
Please delete options that are not relevant and add an
x
in[]
as the item is complete.How has this been tested
Please describe the tests that you ran to verify your changes. Could you provide instructions so we can reproduce them? Please also list any relevant details for your test configuration and also, consider improving test coverage while working on a certain feature or package.
Checklist