JKorf / Bitfinex.Net

A C# .netstandard client library for the Bitfinex REST and Websocket API focusing on clear usage and models
https://jkorf.github.io/Bitfinex.Net/
MIT License
88 stars 50 forks source link

SubcribeToOrderBookUpdates fails to deserialize snapshot due to `int` size #88

Closed cmroche closed 5 years ago

cmroche commented 5 years ago

When calling _bfxSocketClient.SubscribeToBookUpdatesAsync("BTCUSD", Precision.PrecisionLevel2, Frequency.Realtime, 100) deserialization will fail with this in the output:

2019/06/24 22:01:49:716 | Warning | Failed to deserialize Book snapshot object: 5: Error deserializing data: Deserialize Unknown Exception: Value was either too large or too small for an Int32.. Received data: [
  [
    370513707,
    1561428107739,
    0.025,
    11125.13150095
  ],

The function, however, succeeds with other less popular currency pairs such as "ETHUSD".

JKorf commented 5 years ago

Hi, thats very odd. I tried that exact call but it works for me. The data returned for example is this for me: [11500,460,-604.89727245], which is [price, count, amount]. I'm not sure what the format is you received. Do you have any more context? Are you subscribing multiple things concurrently? Does it always happen?

cmroche commented 5 years ago

I am also subscribing to trades at the same time (for the same asset). I am able to received trades without an issue, but never received order books, fails during the snapshot with that error.

I may not be able to come back to this until the weekend, but I can try disabling trades and get a bit more information. Also, while I thought this was working for smaller asset volumes, I was wrong. It fails in all cases I try.

JKorf commented 5 years ago

Hi, the problem was indeed subscribing to them in parallel, after which it tried to deserialize book data into trade data. I've pushed a new version in which this should be fixed!

cmroche commented 5 years ago

Confirmed, my test cases all passed after updating. Thanks for the quick fix.