wisespace-io / bitfinex-rs

Bitfinex trading api
Other
57 stars 33 forks source link

implemented and tested the RawBooks for the websocket stream #2

Closed JoshuaBatty closed 6 years ago

JoshuaBatty commented 6 years ago

Hey @wisespace-io thanks for your suggestions. Everything is working perfectly! Cheers.

JoshuaBatty commented 6 years ago

Actually, i'm finding some weird behaviour. It seems to only work every now and then.

i'd say 50% of the time it works as expected and I can receive the raw_book stream, the other 50% of the time im getting the following error

thread 'main' panicked at 'called Result::unwrap() on an Err value: Error(Json(Error("data did not match any variant of untagged enum NotificationEvent", line: 0, column: 0)), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', libcore/result.rs:945:5

Strange that it seems to happen randomly.... Not sure why this is.

wisespace-io commented 6 years ago

Okay, according to the error message, it is missing to handle a NotificationEvent: "data did not match any variant of untagged enum NotificationEvent"

I noticed that we are not handling the subscription confirmation for Raw Books. See: https://github.com/wisespace-io/bitfinex-rs/blob/master/src/events.rs#L9

I will merge your Pull Request and add it in another commit as we also need to update the chanId to u32 in all NotificatioEvents, plus fix a typo.

wisespace-io commented 6 years ago

@JoshuaBatty I implemented a fix and it should be fine now. I changed NotificationEvent, so check the example to update your code accordingly

https://github.com/wisespace-io/bitfinex-rs/blob/master/examples/src/public_channels.rs#L15

Thank you for the contribution

JoshuaBatty commented 6 years ago

Great thanks @wisespace-io !! :)