KiteConnect.DataException: Unable to parse data - Error in KiteConnect.Kite.GetPositions()

onlineRaman
I am getting this error very frequently:

KiteConnect.DataException: Unable to parse data. {"tradingsymbol":"SAIL","exchange":"NSE","instrument_token":758529,"product":"BO","quantity":28,"overnight_quantity":0,"multiplier":1,"average_price":35.35,"close_price":0,"last_price":35.35,"value":-989.8,"pnl":1.1368683772161603E-13,"m2m":1.1368683772161603E-13,"unrealised":1.1368683772161603E-13,"realised":0,"buy_quantity":28,"buy_price":35.35,"buy_value":989.8,"buy_m2m":989.8,"sell_quantity":0,"sell_price":0,"sell_value":0,"sell_m2m":0,"day_buy_quantity":28,"day_buy_price":35.35,"day_buy_value":989.8,"day_sell_quantity":0,"day_sell_price":0,"day_sell_value":0}
at KiteConnect.Position..ctor(Dictionary`2 data)
at KiteConnect.PositionResponse..ctor(Dictionary`2 data)
at CallSite.Target(Closure , CallSite , Type , Object )
at KiteConnect.Kite.GetPositions()
Tagged:
  • sujith
    This shouldn't happen. Can you let us know more about this issue?
    Please let us know which version of the library you are using, your setup and some more details to debug or reproduce.
  • jeevansevar
    Even i am also gettin same error i am using 3.0 version API

    Unable to parse data.
    {"tradingsymbol":"SBIN","exchange":"NSE","instrument_token":779521,"product":"MIS","quantity":1,"overnight_quantity":0,"multiplier":1,
    "average_price":332.4,"close_price":0,"last_price":331.7,"value":-331.70000000000005,
    "pnl":-5.6843418860808015E-14,"m2m":-5.6843418860808015E-14,
    "unrealised":-5.6843418860808015E-14,"realised":0,"buy_quantity":5,"buy_price":332.4,"buy_value":1662,"buy_m2m":1662,"sell_quantity":4,"sell_price":332.575,"sell_value":1330.3,"sell_m2m":1330.3,"day_buy_quantity":5,"day_buy_price":332.4,
    "day_buy_value":1662,"day_sell_quantity":4,"day_sell_price":332.575,"day_sell_value":1330.3}
  • kcsomisetty
    I am getting same error too.
    Looks like it happens if there is a opening position with SBIN.

    I am using c# SDK kiteconnect 3.0
  • kcsomisetty
    sorry, it happens with other stocks too. (ex: IOC).
    looks like a typecast exception in my case.

    full stack is
    Feb-05 12:45:00 Zerodha : GetAllPositions => KiteConnect.DataException: Unable to parse data. {"tradingsymbol":"IOC","exchange":"NSE","instrument_token":415745,"product":"MIS","quantity":-1,"overnight_quantity":0,"multiplier":1,"average_price":115.05,"close_price":0,"last_price":114.95,"value":114.94999999999999,"pnl":-1.4210854715202004E-14,"m2m":-1.4210854715202004E-14,"unrealised":-1.4210854715202004E-14,"realised":0,"buy_quantity":1,"buy_price":115.15,"buy_value":115.15,"buy_m2m":115.15,"sell_quantity":2,"sell_price":115.05,"sell_value":230.1,"sell_m2m":230.1,"day_buy_quantity":1,"day_buy_price":115.15,"day_buy_value":115.15,"day_sell_quantity":2,"day_sell_price":115.05,"day_sell_value":230.1} ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'double' to 'decimal'. An explicit conversion exists (are you missing a cast?)
    at CallSite.Target(Closure , CallSite , Object )
    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    at CallSite.Target(Closure , CallSite , Object )
    at KiteConnect.Position..ctor(Dictionary`2 data)
    --- End of inner exception stack trace ---
    at KiteConnect.Position..ctor(Dictionary`2 data)
    at KiteConnect.PositionResponse..ctor(Dictionary`2 data)
    at CallSite.Target(Closure , CallSite , Type , Object )
    at KiteConnect.Kite.GetPositions()
  • kcsomisetty
    kcsomisetty edited February 2020
    Hey @sujith this is blokcing my strategy from going live.
    can you quickly take a look ?

    this is the library version i am using.
    Tech.Zerodha.KiteConnect.3.0.3.1

    the base error message is
    "Cannot implicitly convert type 'double' to 'decimal'. An explicit conversion exists (are you missing a cast?)"
  • kcsomisetty
    kcsomisetty edited February 2020
    my guess is, conversion of m2m/unrealized fields in Position.ctor

    https://github.com/zerodhatech/dotnetkiteconnect/blob/a06a0cba2dd8700baaa07c52ba2d26da41565399/KiteConnect/Structures.cs#L280

    is failing and throwing exception.
    i might be wrong though.
  • sujith
    Yes, this is happening because of the exponential value. We have asked the .NET client team to handle this.
  • kcsomisetty
    @sujith
    i have tested a fix locally and created a pull request.
    https://github.com/zerodhatech/dotnetkiteconnect/pull/19

    your team review and merge it.
  • tonystark
    @kcsomisetty I replied to your PR. We can continue the discussion there.
Sign In or Register to comment.