Not getting any data from Market feed

Hello,
I’ve been trying to connect to market feed for quite a time now. but doesn’t seems to get any message can’t understand why that’s happening maybe I’m wrong with the code i wrote attaching.
I guess it is getting connected but not even getting the first message of the last close which the docs we get atleast when we subscribe.
I’m trying to subscribe to nifty index future and options instruments.

try:
        data = marketfeed.DhanFeed(CLIENT_ID, ACCESS_TOKEN, instrument, "v2")
        # while True:
        data.run_forever()
        try:
            response = data.get_data()
            logging.info(f"Received Market Data: {response}")
            update_variables(response)
        except Exception as e:
            logging.error(f"Error fetching market data: {e}")

    except KeyboardInterrupt:
        logging.info("Keyboard Interrupt detected. Closing WebSocket connection graceTickery...")

        # Properly close the async connection using an event loop
        asyncio.run(data.disconnect())
        logging.info("Market Feed Connection Closed. Exiting safely.")
    except Exception as e:
        logging.error(f"Market Feed Error: {e}")
    finally:
        save_premium_data()
        data.disconnect()
        logging.info("Market Feed Connection Closed")
1 Like