Idirect-Tech / Breeze-Python-SDK

The official Python client library for the ICICI Securities trading APIs
MIT License
63 stars 30 forks source link

Not getting tick data with Websocket on_ticks #110

Open nayeshagandotra opened 4 months ago

nayeshagandotra commented 4 months ago

Hi, I am trying to get live tick data with on_ticks. All the libraries are installed correctly and I'm even using a while loop to prevent the main function from exiting. I've tried emailing breeze api help but my email keeps getting blocked. Here's the code for reference:

Imports

from breeze_connect import BreezeConnect import pandas as pd import matplotlib.pyplot as plt import time import urllib

if name == 'main':

initialize session

# Initialize SDK
breeze = BreezeConnect(api_key="api_key")

# Generate Session
breeze.generate_session(api_secret="secret_key",
                        session_token="session")

# Connect to websocket(it will connect to tick-by-tick data server)
breeze.ws_connect()

# on_ticks
def on_ticks(ticks):
    print("Ticks: {}".format(ticks))

# Assign the callbacks.
breeze.on_ticks = on_ticks

# # subscribe to Real Time Streaming OHLCV Data of stocks
breeze.subscribe_feeds(exchange_code="NSE", 
                       stock_code="NIFTY", 
                       product_type="cash", 
                       expiry_date = "",
                       strike_price = "",
                       right = "",
                       interval="1second", 
                       get_exchange_quotes=True,
                       get_order_notification=True)

while True:
    print("iter")
    time.sleep(10)

And this is the output I'm getting:

image

Please help.