dougdellolio / coinbasepro-csharp

The unofficial .NET/C# client library for the Coinbase Pro/GDAX API
MIT License
192 stars 90 forks source link

nulls in Gdax ticker #111

Closed franklin770 closed 6 years ago

franklin770 commented 6 years ago

"best_bid" is null, NullValueHandling = NullValueHandling.Ignore,

Exception thrown: 'System.DivideByZeroException' in mscorlib.dll Ticker-{"type":"ticker","product_id":"BCH-BTC","price":0,"open_24h":0,"volume_24h":0,"low_24h":0,"high_24h":0,"volume_30d":"289.89382751","best_bid":null,"best_ask":"10.98"} Subscriptions-{"type":"subscriptions","channels":[{"name":"user","product_ids":["BTC-USD","BTC-EUR","BTC-GBP","ETH-USD","ETH-EUR","ETH-BTC","LTC-USD","LTC-EUR","LTC-BTC","BCH-USD","BCH-EUR","BCH-BTC"]},{"name":"ticker","product_ids":["BTC-USD","BTC-EUR","BTC-GBP","ETH-USD","ETH-EUR","ETH-BTC","LTC-USD","LTC-EUR","LTC-BTC","BCH-USD","BCH-EUR","BCH-BTC"]}]}

private static JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings { FloatParseHandling = FloatParseHandling.Decimal, NullValueHandling = NullValueHandling.Ignore, ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() } };

dougdellolio commented 6 years ago

hi @franklin770. can you please provide the parameters you used for the websocket feed to get this error? looks like maybe the user and ticker channel?

franklin770 commented 6 years ago

Hi Doug

It is on the ticker channel. there is definitely an exception being thrown

You have NullValueHandling.Ignore set, so it is being ignored

if you add Error = HandleDeserializationError you will catch it.

private static JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings { FloatParseHandling = FloatParseHandling.Decimal, NullValueHandling = NullValueHandling.Ignore, ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() }, Error = HandleDeserializationError };

public static void HandleDeserializationError(object sender, ErrorEventArgs errorArgs) { // errorArgs.ErrorContext.Handled = true; //}

    }

However, looking into it more, there may be another error on my side. investigating.

BTW

I am getting this quite often.

    private void WebSocket_Error(object sender,

SuperSocket.ClientEngine.ErrorEventArgs e) { throw new GDAXSharpWebSocketException($"WebSocket Feed Error: {e.Exception.Message}") { WebSocket = WebSocketFeed, StatusCode = WebSocketFeed.State, ErrorEvent = e

        };
    }

Thanks

On Thu, Apr 12, 2018 at 7:19 PM, Doug Dellolio notifications@github.com wrote:

hi @franklin770 https://github.com/franklin770. can you please provide the parameters you used for the websocket feed to get this error? looks like maybe the user and ticker channel?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dougdellolio/gdax-csharp/issues/111#issuecomment-380973083, or mute the thread https://github.com/notifications/unsubscribe-auth/ASpk6CoOzJdCyP6hd8W2Zpw41Kg-HJZSks5tn-EegaJpZM4TSmZm .

franklin770 commented 6 years ago

yes I am using user, and ticker channel

On Thu, Apr 12, 2018 at 8:09 PM, Avi Franklin srdinc@gmail.com wrote:

Hi Doug

It is on the ticker channel. there is definitely an exception being thrown

You have NullValueHandling.Ignore set, so it is being ignored

if you add Error = HandleDeserializationError you will catch it.

private static JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings { FloatParseHandling = FloatParseHandling.Decimal, NullValueHandling = NullValueHandling.Ignore, ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() }, Error = HandleDeserializationError };

public static void HandleDeserializationError(object sender, ErrorEventArgs errorArgs) { // errorArgs.ErrorContext.Handled = true; //}

    }

However, looking into it more, there may be another error on my side. investigating.

BTW

I am getting this quite often.

    private void WebSocket_Error(object sender,

SuperSocket.ClientEngine.ErrorEventArgs e) { throw new GDAXSharpWebSocketException($"WebSocket Feed Error: {e.Exception.Message}") { WebSocket = WebSocketFeed, StatusCode = WebSocketFeed.State, ErrorEvent = e

        };
    }

Thanks

On Thu, Apr 12, 2018 at 7:19 PM, Doug Dellolio notifications@github.com wrote:

hi @franklin770 https://github.com/franklin770. can you please provide the parameters you used for the websocket feed to get this error? looks like maybe the user and ticker channel?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dougdellolio/gdax-csharp/issues/111#issuecomment-380973083, or mute the thread https://github.com/notifications/unsubscribe-auth/ASpk6CoOzJdCyP6hd8W2Zpw41Kg-HJZSks5tn-EegaJpZM4TSmZm .

dougdellolio commented 6 years ago

can't seem to replicate this and see any errors :/. the error i see being thrown in the exception above is DivideByZeroException. are you doing math around the data?

franklin770 commented 6 years ago

Hi Doug.

I am doing math and the DivideByZeroException that I was getting is also on my side. I mistakenly thought that the DivideByZeroException that is being thrown in the websocket was the cause

Thanks for replying

Regards

On Thu, Apr 12, 2018 at 8:20 PM, Doug Dellolio notifications@github.com wrote:

can't seem to replicate this and see any errors :/. the error i see being thrown in the exception above is DivideByZeroException. are you doing math around the data?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dougdellolio/gdax-csharp/issues/111#issuecomment-380983011, or mute the thread https://github.com/notifications/unsubscribe-auth/ASpk6C6ywB9MbNjhyTBYR2es_Yfc1Ussks5tn-9agaJpZM4TSmZm .

dougdellolio commented 6 years ago

glad its fixed 😄 will close this.

franklin770 commented 6 years ago

Thx.

That's the problem with using the stupid sandbox. The prices are all off from the actual production prices, and it returns 0 for bid/ask etc.

I have to move to the realtime but my code is not there yet

On Thu, Apr 12, 2018 at 9:42 PM, Doug Dellolio notifications@github.com wrote:

Closed #111 https://github.com/dougdellolio/gdax-csharp/issues/111.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dougdellolio/gdax-csharp/issues/111#event-1572290941, or mute the thread https://github.com/notifications/unsubscribe-auth/ASpk6BYKjOOoR4peEfetWXYurt5iOiiWks5toAKXgaJpZM4TSmZm .