Skip to content

ExchangeHuobiAPI.OnGetTickersAsync() - System.ArgumentException: 'Accessed JArray values with invalid key value: "data". Int32 array index expected.' #421

Closed

Description

@GonzoKK

Possibly similar to #415

image

image

{[
{
"open": 0.429192,
"close": 0.43193,
"low": 0.42868,
"high": 0.444504,
"amount": 805.14014476611283,
"count": 2644,
"vol": 349.6994085636,
"symbol": "xmreth"
},
{
"open": 8.158E-05,
"close": 7.891E-05,
"low": 7.814E-05,
"high": 8.314E-05,
"amount": 16773.64,
"count": 4159,
"vol": 1.3340653106,
"symbol": "kmdbtc"
},
{
"open": 1.72E-05,
"close": 1.695E-05,
"low": 1.681E-05,
"high": 1.732E-05,
"amount": 174810.79712369648,
"count": 5410,
"vol": 2.975608026,
"symbol": "steembtc"
},
{
"open": 1.098E-07,
"close": 1.11E-07,
"low": 1.086E-07,
"high": 1.249E-07,
"amount": 212304373.11159352,
"count": 11322,
"vol": 23.393710267908219,
"symbol": "ncashbtc"

Activity

  1. GonzoKK commented on Aug 19, 2019

    @GonzoKK
    Author

    I'll have a stab at troubleshooting this...

    Firstly I removed "data" as its not there for this endpoint (see below)

    image

    Note that askKey and bidKey are hardcoded as null - which causes ParseTicker to crash on line 441

    image

    https://api.huobi.pro/market/tickers
    https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs

    This endpoint (for multiple tickers) returns:

    "open": 0.429192,
    "close": 0.43193,
    "low": 0.42868,
    "high": 0.444504,
    "amount": 805.14014476611283,
    "count": 2644,
    "vol": 349.6994085636,
    "symbol": "xmreth"

    Bid and Ask are not there, which means ParseTicker will fail.

    Looks like the code would only work for a single ticker eg
    https://api.huobi.pro/market/detail/merged?symbol=ethusdt

    but not for multiple tickers...

    A hack would be to test for null, but that means the ExchangeTicker would be not be populated with Ask and Bid.

    Any thoughts?

  2. vslee commented on Aug 19, 2019

    @vslee
    Collaborator

    Might have to switch to get aggregated tickers endpoint bc that has bid/ask.
    GET https://api.huobi.pro/market/detail/merged

  3. vslee commented on Aug 19, 2019

    @vslee
    Collaborator

    Yes, like you said, would work for only a single ticker not multiple. So we would have to loop through and call it multiple times if ppl wanted multiple tickers

  4. GonzoKK commented on Aug 20, 2019

    @GonzoKK
    Author

    Testing further... I changed askKey to "ask" and bidKey to "bid"

    image

    This however leads to a parsing error for symbol "hb10":

    "symbol": "hb10",
    "open": 0.6076,
    "close": 0.608,
    "low": 0.6009,
    "high": 0.6147,
    "amount": 0.0,
    "count": 0,
    "vol": 0.0

    image

    Seems the problem lies with api.ExchangeMarketSymbolToCurrencies(marketSymbol);

    image

    I reckon the symbol parsing logic can/should be improved

  5. vslee commented on Aug 20, 2019

    @vslee
    Collaborator

    What does hb10 refer to? Is that the name of a symbol?

  6. GonzoKK commented on Aug 21, 2019

    @GonzoKK
    Author
  7. GonzoKK commented on Sep 4, 2019

    @GonzoKK
    Author

    See potential fix at #424 (comment)

  8. jjxtra commented on Sep 5, 2019

    @jjxtra
    Collaborator

    Fixed in latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions