Skip to content
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

Merged
merged 1 commit into from Nov 1, 2023

Conversation

bailantaotao
Copy link
Collaborator

@bailantaotao bailantaotao commented Oct 31, 2023

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.

@bbgokarma-bot
Copy link

Welcome back! @bailantaotao, This pull request may get 661 BBG.

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
Copy link
Owner

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?

Copy link
Collaborator Author

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
Copy link
Owner

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?

Copy link
Collaborator Author

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.

High: k.HighestPrice,
Low: k.LowestPrice,
Volume: k.Volume,
QuoteVolume: 0, // not supported
Copy link
Owner

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

@@ -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"):
Copy link
Owner

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 ?

Copy link
Collaborator Author

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

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 740 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 745 BBG

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #1380 (102b662) into main (7c1060c) will increase coverage by 0.12%.
The diff coverage is 64.40%.

Impacted file tree graph

@@            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     
Files Coverage Δ
pkg/exchange/bitget/stream_callbacks.go 0.00% <0.00%> (ø)
pkg/exchange/bitget/types.go 60.89% <86.36%> (+18.67%) ⬆️
pkg/exchange/bitget/stream.go 32.68% <41.30%> (+2.24%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c1060c...102b662. Read the comment docs.

@bailantaotao bailantaotao merged commit d758efc into c9s:main Nov 1, 2023
4 checks passed
@bailantaotao bailantaotao deleted the edwin/bitget/add-kline branch November 1, 2023 11:32
@bbgokarma-bot
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants