OnTick incorrect data .net client api

Hi All,
Kite Connect API version -> V3
Kite Connect client -> .net client
Code Base -> https://github.com/zerodhatech/dotnetkiteconnect/tree/kite3
Can some please help me to fix bellow issue.
Activity Description -> With ref. to git hub C# code. i am subscribing to Nifty50 stock. But I am not getting updated. I am using onTick Event to store/process data in my C# application.

Problem-> When OnTick data getting called and i do save that info into DB it is not showing correct value according to time.

C# code

private static void initTicker()
ticker = new Ticker(MyAPIKey, MyAccessToken);

ticker.OnTick += OnTick;
ticker.OnReconnect += OnReconnect;
ticker.OnNoReconnect += OnNoReconnect;
ticker.OnError += OnError;
ticker.OnClose += OnClose;
ticker.OnConnect += OnConnect;
ticker.OnOrderUpdate += OnOrderUpdate;

ticker.EnableReconnect(Interval: 5, Retries: 50);

// Subscribing to NIFTY50 and setting mode to LTP
ticker.Subscribe(Tokens: ins_tokent);
ticker.SetMode(Tokens: ins_tokent, Mode: Constants.MODE_FULL);

ins_tokent -> is array of uint32 nitfy50 instrument tokent

private static void OnTick(Tick TickData)

Console.WriteLine("Tick " + Utils.JsonSerialize(TickData));
TickOperation.SaveTickEntity(TickData); // direct saving to DB

OutPut As below
If you observe value for Volume ,LastTradeTime and TimeStamp is varring but OHLC is not getting change by time, but i notice this value 1st tick of the day which is at 9.15 as compared with char.

Time 09:24:38.000
InstrumentToken Open High Low Close Volume LastTradeTime Timestamp
60417 1725.70 1747.60 1725.70 1725.15 165776 2019-10-09 09:24:37.000 2019-10-09 09:24:38.000
60417 1725.70 1747.60 1725.70 1725.15 165948 2019-10-09 09:24:39.000 2019-10-09 09:24:40.000

Time 11:11:45.000
InstrumentToken Open High Low Close Volume LastTradeTime Timestamp
60417 1725.70 1749.90 1725.70 1725.15 680434 2019-10-09 11:11:43.000 2019-10-09 11:11:45.000

Please find below image for sql data comparison.

  • sujith
    Kite Ticker will give you day's OHLC and not any specific interval's OHLC. You need to generate your own candles if you want intra-day OHLC. You can refer to this thread to know more.
  • AlgoTrader007
    So on every tick i need chk last one min on tick records and from them i need to identify OHLC value.
    first tick at 9:15:01 is my open value,
    Highest from record between 9:15:01 to 9:15:59 is my High
    Lowest from record between 9:15:01 to 9:15:59 is my is low

    Close is record at 9:15:59 is my close value

    Using this tick i can create a ohlc candle for one minute of the day .

    And all above values must be lpt for that particular tick.

    Correct me if any thing wrong or is missed.

    One point just need to confirm is if i Request ltp/quote mode timestamp and lasttradedtime is null. Hence every time i need to send my mode is as full.
  • sujith
    Yes, you need to track last traded price and also you can start form 09:15:00 to 09:15:59 If you start from 09:15:01 then you will end up with 59 seconds right.

    You need to set the mode to full once and then Kite Ticker will keep sending you full mode ticks.
  • AlgoTrader007
    AlgoTrader007 edited October 2019

    I am able to create one min candle as we discussed above, but having problem with volume
    I tried to sum [Volume] and also tried with [LastQuantity] but it was not matching with zerodha chart.
    OHLC is matched with chart.
    Can you suggest me how should i proceed with this volume problem?
    Please see attached image
  • sujith
    The volume data is cumulative data. You don't have to sum it up. You should be finding the difference between the first and last tick.
    You can refer to this thread to get a clear picture of the whole process.
Sign In or Register to comment.