glitch100 / BinanceDotNet

Official C# Wrapper for the Binance exchange API, with REST and WebSocket endpoints

Home Page:https://www.nuget.org/packages/BinanceDotNet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JsonSerializationException when using ConnectToIndividualSymbolTickerWebSocket?

masanaka opened this issue · comments

Hello.
When I using ConnectToIndividualSymbolTickerWebSocket, JsonSerializationException happend.
I checked the stream doc, found BinanceAggregateTradeData looks like not fit for the response.
Is something wrong?

I have the same problem. Exception i get is

Newtonsoft.Json.JsonSerializationException: 'Error converting value "3680.90000000" to type 'System.Int64'. Path 'a', line 1, position 213.'

Do either of you @filippopovic or @masanaka want to do a PR for this?

public Guid ConnectToIndividualSymbolTickerWebSocket(BinanceWebSocketMessageHandler<BinanceAggregateTradeData> messageEventHandler)

BinanceAggregateTradeData must get replaced with BinanceTradeData.
but there is still a problem. websocket cant handel Lists/Arrays, design fail

ErrorMsg:
{"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BinanceExchange.API.Models.WebSocket.BinanceTradeData' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath '', line 1, position 1."}

Data:

"[{\"e\":\"24hrTicker\",\"E\":1563082102020,\"s\":\"ETHBTC\",\"p\":\"0.00040900\",\"P\":\"1.751\",\"w\":\"0.02372569\",\"x\":\"0.02335200\",\"c\":\"0.02376200\",\"Q\":\"0.05100000\",\"b\":\"0.02376200\",\"B\":\"0.56200000\",\"a\":\"0.02376300\",\"A\":\"1.45600000\",\"o\":\"0.02335300\",\"h\":\"0.02434700\",\"l\":\"0.02330400\",\"v\":\"158721.39000000\",\"q\":\"3765.77450455\",\"O\":1562995702015,\"C\":1563082102015,\"F\":133436105,\"L\":133579725,\"n\":143621},{\"e\":\"24hrTicker\",\"E\":1563082101964,\"s\":\"LTCBTC\",\"p\":\"0.00003900\",\"P\":\"0.438\",\"w\":\"0.00893864\",\"x\":\"0.00889300\",\"c\":\"0.00893300\",\"Q\":\"10.46000000\",\"b\":\"0.00893800\",\"B\":\"0.22000000\",\"a\":\"0.00894000\",\"A\":\"9.01000000\",\"o\":\"0.00889400\",\"h\":\"0.00913000\",\"l\":\"0.00880600\",\"v\":\"182972.51000000\",\"q\":\"1635.52607272\",\"O\":1562995701957,\"C\":1563082101957,\"F\":31188463,\"L\":31240813,\"n\":52351},{\"e\":\"24hrTicker\",\"E\":1563082102237,\"s\":\"BNBBTC\",\"p\":\"0.00003190\",\"P\":\"1.165\",\"w\":\"0.00276125\",\"x\":\"0.00273670\",\"c\":\"0.00276960\",\"Q\":\"4.85000000\",\"b\":\"0.00276860\",\"B\":\"45.97000000\",\"a\":\"0.00276990\",\"A\":\"58.98000000\",\"o\":\"0.00273770\",\"h\":\"0.00280000\",\"l\":\"0.00270980\",\"v\":\"2291328.43000000\",\"q\":\"6326.92075756\",\"O\":1562995702231,\"C\":1563082102231,\"F\":54808800,\"L\":54967644,\"n\":158845},{\"e\":\"24hrTicker\",\"E\":1563082101615,\"s\":\"NEOBTC\",\"p\":\"-0.00005100\",\"P\":\"-3.957\",\"w\":\"0.00126509\",\"x\":\"0.00129000\",\"c\":\"0.00123800\",\"Q\":\"123.73000000\",\"b\":\"0.00123700\",\"B\":\"110.39000000\",\"a\":\"0.00123900\",\"A\":\"711.00000000\",\"o\":\"0.00128900\",\"h\":\"0.00130700\",\"l\":\"0.00122600\",\"v\":\"384343.60000000\",\"q\":\"486.22822450\",\"O\":1562995701609,\"C\":1563082101609,\"F\":28039865,\"L\":28062988,\"n\":23124},{\"e\":\"24hrTicker\",\"E\":1563082102216,\"s\":\"QTUMETH\",\"p\":\"-0.00033400\",\"P\":\"-2.443\",\"w\":\"0.01339483\",\"x\":\"0.01368900\",\"c\":\"0.01334000\",\"Q\":\"0.53000000\",\"b\":\"0.01326200\",\"B\":\"60.37000000\",\"a\":\"0.01333400\",\"A\":\"5.40000000\",\"o\":\"0.01367400\",\"h\":\"0.01377000\",\"l\":\"0.01296700\",\"v\":\"23932.43000000\",\"q\":\"320.57086246\",\"O\":1562995702209,\"C\":1563082102209,\"F\":3688002,\"L\":3689266,\"n\":1265},{\"e\":\"24hrTicker\",\"E\":1563082102219,\"s\":\"BTCUSDT\",\"p\":\"-411.08000000\",\"P\":\"-3.536\",\"w\":\"11275.28619521\",\"x\":\"11627.17000000\",\"c\":\"11215.47000000\",\"Q\":\"0.00102700\",\"b\":\"11214.81000000\",\"B\":\"0.15267300\",\"a\":\"11215.57000000\",\"A\":\"0.00000400\",\"o\":\"11626.55000000\",\"h\":\"11652.95000000\",\"l\":\"10830.00000000\",\"v\":\"56028.53955100\",\"q\":\"631737818.53704864\",\"O\":1562995702212,\"C\":1563082102212,\"F\":153851955,\"L\":154375091,\"n\":523137},{\"e\":\"24hrTicker\",\"E\":1563082102129,\"s\":\"ETHUSDT\",\"p\":\"-4.84000000\",\"P\":\"-1.783\",\"w\":\"267.89085625\",\"x\":\"271.45000000\",\"c\":\"266.61000000\",\"Q\":\"1.87540000\",\"b\":\"266.53000000\",\"B\":\"0.00071000\",\"a\":\"266.61000000\",\"A\":\"0.80182000\",\"o\":\"271.45000000\",\"h\":\"271.87000000\",\"l\":\"262.20000000\",\"v\":\"199853.77118000\",\"q\":\"53538997.88587070\",\"O\":1562995702123,\"C\":1563082102123,\"F\":86092648,\"L\":86221514,\"n\":128867},{\"e\":\"24hrTicker\",\"E\":1563082101764,\"s\":\"OMGETH\",\"p\":\"-0.00031100\",\"P\":\"-4.336\",\"w\":\"0.00699986\",\"x\":\"0.00717300\",\"c\":\"0.00686100\",\"Q\":\"3.56000000\",\"b\":\"0.00684100\",\"B\":\"34.14000000\",\"a\":\"0.00685800\",\"A\":\"126.70000000\",\"o\":\"0.00717200\",\"h\":\"0.00722000\",\"l\":\"0.00675100\",\"v\":\"104549.02000000\",\"q\":\"731.82870178\",\"O\":1562995701758,\"C\":1563082101758,\"F\":3446773,\"L\":3448575,\"n\":1803},{\"e\":\"24hrTicker\",\"E\":1563082101875,\"s\":\"STRATBTC\",\"p\":\"0.00000060\",\"P\":\"1.015\",\"w\":\"0.00005964\",\"x\":\"0.00005900\",\"c\":\"0.00005970\",\"Q\":\"320.08000000\",\"b\":\"0.00005970\",\"B\":\"270.15000000\",\"a\":\"0.00005980\",\"A\":\"208.19000000\",\"o\":\"0.00005910\",\"h\":\"0.00006050\",\"l\":\"0.00005840\",\"v\":\"458868.30000000\",\"q\":\"27.36865574\",\"O\":1562995701870,\"C\":1563082101870,\"F\":8272585,\"L\":8274822,\"n\":2238},{\"e\":\"24hrTicker\",\"E\":1563082102194,\"s\":\"STRATETH\",\"p\":\"-0.00000700\",\"P\":\"-0.278\",\"w\":\"0.00252411\",\"x\":\"0.00253200\",\"c\":\"0.00251300\",\"Q\":\"51.13000000\",\"b\":\"0.00250900\",\"B\":\"158.70000000\",\"a\":\"0.00253000\",\"A\":\"673.52000000\",\"o\":\"0.00252000\",\"h\":\"0.00257300\",\"l\":\"0.00246300\",\"v\":\"28514.43000000\",\"q\":\"71.97350545\",\"O\":1562995702189,\"C\":1563082102189,\"F\":1290922,\"L\":1291292,\"n\":371},{\"e\":\"24hrTicker\",\"E\":1563082101742,\"s\":\"SNGLSBTC\",\"p\":\"-0.00000003\",\"P\":\"-2.941\",\"w\":\"0.00000101\",\"x\":\"0.00000101\",\"c\":\"0.00000099\",\"Q\":\"7920.00000000\",\"b\":\"0.00000099\",\"B\":\"140464.00000000\",\"a\":\"0.00000100\",\"A\":\"229992.00000000\",\"o\":\"0.00000102\",\"h\":\"0.00000105\",\"l\":\"0.00000098\",\"v\":\"17045442.00000000\",\"q\":\"17.14900249\",\"O\":1562995701735,\"C\":1563082101735,\"F\":4394840,\"L\":4396146,\"n\":1307},{\"e\":\"24hrTicker\",\"E\":1563082101737,\"s\":\"SNGLSETH\",\"p\":\"-0.00000161\",\"P\":\"-3.691\",\"w\":\"0.00004280\",\"x\":\"0.00004356\",\"c\":\"0.00004201\",\"Q\":\"974.00000000\",\"b\":\"0.00004166\",\"B\":\"1006.00000000\",\"a\":\"0.00004206\",\"A\":\"2479.00000000\",\"o\":\"0.00004362\",\"h\":\"0.00004460\",\"l\":\"0.00004132\",\"v\":\"404010.00000000\",\"q\":\"17.29107865\",\"O\":1562995701730,\"C\":1563082101730,\"F\":1182364,\"L\":1182479,\"n\":116},{\"e\":\"24hrTicker\",\"E\":1563082101787,\"s\":\"BQXBTC\",\"p\":\"-0.00000030\",\"P\":\"-2.400\",\"w\":\"0.00001228\",\"x\":\"0.00001249\",\"c\":\"0.00001220\",\"Q\":\"4.00000000\",\"b\":\"0.00001213\",\"B\":\"1116.00000000\",\"a\":\"0.00001220\",\"A\":\"4400.00000000\",\"o\":\"0.00001250\",\"h\":\"0.00001330\",\"l\":\"0.00001075\",\"v\":\"13743407.00000000\",\"q\":\"168.77038167\",\"O\":1562995701781,\"C\":1563082101781,\"F\":6374762,\"L\":6391504,\"n\":16743},{\"e\":\"24hrTicker\",\"E\":1563082101782,\"s\":\"BQXETH\",\"p\":\"-0.00002670\",\"P\":\"-4.958\",\"w\":\"0.00051445\",\"x\":\"0.00053400\",\"c\":\"0.00051180\",\"Q\":\"52.00000000\",\"b\":\"0.00050920\",\"B\":\"4393.00000000\",\"a\":\"0.00051190\",\"A\":\"2445.00000000\",\"o\":\"0.00053850\",\"h\":\"0.00056420\",\"l\":\"0.00048820\",\"v\":\"967974.00000000\",\"q\":\"497.97152710\",\"O\":1562995701775,\"C\":1563082101775,\"F\":1314685,\"L\":1316429,\"n\":1745},{\"e\":\"24hrTicker\",\"E\":1563082101640,\"s\":\"KNCETH\",\"p\":\"-0.00001720\",\"P\":\"-2.115\",\"w\":\"0.00079853\",\"x\":\"0.00081630\",\"c\":\"0.00079590\",\"Q\":\"515.00000000\",\"b\":\"0.00079330\",\"B\":\"300.00000000\",\"a\":\"0.00079590\",\"A\":\"1118.00000000\",\"o\":\"0.00081310\",\"h\":\"0.00081680\",\"l\":\"0.00078870\",\"v\":\"267519.00000000\",\"q\":\"213.62196100\",\"O\":1562995701634,\"C\":1563082101634,\"F\":2213643,\"L\":2214524,\"n\":882},{\"e\":\"24hrTicker\",\"E\":1563082101909,\"s\":\"IOTABTC\",\"p\":\"0.00000037\",\"P\":\"1.235\",\"w\":\"0.00003037\",\"x\":\"0.00002999\",\"c\":\"0.00003034\",\"Q\":\"257.00000000\",\"b\":\"0.00003030\",\"B\":\"692.00000000\",\"a\":\"0.00003038\",\"A\":\"197.00000000\",\"o\":\"0.00002997\",\"h\":\"0.00003101\",\"l\":\"0.00002993\",\"v\":\"2887716.00000000\",\"q\":\"87.70133914\",\"O\":1562995701904,\"C\":1563082101904, ......................"