Closed prattyush closed 1 year ago
Dear Prattyush,
You can refer the below piece of code to subscribe NIFTY50.
import time from breeze_connect import BreezeConnect from datetime import datetime, timedelta key_api = "" key_secret = "" key_session = "14563848" breeze = BreezeConnect(api_key=key_api) breeze.generate_session(api_secret=key_secret, session_token=key_session)
breeze.ws_connect()
data = []
def on_ticks(ticks): data.append(ticks) print("Ticks: {}".format(ticks))
breeze.on_ticks = on_ticks breeze.subscribe_feeds(get_order_notification=True)
breeze.unsubscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="06-Jul-2023", strike_price="17000", right="Call", interval="1second")
You can use the below link to get the all the instrument prices with the expiry.
https://traderweb.icicidirect.com/Content/File/txtFile/ScripFile/StockScriptNew.csv
From: prattyush @.> Sent: Tuesday, July 4, 2023 11:44 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: Subscribed @.***> Subject: [Idirect-Tech/Breeze-Python-SDK] Nifty Options Feed Doesn't work (Issue #32)
External Email Warning: Use 'Report suspicious Email' button to report Phishing mails. Do not click on any attachment or links/URL in this email unless sender is reliable.
Hello,
This issue is regarding not able to subscribe to Nifty Options Feed. I am able to subscribe to Nifty Feed but getting an error mentioned below for Nifty Options. I am using the latest python SDK.
The error seems like it is part of the breeze code. Tried everything, can't bypass this error for Nifty Options Feed. The same issue also comes with the sample code of subscribe feeds for options.
The code:-
self.icicid_client.ws_connect() self.icicid_client.on_ticks = self.on_ticks self.icicid_client.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date=str(config.expiry_date), strike_price=str(config.strike_price), right=str(config.type), get_exchange_quotes=str(True), get_market_depth=str(False), interval=interval)
Getting the error:- AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\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) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ASUS EZ312WS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\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
And then program hangs.
Similar Error Also Happens with code
self.icicid_client.subscribe_feeds(exchange_code="NFO", stock_code="ZEEENT", product_type="options",
expiry_date="27-July-2023", strike_price=170.0, right="Call", interval="1second")
Error:-
\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\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)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS EZ312WS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\breeze_connect\breeze_connect.py", line 302, in get_stock_token_value
contract_detail_value = contract_detail_value + "-" + strike_price
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
TypeError: can only concatenate str (not "float") to str
—
Reply to this email directly, view it on GitHub<https://github.com/Idirect-Tech/Breeze-Python-SDK/issues/32>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A3TQZ4Z5HP7P4JEEKRGW5TDXORMORANCNFSM6AAAAAAZ6AZTZY>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Print this mail only if absolutely necessary. Save Paper. Save Trees." "The information contained in this e-mail and any attachments to this message are intended for the exclusive use of the intended recipient and may contain proprietary, confidential or legally privileged information. If you are not the intended recipient, please note that you are not authorised to disseminate, distribute or copy this e-mail or any parts of it or act upon/rely on the contents of this e-mail in any manner. Please notify the sender immediately by e-mail and destroy all copies of this e-mail and any attachments. Please also note that ICICI Bank or its subsidiaries and associated companies, (collectively "ICICI Group"), are unable to exercise control or ensure the integrity of/over the contents of the information contained in e-mail transmissions and that any views expressed in this e-mail are not endorsed by/binding on the ICICI Group unless the sender does so expressly with due authority of ICICI Group. Before opening any attachments please check them for viruses and defects and please note that ICICI Group accepts no liability or responsibility for any damage caused by any virus that may be transmitted by this email. Any unauthorized use of this email or any attachment(s) may be treated as infringement of right(s) including right of privacy under the applicable laws of India including Information and Technology Act, 2000. Thank you for your cooperation. Regulatory Disclosures are available on https://www.icicisecurities.com (for institutional business) and www.icicidirect.com (for retail business).
I want to listen to options Nifty Feed. Will this work. B.T.W I am using python SDK.
breeze.subscribe_feeds(get_order_notification=True)
It got resolved. Thanks, the expiry date format was wrong. It needs %b as Month format.
Thanks.
Hello,
This issue is regarding not able to subscribe to Nifty Options Feed. I am able to subscribe to Nifty Feed but getting an error mentioned below for Nifty Options. I am using the latest python SDK.
The error seems like it is part of the breeze code. Tried everything, can't bypass this error for Nifty Options Feed. The same issue also comes with the sample code of subscribe feeds for options.
The code:-
config.expirty_date ="06-July-2023" config.type="Call" config.strike_price=19300
self.icicid_client.ws_connect() self.icicid_client.on_ticks = self.on_ticks self.icicid_client.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date=config.expiry_date, strike_price=config.strike_price, right=config.type, get_exchange_quotes=True, get_market_depth=False, interval=interval)
Getting the error:- AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\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) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ASUS EZ312WS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\breeze_connect\breeze_connect.py", line 319, in get_stock_token_value exchange_quotes_token_value = exchange_code_name + "1!" + token_value