Historical Data

chavda
@sujith can you please help me with fetching historical data of expired option
  • sujith
    Kite Connect only provides day candle data for expired futures instruments. We don't provide data for expired options instruments.
  • chavda
    import logging
    from kiteconnect import KiteTicker

    logging.basicConfig(level=logging.DEBUG)

    # Initialise
    kws = KiteTicker(api_key, access_token)

    def on_ticks(ws, ticks):
    # Callback to receive ticks.
    logging.debug("Ticks: {}".format(ticks))

    def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    ws.subscribe([19471106])

    def on_close(ws, code, reason):
    # On connection close stop the main loop
    # Reconnection will not happen after executing `ws.stop()`
    ws.stop()

    # Assign the callbacks.
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect
    kws.on_close = on_close

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()



    Geting this error please help to solve



    ---------------------------------------------------------------------------
    ReactorNotRestartable Traceback (most recent call last)
    in ()
    23 # Infinite loop on the main thread. Nothing after this will run.
    24 # You have to use the pre-defined callbacks to manage subscriptions.
    ---> 25 kws.connect()

    3 frames
    /usr/local/lib/python3.10/dist-packages/twisted/internet/base.py in startRunning(self)
    841 raise error.ReactorAlreadyRunning()
    842 if self._startedBefore:
    --> 843 raise error.ReactorNotRestartable()
    844 self._started = True
    845 self._stopped = False

    ReactorNotRestartable:
  • rakeshr
    ReactorNotRestartable
    Go through the Python websocket FAQs here.
Sign In or Register to comment.