Websocket with curl command

Kamalv
Hi @sujith @rakeshr @kiteconnect ,

I am trying to save LTP information on tick, with Websockets. My intention is to perform only with curl commands, same as order placing (my Implementation in AWS, python package installation posing challenges). Checked in documentation but did not find any, can you suggest me?

Thanks,
Kamal
  • rakeshr
    You can check out the documentation here. You can refer python client websocket implementation as well.
  • Kamalv
    Thanks for the response @rakeshr, i tried both options reaching same error as earlier, cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)"(https://kite.trade/forum/discussion/10788/import-kiteconnect-in-aws-lambda#latest).

    Any alternate for updating LTP in DB.
  • rakeshr
    Any alternate for updating LTP in DB
    You will have to make LTP quote call at required interval for the same.
  • Kamalv
    Yeah, this will be my final approach. can i call LTP quote call every second? (just want to be very clear on limitations).
  • SRIJAN
    Yes,quote api has rate limit of 1r/sec.
  • Kamalv
    Thank you
  • Kamalv
    Kamalv edited January 2022
    @rakeshr @sujith @SRIJAN as per the documentation, variable "net_change" from trade/quote should hold "The absolute change from yesterday's close to last traded price". However i'm getting always 0. Can you check from your end?.

    I need change % of the stock.
  • SRIJAN
    SRIJAN edited January 2022
    @Kamalv I tried rn. It's giving me the net_change correctly. To calculate %change,just do (net_change/yesterday's close)*100. For which instrument are you using quote call??
  • Kamalv
    Kamalv edited January 2022
    this is what i'm getting for TATAMOTORS
    <pre class="CodeBlock"><code>{'NSE:TATAMOTORS': {'instrument_token': 884737,
    'timestamp': '2022-01-05 12:15:47',
    'last_trade_time': '2022-01-05 12:15:47',
    'last_price': 487.4,
    'last_quantity': 5,
    'buy_quantity': 1240730,
    'sell_quantity': 1692386,
    'volume': 6950460,
    'average_price': 486.28,
    'oi': 0,
    'oi_day_high': 0,
    'oi_day_low': 0,
    <b class="Bold"><b class="Bold"> 'net_change': 0,</b></b>
    'lower_circuit_limit': 440.65,
    'upper_circuit_limit': 538.55,
    'ohlc': {'open': 486.95, 'high': 488.65, 'low': 483.55, 'close': 489.6},
    .
    .
    .
  • SRIJAN
    Oh,yes,idk why it's showing 0 for TATAMOTORS in quote. In websocket,the change is correct.
  • SRIJAN
    SRIJAN edited January 2022
    https://kite.trade/forum/discussion/comment/33099/#Comment_33099

    I suggest you to write code for net_change. To avoid these situations.
  • SRIJAN
    SRIJAN edited January 2022
    Read this :
    https://kite.trade/forum/discussion/1576/change-percentage

    Only for indices, KiteConnect(quote) is sending net_change. And it's true,i just checked,net_change for equities and derivatives are 0 too. I tried with nifty and bank nifty when i told you that it is working. So,i thought it's working. But, websocket is showing changes perfectly.
  • Kamalv
    Is there any workaround?
    Is there any way i can get yesterday's closing price of a stock? I can save day's closing price and refer but looking for optimized way (instead of saving all stocks closing price everyday and reading back).
  • SRIJAN
    @kamalv Read the documentation properly. Sujith sir told in the above thread too. The close price in the quote response is the close price of the previous day. So, you don't need to save anything. To calculate net %change just do ((ltp/close)-1)*100.
  • Kamalv
    Used above formula for TATAMOTORS but net % is not matching, ((489.75/489.60)-1)*100 = 0.0306.


    am i missing anything?

  • SRIJAN
    Check now. The change is 0.03%. Kite is under maintenance at night time,the prices you see are last trading day's price for few hours. If you look clearly,the ohl are also as of the last trading day i.e. Tuesday's. On Tuesday,it was 1.61% down.(You can try with the ohlc in screenshot). Midnight is not a good time to backtest today's data. ;)
  • rakeshr
    BOD(Beginning of the day) process happens every trading day around 6 AM, this is when the close field is updated. You should check post-BOD period, to get the previous day's close value.
Sign In or Register to comment.