Idirect-Tech / Breeze-Python-SDK

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

No Quotes are received #55

Open shisingh opened 6 months ago

shisingh commented 6 months ago

from breeze_connect import BreezeConnect

Initialize SDK

breeze = BreezeConnect(api_key="my-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("your_api_key"))

Generate Session

breeze.generate_session(api_secret="my-secret", session_token="my-session")

Generate ISO8601 Date/DateTime String

import datetime iso_date_string = datetime.datetime.strptime("28/02/2021","%d/%m/%Y").isoformat()[:10] + 'T05:30:00.000Z' iso_date_time_string = datetime.datetime.strptime("28/02/2021 23:59:59","%d/%m/%Y %H:%M:%S").isoformat()[:19] + '.000Z'

Callback to receive ticks.

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

Assign the callbacks.

breeze.on_ticks = on_ticks

subscribe stocks feeds

breeze.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21700", right="Call", get_exchange_quotes=True, get_market_depth=False)

input("press enter")

unsubscribe stocks feeds

breeze.unsubscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="311-Jan-2024", strike_price="21700", right="Call", get_exchange_quotes=True, get_market_depth=False)

ws_disconnect (it will disconnect from all actively connected servers)

breeze.ws_disconnect() print("Run completed")

Idirect-Tech commented 6 months ago

Dear Client,

Requested to share the code without credential at breezeapi@icicisecurities.com.

shisingh commented 6 months ago
from breeze_connect import BreezeConnect

# Initialize SDK
breeze = BreezeConnect(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("your_api_key"))

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

# Generate ISO8601 Date/DateTime String
import datetime
iso_date_string = datetime.datetime.strptime("28/02/2021","%d/%m/%Y").isoformat()[:10] + 'T05:30:00.000Z'
iso_date_time_string = datetime.datetime.strptime("28/02/2021 23:59:59","%d/%m/%Y %H:%M:%S").isoformat()[:19] + '.000Z'

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

# Assign the callbacks.
breeze.on_ticks = on_ticks

# subscribe stocks feeds
breeze.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21700", right="Call", get_exchange_quotes=True, get_market_depth=False)

input("press enter to exit")

# unsubscribe stocks feeds
breeze.unsubscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21700", right="Call", get_exchange_quotes=True, get_market_depth=False)

# ws_disconnect (it will disconnect from all actively connected servers)
breeze.ws_disconnect()
print("Run completed")

Above is the code and sending through email as well. Kindly look into the issue or tell us that it is still under development and not working fully so that we can look alternatives.

shisingh commented 6 months ago

Is there any update on it?

Idirect-Tech commented 6 months ago

Dear Client,

Please don't use breeze.ws_disconnect() until unless you want to disconnect from all actively connected servers.

Idirect-Tech commented 6 months ago

Dear Client,

Please run the code by commenting out breeze.ws_disconnect() statement.

[E29CF836]

Thanks & Regards,

Hiten Solanki,

Team Breeze API,

ICICI Securities


From: shisingh @.> Sent: Tuesday, January 9, 2024 8:56 AM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] No Quotes are received (Issue #55)

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.

Is there any update on it?

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/55#issuecomment-1882328793, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ44NITSD4TVJIRGPSF3YNS2FDAVCNFSM6AAAAABBOCK2QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBSGMZDQNZZGM. You are receiving this because you commented.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).

shisingh commented 6 months ago

Modified as suggested below, still no data is received. Only below output was received:

press enter to exit. Current time is : 2024-01-10 11:14:34.163435 Run completed. Current Time is : 2024-01-10 11:17:03.612432

from breeze_connect import BreezeConnect

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

import urllib

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

import datetime

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

# Assign the callbacks.
breeze.on_ticks = on_ticks

# subscribe stocks feeds
breeze.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21500", right="Call", get_exchange_quotes=True, get_market_depth=False)

now = datetime.datetime.now()
input(f"press enter to exit. Current time is : {now}")

# ws_disconnect (it will disconnect from all actively connected servers)
breeze.ws_disconnect()
now = datetime.datetime.now()
print(f"Run completed. Current Time is : {now}")
Idirect-Tech commented 6 months ago

Dear Client,

Please use the below piece of code.

Here breeze.ws_connect() was missing.

from breeze_connect import BreezeConnect import datetime import urllib

Initialize SDK

breeze = BreezeConnect(api_key="")

Generate Session

breeze.generate_session(api_secret="", session_token="")

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))

Assign the callbacks.

breeze.on_ticks = on_ticks

subscribe stocks feeds

breeze.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21500", right="Call", get_exchange_quotes=True, get_market_depth=False)

now = datetime.datetime.now() input(f"press enter to exit. Current time is : {now}")

ws_disconnect (it will disconnect from all actively connected servers)

breeze.ws_disconnect() now = datetime.datetime.now() print(f"Run completed. Current Time is : {now}")

[E29CF836]

Thanks & Regards,

Amrit Mohanty,

API & Algo Products,

Derivatives, EPG

ICICIdirect


From: shisingh @.> Sent: Wednesday, January 10, 2024 11:18 AM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] No Quotes are received (Issue #55)

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.

Modified as suggested below, still no data is received. Only below output was received:

press enter to exit. Current time is : 2024-01-10 11:14:34.163435 Run completed. Current Time is : 2024-01-10 11:17:03.612432

from breeze_connect import BreezeConnect

Initialize SDK

breeze = BreezeConnect(api_key="")

import urllib

Generate Session

breeze.generate_session(api_secret="", session_token="")

import datetime

Callback to receive ticks.

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

Assign the callbacks.

breeze.on_ticks = on_ticks

subscribe stocks feeds

breeze.subscribe_feeds(exchange_code="NFO", stock_code="NIFTY", product_type="options", expiry_date="11-Jan-2024", strike_price="21500", right="Call", get_exchange_quotes=True, get_market_depth=False)

now = datetime.datetime.now() input(f"press enter to exit. Current time is : {now}")

ws_disconnect (it will disconnect from all actively connected servers)

breeze.ws_disconnect() now = datetime.datetime.now() print(f"Run completed. Current Time is : {now}")

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/55#issuecomment-1884231691, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ4ZZM7PJSDACQNDIEQ3YNYTUTAVCNFSM6AAAAABBOCK2QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBUGIZTCNRZGE. You are receiving this because you commented.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).

shisingh commented 6 months ago

Thanks. It is working now!

sudhakarsi commented 4 months ago

how to keep polling for new data in case order placed/getting option chain

Idirect-Tech commented 4 months ago

Dear Client,

Requested to clarify the query.

Please elaborate it bit more so that we will get a clarity.

[E29CF836]

Thanks & Regards,

Amrit Mohanty,

API & Algo Products,

Derivatives, EPG

ICICIdirect


From: sudhakarsi @.> Sent: Friday, March 1, 2024 12:40 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] No Quotes are received (Issue #55)

CAUTION: This email originated from outside the organization! Do not click links, open attachments or reply, unless you recognize the sender's email address! Use 'Report suspicious Email' button in the toolbar to report Phishing mails. Beware!

how to keep polling for new data in case order placed/getting option chain

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/55#issuecomment-1972629074, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ42GPCD7DYB27UFJWLDYWASXBAVCNFSM6AAAAABBOCK2QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSGYZDSMBXGQ. You are receiving this because you commented.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).

sudhakarsi commented 4 months ago

I have called option chain data and want to update option chain as per tick. So how can one keep updating option chain? Do one has to subscribe to full option chain?

Idirect-Tech commented 4 months ago

Dear Client,

Option chain data can not be updated or manipulated manually.

It is a auto updated feature and that would be done through backend.

You can able to subscribe the full option chain by looping through the stock token .

[E29CF836]

Thanks & Regards,

Amrit Mohanty,

API & Algo Products,

Derivatives, EPG

ICICIdirect


From: sudhakarsi @.> Sent: Friday, March 1, 2024 3:08 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] No Quotes are received (Issue #55)

CAUTION: This email originated from outside the organization! Do not click links, open attachments or reply, unless you recognize the sender's email address! Use 'Report suspicious Email' button in the toolbar to report Phishing mails. Beware!

I have called option chain data and want to update option chain as per tick. So how can one keep updating option chain? Do one has to subscribe to full option chain?

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/55#issuecomment-1972843098, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ4ZQ6BK6CQLK64GB7BLYWBEADAVCNFSM6AAAAABBOCK2QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSHA2DGMBZHA. You are receiving this because you commented.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).