try: order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product, quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY') return order_id except Exception as e: print("\nCould not place the order during the 1st time because of the following reason: \n" + "'" + str(e) + "'") sleep(1) try: order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product, quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY') return order_id except Exception as e: print("\nCould not place the order during the 2nd time because of the following reason: \n" + "'" + str(e) + "'") sleep(2) try: order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product, quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY') return order_id except Exception as e: print("\nCould not place the order during the 3rd and the last time because of the following reason: \n" + "'" + str(e) + "'") print("\nSomething seems to be wrong, please check.")
def place_order(variety, exchange, trading_symbol, transaction_type, product=None, quantity=None, order_type=None, price=None, trigger_price=None, square_off=None, stop_loss=None, disclosed_quantity=None):
try:
order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product,
quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY')
return order_id
except Exception as e:
print("\nCould not place the order during the 1st time because of the following reason: \n" + "'" + str(e) + "'")
sleep(1)
try:
order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product,
quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY')
return order_id
except Exception as e:
print("\nCould not place the order during the 2nd time because of the following reason: \n" + "'" + str(e) + "'")
sleep(2)
try:
order_id = kite.place_order(variety=variety, exchange=exchange, tradingsymbol=trading_symbol, transaction_type=transaction_type, product=product,
quantity=quantity, order_type=order_type, price=price, trigger_price=trigger_price, squareoff=square_off, stoploss=stop_loss, disclosed_quantity=disclosed_quantity, validity='DAY')
return order_id
except Exception as e:
print("\nCould not place the order during the 3rd and the last time because of the following reason: \n" + "'" + str(e) + "'")
print("\nSomething seems to be wrong, please check.")
and placing order you can use
call_order_id = place_order(variety='regular', exchange=exchange, trading_symbol=call_option_name, transaction_type='BUY', product='MIS', quantity=quantity, order_type='LIMIT', price = 1000)