Idirect-Tech / Breeze-Python-SDK

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

Websocket data fetchiong error #43

Open suyeshs opened 9 months ago

suyeshs commented 9 months ago

I am getting the below Error when connecting to the WebSocket using Python. Connection is successful.

env\Lib\site-packages\breeze_connect\breeze_connect.py", line 358, in subscribe_feeds

exchange_quotes_token, market_depth_token = self.get_stock_token_value(exchange_code=exchange_code, stock_code=stock_code, product_type=product_type, expiry_date=expiry_date, strike_price=strike_price, right=right, get_exchange_quotes=get_exchange_quotes, get_market_depth=get_market_depth)

env\Lib\site-packages\breeze_connect\breeze_connect.py", line 319, in get_stock_token_value

exchange_quotes_token_value = exchange_code_name + "1!" + token_value

                              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

TypeError: can only concatenate str (not "bool") to str

The request code

class TickDataConsumer(AsyncWebsocketConsumer): async def connect(self): self.breeze = BreezeConnect(api_key="") self.breeze.generate_session(api_secret="", session_token="23017248") self.breeze.ws_connect() # Use the ws_connect method of BreezeConnect

    # Assign the callback.
    self.breeze.on_ticks = self.on_ticks

    # Subscribe to the stock feed.
    self.breeze.subscribe_feeds(
        exchange_code="NFO", 
        stock_code="NIFTY", 
        product_type="options", 
        expiry_date="05-Oct-2023", 
        strike_price="", 
        right="Call", 
        get_exchange_quotes=True, 
        get_market_depth=False
    )

    await self.accept()

# Callback to receive ticks.
async def on_ticks(self, ticks):
    print("Ticks: {}".format(ticks))
yogiyadav08 commented 9 months ago

getting this error since past 10 days,

using the code below.

breeze = BreezeConnect(api_key=api_key) breeze.generate_session(api_secret=api_secret, session_token=session_token)

breeze.ws_connect() sleep(2)

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

Assign the callbacks.

breeze.on_ticks = on_ticks

breeze.subscribe_feeds( exchange_code="NFO", stock_code="CNXBAN", product_type="options", expiry_date="11-Oct-2023", strike_price="45000", right="call", get_exchange_quotes=True, get_market_depth=False, )

Traceback (most recent call last): File "/Users/yogiyadav08/PycharmProjects/Trading/test.py", line 31, in breeze.subscribe_feeds( File "/Users/yogiyadav08/.conda/envs/Trading/lib/python3.10/site-packages/breeze_connect/breeze_connect.py", line 365, in subscribe_feeds self.sio_rate_refresh_handler.watch(exchange_quotes_token) File "/Users/yogiyadav08/.conda/envs/Trading/lib/python3.10/site-packages/breeze_connect/breeze_connect.py", line 103, in watch self.sio.emit('join', data) File "/Users/yogiyadav08/.conda/envs/Trading/lib/python3.10/site-packages/socketio/client.py", line 393, in emit raise exceptions.BadNamespaceError( socketio.exceptions.BadNamespaceError: / is not a connected namespace.

ammukumaran commented 6 months ago

today getting the above errors....anyone with fix for this

axresh commented 6 months ago

Yes, faced this problem today, now its working... What was the issue?

sanchaykasturey commented 6 months ago

I have also faced this error, this is stupid but this is supposed to accept specific date time formats for everything like while subscribing to option feed, while fetching option chain, etc.

So, for your reference below is the kind of format which works:

expiryOpt="2023-12-22T06:00:00.000Z" this is DATE for the expiry of the Option
subscribeOpt= "22-Dec-2023" #this is DATE for subscribing the OHLCV of the Option
expiryFut="2023-12-22T06:00:00.000Z" #this is DATE for the expiry of the FUTURE

Also if you don't require tick by tick data, you may use: interval: "1minute" for 1 minute data

Gaganiith commented 6 months ago

Anyone got the Solution. This subscribe_feeds work with NSE as exchnage_code but fails for NFO stating concatenation error

image

subscribe stocks feeds

breeze.subscribe_feeds(exchange_code="NFO", stock_code="ZEEENT", product_type="options", expiry_date="28-Dec-2023", strike_price="350", right="Call", interval="", get_exchange_quotes=True, get_market_depth=False)