How to Place SL and Trailing SL with Kite API

gsx_3013
HI All

Hope you are doing well.

I have a question. I am trying to place a buy order and then a sell order using Kite API v3. Now the code that I have is

==== Start of CODE (ignore the indentation here)=====
#buy NFO at MO
def place_mo_buy(symbl):
print(f"[+] QT Place_MO_Sell: Placing BUY for NFO OPT: {symbl}")

try:
order_id = kite.place_order(tradingsymbol=symbl,variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NFO,
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=Quantity,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS,price=None, validity=None,
disclosed_quantity=None, trigger_price=None,
squareoff=None, stoploss=None, trailing_stoploss=None, tag=None)

print("Order placed. ID is:", order_id)
return order_id
except Exception as e:
print(“exception occured:” + str(e))
return -1

#sell NFO at MO
def place_mo_sell(symbl):
print(f"[+] QT Place_MO_Sell: Placing SELL for NFO OPT: {symbl}")

try:
order_id = kite.place_order(tradingsymbol=symbl,variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NFO,
transaction_type=kite.TRANSACTION_TYPE_SELL,
quantity=Quantity,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS,price=None, validity=None,
disclosed_quantity=None, trigger_price=None,
squareoff=None, stoploss=None, trailing_stoploss=None, tag=None)

print("Order placed. ID is:", order_id)
return order_id
except Exception as e:
print(“exception occured:” + str(e))
return -1

==== END of CODE ======
Now the questions are

How do I place the SL? Should I create a seperate MO SELL for that based on the defined TARGET? Do the argument “stoploss=None” work?

If I want to place in a Trailing SL? Do the argument “trailing_stoploss=None” work? is it % or what?

I know I can create a GTT to put in the SL, and Target but if it reaches Target how should i not execute the sell rather start trailing.

Thanks & Regards
Gaurav

Sign In or Register to comment.