-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
FEATURE: [bitget] support kline subscription on stream #1380
Conversation
Welcome back! @bailantaotao, This pull request may get 661 BBG. |
pkg/exchange/bitget/stream.go
Outdated
return nil, fmt.Errorf("failed to unmarshal data into KLineEvent, Arg: %+v Data: %s, err: %w", event.Arg, string(event.Data), err) | ||
} | ||
|
||
kline.actionType = event.Action |
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.
i think you can make these field public?
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.
The action type is used in the current package, so i made it private.
t.Log("got closed update", kline) | ||
}) | ||
c := make(chan struct{}) | ||
<-c |
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 test will be blocked?
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.
yeah~but it will be skipped in CI tests. if we want to see something, we can run this test to view the results.
pkg/exchange/bitget/types.go
Outdated
High: k.HighestPrice, | ||
Low: k.LowestPrice, | ||
Volume: k.Volume, | ||
QuoteVolume: 0, // not supported |
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.
lint error, you should use fixedpoint.Zero here
pkg/exchange/bitget/stream.go
Outdated
@@ -212,7 +225,19 @@ func parseEvent(in []byte) (interface{}, error) { | |||
book.instId = event.Arg.InstId | |||
return &book, nil | |||
|
|||
case ChannelTrade: | |||
case strings.HasPrefix(string(ch), "candle"): |
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.
maybe you can pull out this case to a if statement that runs before this switch, so that you switch cases could be simplified ?
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.
Or i pull it out to default? like:
default:
if strings.HasPrefix(string(ch), "candle") {
var kline KLineEvent
err = json.Unmarshal(event.Data, &kline.Events)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal data into KLineEvent, Arg: %+v Data: %s, err: %w", event.Arg, string(event.Data), err)
}
kline.actionType = event.Action
kline.channel = ch
kline.instId = event.Arg.InstId
return &kline, nil
}
// other case are return err.
I hope that every event is handled in switch-case
33049ba
to
6499ecf
Compare
Re-estimated karma: this pull request may get 740 BBG |
6499ecf
to
102b662
Compare
Re-estimated karma: this pull request may get 745 BBG |
Codecov Report
@@ Coverage Diff @@
## main #1380 +/- ##
==========================================
+ Coverage 20.92% 21.05% +0.12%
==========================================
Files 568 568
Lines 40774 40890 +116
==========================================
+ Hits 8533 8608 +75
- Misses 31609 31647 +38
- Partials 632 635 +3
Continue to review full report in Codecov by Sentry.
|
Hi @bailantaotao, Well done! 755 BBG has been sent to your polygon wallet. Please check the following tx: https://polygonscan.com/tx/0xd771835040cb32e22c490a0aafd4ee019c31b83cf86f94b947d588a5b392a240 Thank you for your contribution! |
https://bitgetlimited.github.io/apidoc/en/spot/#candlesticks-channel
The closed flag of Kline is not supported by Bitget. Therefore, we store the last Kline to compare the time duration and determine whether the Kline is closed.