Open sudhakarsi opened 6 months ago
following program exits after printing {'message': 'Stock CNXBAN subscribed successfully'}
breeze = BreezeConnect(api_key=api_key)
import urllib
print("https://api.icicidirect.com/apiuser/login?api_key="+urllib.parse.quote_plus(api_key))
breeze.generate_session(api_secret=api_secret,session_token=api_session)
breeze.ws_connect()
def on_ticks(ticks): print("Ticks: {}".format(ticks)) print(ticks)
breeze.on_ticks = on_ticks
expiry = "03-Apr-2024"
ret = breeze.subscribe_feeds(exchange_code="NFO", stock_code="CNXBAN", product_type="options", expiry_date="03-Apr-2024", strike_price="47200", right="Call", get_exchange_quotes=True, get_market_depth=False) print(ret)
the on_ticks call back is not woirking since 2 weeks. And, it's sad, ICICDirect has no solution for that. Even today, it is not responding smoothly. Erratic response
following program exits after printing {'message': 'Stock CNXBAN subscribed successfully'}
Initialize SDK
breeze = BreezeConnect(api_key=api_key)
Obtain your session key from https://api.icicidirect.com/apiuser/login?api_key=YOUR_API_KEY
Incase your api-key has special characters(like +,=,!) then encode the api key before using in the url as shown below.
import urllib
print("https://api.icicidirect.com/apiuser/login?api_key="+urllib.parse.quote_plus(api_key))
Generate Session
breeze.generate_session(api_secret=api_secret,session_token=api_session)
Connect to websocket(it will connect to tick-by-tick data server)
breeze.ws_connect()
Callback to receive ticks.
def on_ticks(ticks): print("Ticks: {}".format(ticks)) print(ticks)
Assign the callbacks.
breeze.on_ticks = on_ticks
expiry = "03-Apr-2024"
ret = breeze.subscribe_feeds(exchange_code="NFO", stock_code="CNXBAN", product_type="options", expiry_date="03-Apr-2024", strike_price="47200", right="Call", get_exchange_quotes=True, get_market_depth=False) print(ret)