niXman / binapi

Binance API C++ implementation
Apache License 2.0
264 stars 88 forks source link

Pass parameters to WebSocket streams #26

Closed thunderquiet closed 3 years ago

thunderquiet commented 3 years ago

Hi,

How would I provide parameters to the WebSocket routes? For example, in the depth calls I would like to specify the depth and update speed.

Thank you.

niXman commented 3 years ago

hi,

I'm not sure if I understood you correctly... please explain.

thunderquiet commented 3 years ago

According to the documentation: https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams The stream supports depth and update frequency parameters. ex: <symbol>@5@100ms. If I try appending those to the symbol string in my code, I get back nothing, so presumably those need to be passed in some other way?

Thank you for helping out.

niXman commented 3 years ago

ah, got it.

I think need to change this member-fn as handle depth(const char *pair, std::size_t ms, on_depth_received_cb cb); and check the ms argument for 100/250/500, and according to the ms value change the second argument here.

can you make the necessary changes as PR?

niXman commented 3 years ago

hmm...

strange, but there are different values...

thunderquiet commented 3 years ago

Thanks for the tips. Created PR - https://github.com/niXman/binapi/pull/27

Not sure if it makes sense to make the parameter enum instead of size_t to enforce valid values. For example if user provides 600 they will get back nothing.

niXman commented 3 years ago

great, thanks!

but two points.

1) have you checked which values are correct? 100/250/500/1000 ? 2) yes I think be better to add enum.