How to book Profit or exit the cover order using Python

samphel
samphel edited January 2020 in Python client
hello everyone,

please help me out, how to exit or square off the cover order when you have reached your target, since the stoploss order is always with the cover order and when it touched the SL price it gets activated and order is executed , now if i have reached my profit target how to exit that order using python please help im also attaching a order output i have received.
[{'average_price': 180.45,
'cancelled_quantity': 0,
'disclosed_quantity': 0,
'exchange': 'NSE',
'exchange_order_id': '1200000000865127',
'exchange_timestamp': datetime.datetime(2020, 1, 24, 9, 31, 23),
'exchange_update_timestamp': '2020-01-24 09:31:23',
'filled_quantity': 6,
'guid': 'ffshfshdf',
'instrument_token': 1723649,
'market_protection': 0,
'meta': {},
'order_id': '200124000435472',
'order_timestamp': datetime.datetime(2020, 1, 24, 9, 31, 23),
'order_type': 'MARKET',
'parent_order_id': None,
'pending_quantity': 0,
'placed_by': 'dfgsdf',
'price': 0,
'product': 'CO',
'quantity': 6,
'status': 'COMPLETE',
'status_message': None,
'status_message_raw': None,
'tag': None,
'tradingsymbol': 'JINDALSTEL',
'transaction_type': 'BUY',
'trigger_price': 178.9,
'validity': 'DAY',
'variety': 'co'},
now i like to sell this jindalstel when target reached , how to code that in python

  • sujith
    You can refer to the documentation here.
  • samphel
    @ sujith i have gone through the documents , i need some examples what is difference between "cancel order" and "exit order"
  • Matti
    @samphel When you exit a cover order position, the stoploss order is modified by the system to a market order. When you use "cancel", an open order that hasn't executed yet is cancelled.
  • samphel
    samphel edited January 2020
    @Matti Thank you, so if in a case where i have reached the target price i could use the algo as follow:
    if (latest_price >= squareoff_price_long):

    kite.exit_order(variety=variety_check, order_id=parent_order_id)
    print(stock_name, "order is exited")

    where latest_price is the ltp i'm geting from kite.ltp and squareoff_price_long is the price where i want to square off and variety_check is "CO". Since i have used this step in my code and i was successfully excuted from the cover order, so for final check i need to know weather i'm doing right or wrong
  • Matti
    Yes, that's right.
  • samphel
    @Matti Thankyou very much really banged my head a lot for this problem
This discussion has been closed.