Idirect-Tech / Breeze-Python-SDK

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

Want to put stoploss order in options order #141

Closed asif633 closed 1 month ago

asif633 commented 2 months ago

My purpose is to put a stoploss order after buy order, buy order through API is successful and showing in portfolio, using the below code:

API Code

def placeOrderOp(stock = "NIFTY", quantity = "50", today = "", expiryDate = "", option_type = "call", strike = "", action = "buy", price = "", order_type = "market", stoploss = ""):
    order = breeze.place_order(stock_code=stock,
    exchange_code="NFO",
    product="options",
    action=action,
    order_type=order_type,
    stoploss=stoploss,
    quantity=quantity,
    price=price,
    validity="day",
    validity_date=today,
    disclosed_quantity="0",
    expiry_date=expiryDate,
    right=option_type,
    strike_price=strike)
    return order

POST Request for all orders

@app.route('/api/breeze/order', methods=['POST'])
def get_all_data():
    new_data = request.get_json()
    print(new_data)
    order = placeOrderOp(stock =  new_data['stock'], quantity=new_data['quantity'], today = new_data['today'], expiryDate= new_data['expiry_date'], strike= new_data['strike'], option_type=new_data['option_type'], action=new_data['action'], order_type= new_data['order_type'], stoploss= new_data['order_type'], price= new_data['price'])
    return jsonify(order)

Example Request body

{"stock":"NIFTY","option_type":"put","strike":25900,"quantity":"25","expiry_date":"2024-09-26T06:00:00.000Z","today":"2023-09-23T06:00:00.000Z","stoploss":140,"action":"sell","order_type":"stoploss","price":139.5}

Error getting while calling the API

{ "Error": "Resource not available", "Status": 500, "Success": null }

Idirect-Tech commented 2 months ago

Dear Asif,

Please use below sample code for placing stoploss order.

breeze.square_off(exchange_code="NFO", product="options", stock_code="NIFTY", expiry_date="2024-09-26T06:00:00.000Z", right="Call", strike_price="16850", action="sell", order_type="stoploss", validity="day", stoploss="100", quantity="50", price="99", validity_date="2024-09-26T06:00:00.000Z", trade_password="", disclosed_quantity="0")

[E29CF836]

Thanks & Regards,

Hiten Solanki,

Team Breeze API,

ICICI Securities


From: Asif Iqubal @.> Sent: Monday, September 23, 2024 12:32 PM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: Subscribed @.***> Subject: [Idirect-Tech/Breeze-Python-SDK] Want to put stoploss order in options order (Issue #141)

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!

My purpose is to put a stoploss order after buy order, buy order through API is successful and showing in portfolio, using the below code:

API Code

`def placeOrderOp(stock = "NIFTY", quantity = "50", today = "", expiryDate = "", option_type = "call", strike = "", action = "buy", price = "", order_type = "market", stoploss = ""): order = breeze.place_order(stock_code=stock, exchange_code="NFO", product="options", action=action, order_type=order_type, stoploss=stoploss, quantity=quantity, price=price, validity="day", validity_date=today, disclosed_quantity="0", expiry_date=expiryDate, right=option_type, strike_price=strike) return order

POST Request for all orders

@app.route('/api/breeze/order', methods=['POST']) def get_all_data(): new_data = request.get_json() print(new_data) order = placeOrderOp(stock = new_data['stock'], quantity=new_data['quantity'], today = new_data['today'], expiryDate= new_data['expiry_date'], strike= new_data['strike'], option_type=new_data['option_type'], action=new_data['action'], order_type= new_data['order_type'], stoploss= new_data['order_type'], price= new_data['price']) return jsonify(order)`

Example Request body

{"stock":"NIFTY","option_type":"put","strike":25900,"quantity":"25","expiry_date":"2024-09-26T06:00:00.000Z","today":"2023-09-23T06:00:00.000Z","stoploss":140,"action":"sell","order_type":"stoploss","price":139.5}

Error getting while calling the API

{ "Error": "Resource not available", "Status": 500, "Success": null }

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

asif633 commented 2 months ago

Working properly thanks for the support