Idirect-Tech / Breeze-Python-SDK

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

Cancel Order API Failing for NSE Exchange #94

Closed marketcalls closed 1 month ago

marketcalls commented 2 months ago

Cancel Order API Failing for NSE Exchange

Description

We are encountering an issue with the cancel_order API for orders on the NSE exchange. The API call returns a status code of 500 with the error message 'No Data Found'. This issue is specific to the NSE exchange as the same API call works successfully for the NFO exchange.

Steps to Reproduce

  1. Attempt to cancel an NSE exchange order:

    breeze.cancel_order(exchange_code="NSE", order_id="20240506T200033213")

    Response:

    {"Success": null, "Status": 500, "Error": "No Data Found"}
  2. For comparison, canceling an NFO exchange order:

    breeze.cancel_order(exchange_code="NFO", order_id="202405064500013257")

    Response:

    {"Success": {"order_id": "202405064500013257", "message": "Your Order Canceled Successfully"}, "Status": 200, "Error": null}

Expected Behavior

The cancel_order API should successfully cancel the order and return a success response as seen with the NFO exchange:

{"Success": {"order_id": "order_id_here", "message": "Your Order Canceled Successfully"}, "Status": 200, "Error": null}

Actual Behavior

The API returns a status code of 500 with the error message 'No Data Found' when attempting to cancel an order on the NSE exchange.

Additional Information

Could you please investigate and resolve this issue?

Thank you!

Idirect-Tech commented 2 months ago

Dear Client,

Before cancelling the order requested to get the order details by using get order details endpoint.

Please find the below sample code for that.

breeze.get_order_detail(exchange_code="NSE", order_id="20220819N100000001")

https://pypi.org/project/breeze-connect/#order_detail [https://pypi.org/static/images/twitter.abaf4b19.webp]https://pypi.org/project/breeze-connect/#order_detail breeze-connecthttps://pypi.org/project/breeze-connect/#order_detail ICICI Direct Breeze pypi.org

[E29CF836]

Thanks & Regards,

Amrit Mohanty,

API & Algo Products,

Derivatives, EPG

ICICIdirect


From: Marketcalls @.> Sent: Monday, May 6, 2024 2:15 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: Subscribed @.***> Subject: [Idirect-Tech/Breeze-Python-SDK] Cancel Order API Failing for NSE Exchange (Issue #94)

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!

Cancel Order API Failing for NSE Exchange Description

We are encountering an issue with the cancel_order API for orders on the NSE exchange. The API call returns a status code of 500 with the error message 'No Data Found'. This issue is specific to the NSE exchange as the same API call works successfully for the NFO exchange.

Steps to Reproduce

  1. Attempt to cancel an NSE exchange order:

breeze.cancel_order(exchange_code="NSE", order_id="20240506T200033213")

Response:

{"Success": null, "Status": 500, "Error": "No Data Found"}

  1. For comparison, canceling an NFO exchange order:

breeze.cancel_order(exchange_code="NFO", order_id="202405064500013257")

Response:

{"Success": {"order_id": "202405064500013257", "message": "Your Order Canceled Successfully"}, "Status": 200, "Error": null}

Expected Behavior

The cancel_order API should successfully cancel the order and return a success response as seen with the NFO exchange:

{"Success": {"order_id": "order_id_here", "message": "Your Order Canceled Successfully"}, "Status": 200, "Error": null}

Actual Behavior

The API returns a status code of 500 with the error message 'No Data Found' when attempting to cancel an order on the NSE exchange.

Additional Information

{"Success": [{"order_id": "20240506T200033213", "exchange_order_id": null, "exchange_code": "NSE", "stock_code": "POWGRI", "product_type": "Margin", "action": "Buy", "order_type": "Limit", "stoploss": "0.00", "quantity": "1", "price": "302.00", "validity": "Day", "disclosed_quantity": "0", "expiry_date": null, "right": null, "strike_price": 0.0, "average_price": "0", "cancelled_quantity": "0", "pending_quantity": "1", "status": "Ordered", "user_remark": "", "order_datetime": "06-May-2024 13:42", "parent_order_id": null, "modification_number": null, "exchange_acknowledgement_date": null, "SLTP_price": null, "exchange_acknowledge_number": null, "initial_limit": null, "intial_sltp": null, "LTP": null, "limit_offset": null, "mbc_flag": null, "cutoff_price": null, "validity_date": ""}], "Status": 200, "Error": null}

Could you please investigate and resolve this issue?

Thank you!

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/94, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ4ZY6KR3V5QGNAWPGI3ZA47KPAVCNFSM6AAAAABHIUCDNGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4DAMZWGA3DGNY. 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).

marketcalls commented 2 months ago

Hi,

Here is the order detail i sent during live market hours before cancelling the order id 20240506T200033213 but it happens for NFO based orders and not for NSE orders

breeze.get_order_detail(exchange_code="NSE",
                        order_id="20240506T200033213")

Response :

{'Success': [{'order_id': '20240506T200033213',
   'exchange_order_id': None,
   'exchange_code': 'NSE',
   'stock_code': 'POWGRI',
   'product_type': 'Margin',
   'action': 'Buy',
   'order_type': 'Limit',
   'stoploss': '0.00',
   'quantity': '1',
   'price': '302.00',
   'validity': 'Day',
   'disclosed_quantity': '0',
   'expiry_date': None,
   'right': None,
   'strike_price': 0.0,
   'average_price': '0',
   'cancelled_quantity': '0',
   'pending_quantity': '1',
   'status': 'Ordered',
   'user_remark': '',
   'order_datetime': '06-May-2024 13:42',
   'parent_order_id': None,
   'modification_number': None,
   'exchange_acknowledgement_date': None,
   'SLTP_price': None,
   'exchange_acknowledge_number': None,
   'initial_limit': None,
   'intial_sltp': None,
   'LTP': None,
   'limit_offset': None,
   'mbc_flag': None,
   'cutoff_price': None,
   'validity_date': ''}],
 'Status': 200,
 'Error': None}

But even then faced the same issue

Idirect-Tech commented 1 month ago

Dear Client,

As can be seen in the attached image, we are able to successfully cancel the order. Please share your match ID to check the issue.

[E29CF836]

Thanks & Regards,

Hiten Solanki,

Team Breeze API,

ICICI Securities


From: Marketcalls @.> Sent: Monday, May 6, 2024 8:09 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] Cancel Order API Failing for NSE Exchange (Issue #94)

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!

Hi,

Here is the order detail

breeze.get_order_detail(exchange_code="NSE", order_id="20240506T200033213")

Response :

{'Success': [{'order_id': '20240506T200033213', 'exchange_order_id': None, 'exchange_code': 'NSE', 'stock_code': 'POWGRI', 'product_type': 'Margin', 'action': 'Buy', 'order_type': 'Limit', 'stoploss': '0.00', 'quantity': '1', 'price': '302.00', 'validity': 'Day', 'disclosed_quantity': '0', 'expiry_date': None, 'right': None, 'strike_price': 0.0, 'average_price': '0', 'cancelled_quantity': '0', 'pending_quantity': '1', 'status': 'Ordered', 'user_remark': '', 'order_datetime': '06-May-2024 13:42', 'parent_order_id': None, 'modification_number': None, 'exchange_acknowledgement_date': None, 'SLTP_price': None, 'exchange_acknowledge_number': None, 'initial_limit': None, 'intial_sltp': None, 'LTP': None, 'limit_offset': None, 'mbc_flag': None, 'cutoff_price': None, 'validity_date': ''}], 'Status': 200, 'Error': None}

But even then faced the same issue

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/94#issuecomment-2096196475, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ47EZC2ZEQL7XKQXZE3ZA6I35AVCNFSM6AAAAABHIUCDNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGE4TMNBXGU. 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).

marketcalls commented 1 month ago

Thanks issue got resolved. image

Idirect-Tech commented 1 month ago

Dear Rajendran,

Options Through option product you can squared off position intraday also or till expiry you can squared off anytime.

breeze.place_order(stock_code="NIFTY", exchange_code="NFO", product="options", action="buy", order_type="market", stoploss="", quantity="50", price="", validity="day", validity_date="2022-08-30T06:00:00.000Z", disclosed_quantity="0", expiry_date="2022-09-29T06:00:00.000Z", right="call", strike_price="22000")

Optionplus:

Option Plus order Placement

breeze.limit_calculator(strike_price = "22000", product_type = "optionplus", expiry_date = "07-MAR-2024", underlying = "NIFTY", exchange_code = "NFO", order_flow = "sell", stop_loss_trigger = "300.00", option_type = "Call", source_flag = "P", limit_rate = "", order_reference = "", available_quantity = "", market_type = "limit", fresh_order_limit = "335")

Option plus stoploss limit price will be received as "285" as can be seen in attached image.

breeze.place_order(stock_code="NIFTY", exchange_code="NFO", product="optionplus", action="buy", order_type="limit", stoploss="300", quantity="50", price="285", validity="day", validity_date="2024-03-07T06:00:00.000Z", disclosed_quantity="0", expiry_date="2024-03-07T06:00:00.000Z", right="call", strike_price="22000", order_type_fresh = "Limit", order_rate_fresh = "335", user_remark="Test")

[E29CF836]

Thanks & Regards,

Hiten Solanki,

Team Breeze API,

ICICI Securities


From: Marketcalls @.> Sent: Thursday, May 9, 2024 5:31 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: BREEZEAPI @.>; Comment @.> Subject: Re: [Idirect-Tech/Breeze-Python-SDK] Cancel Order API Failing for NSE Exchange (Issue #94)

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!

Thanks issue got resolved. image.png (view on web)https://github.com/Idirect-Tech/Breeze-Python-SDK/assets/8728989/1bcd8e01-3835-455f-948d-f91ceea37417

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/94#issuecomment-2102528764, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ45I4ONFNNR7BAJOYB3ZBNQRLAVCNFSM6AAAAABHIUCDNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBSGUZDQNZWGQ. 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).