Proper way of exiting the Cover order in Commodity

ibot
Hi,

I have been trying to incorporate the usage of Cover order for commodity. In order to exit the cover order upon hitting the required target, what is the proper
way to invoke the API.

The approach I followed is as follows,
Plz note: I'm using Python client for this,


def exit_the_order(self, order_id, parent_order_id, instrument_token):
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':ECDHE-RSA-AES256-GCM-SHA384'
api_key='+CONFIG.API_KEY+'&access_token='+CONFIG.ACCESS_TOKEN+'&parent_order_id='+parent_order_id
url = "https://api.kite.trade/orders/co/"+order_id+"?parent_order_id="+parent_order_id
var = "token " + CONFIG.API_KEY + ":" + CONFIG.ACCESS_TOKEN
headers = {
"X-Kite-Version": '3',
"Authorization": var
}
try:
response = requests.delete(url, data=data, headers=headers)
json_data = json.loads(response.text)
if json_data['status'] == 'success':
print("Order id:", order_id, " exited successfully.")
else:
print(" Exiting the order:", order_id, " Failed...")

except Exception as e:
print("Exception occured ")
return

Up on executing the above function, I started seeing the message "request order pending". I tried to use different API looking at the kite documentation, like
url = "https://api.kite.trade/orders/regular/"+order_id+"
url = "https://api.kite.trade/orders/bo/"+order_id+"

Please help me out on this issue of
1.proper way of exiting the cover order,
2.Modifying the trigger_price.

Thanks,

Tagged:
  • ibot
    Guy plz help me out. I'm absolutely stuck on this.
  • rakeshr
    @ibot
    You can use kite Connect Python client, instead of using requests lib.To Exit Cover order, for Python client:
    kite.cancel_order(variety='co',order_id='Order id for pending limit buy/sell order')
    Go through this documentation.
  • ibot
    ibot edited July 2018
    Hi thanks,

    I got it.

    Anyways, I also found the solution to use request library. Just posting the solution to help others who found similar issue.
    requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':ECDHE-RSA-AES256-GCM-SHA384'
    url = "https://api.kite.trade/orders/co/"+order_id
    var = "token " + API_KEY + ":" + ACCESS_TOKEN
    headers = {
    "X-Kite-Version": '3',
    "Authorization": var
    }

    try:
    response = requests.delete(url, headers=headers)
    json_data = json.loads(response.text)
    if json_data['status'] == 'success':
    print("Order id:", order_id, " exited successfully.")
    except Exception as e:
    print("Exception e:", str(e))
    return
This discussion has been closed.