for i in a: if(i[order_id]==ce_sell_order_id) and (i[status]=="COMPLETE"): #check for order completion status also, then go for placing a Sl-M order. sl = i[average_price]*1.25 ce_slm_sell_order_id=kite.place_order (variety=kite.VARIETY_REGULAR, exchange=kite.EXCHANGE_NFO, order_type=kite.ORDER_TYPE_SL-M, tradingsymbol=banknifty_tradingsymbol_CE, transaction_type=kite.TRANSACTION_TYPE_BUY, quantity=25, price=sl, validity=kite.VALIDITY_DAY, product = kite.PRODUCT_MIS, )
ce_counter = ce_counter+1
Problem no. 1: while running the program it says that "local variable 'ce_counter' referenced before assignment" although I have initialized the variable at the very start of the program with other variables as: banknifty_tradingsymbol_CE = 0 banknifty_tradingsymbol_PE = 0 ce_sell_order_id =0 ce_slm_sell_order_id = 0 pe_sell_order_id =0 pe_slm_sell_order_id =0 ce_counter = 0 pe_counter = 0
after initializing it at the beginning itself variable should act globally, but there is some issue. Please help me out in this.
Although that previous error has been by-passed but still the code is not functioning appropriately.
Attaching the file URL.
What I desire from the code is to sell ATM CE and PE of an Index and at the same time put SL of 25% for each of the two trades.
Rules: 1. The above selling should happen only once in the time frame entered by the user. 2. SL should be calculated based on the price on which order has been executed.
Also please let me know if there is any platform of Zerodha for checking our codes, where virtual money is involved as it will help to check the code without any monetary loss due to some error in code.
Also please let me know if there is any platform of Zerodha for checking our codes, where virtual money is involved as it will help to check the code without any monetary loss due to some error in code.
No, currently we don't have a sandbox environment.
Attaching the file URL.
What I desire from the code is to sell ATM CE and PE of an Index and at the same time put SL of 25% for each of the two trades.
Rules:
1. The above selling should happen only once in the time frame entered by the user.
2. SL should be calculated based on the price on which order has been executed.
Also please let me know if there is any platform of Zerodha for checking our codes, where virtual money is involved as it will help to check the code without any monetary loss due to some error in code.
https://drive.google.com/file/d/1aP8PZnfPSd-B8MpjF4C6JFV_exHgYeuH/view?usp=sharing