You can reach out to our support team at help@dhan.co, or any of our official customer support channels for resolution to your queries. As you may know, this is an open community and threads might get lost - refer to community guidelines.
We try our best to check every open thread but some might get missed or unaddressed, or there might be other community members who might reply to it. Apologies from my side to have missed this particular topic.
On your query, this is occurring as you are placing limit order for both buy and sell. It might happen that your Buy order is not matched (as the ask is higher than the limit price) and later the Sell order gets executed (due to price matching).
HArdik
our client wants us to specifically place a limit order only. Any suggestions please.
If we can try to check if the buy limit order is successful and then try to place the sell order then there might be a time gap. Please let me know any suggestions please.
Thanks
Sai
Understood. What you can try is placing LIMIT order instead but also polling Trade Book API to get order status at defined interval. If you get order executed as success, then you can place simultaneous take_profit order. I wonât be able to help you with code for this, as this is too custom and will depend on your trading strategy.
# get order from dhan api list_orders()
df_orders_from_dhan,fname = get_orders_list_from_dhan()
# get ordr_id of the buy order from local var
ordr_id = dct_args['ordr_id']
# get the specific row of that buy orderid
df_order = df_orders_from_dhan[df_orders_from_dhan['orderId']==ordr_id]
if len(df_order) == 1:
order_status = df_order['orderStatus'].iloc[0]
if order_status.lower()=='traded':
symbol = dct_args['symbol']
ttype_buy_sell = dct_args['ttype_buy_sell']
security_id = dct_args['security_id']
qty = dct_args['qty']
price = dct_args['price']
bo_profit_val = dct_args['bo_profit_val']
take_price = price + price*(bo_profit_val)
*** is it possible to specify the orderid of the buy order when placing sell order
so that specific buy orderid is placed for sell and not any other order as there may be many orders for a symbol.securityId ***
response_sell = dhan.place_order(
transaction_type=dhan.SELL,
exchange_segment=dhan.NSE,
product_type=dhan.INTRA,
order_type=dhan.LIMIT,
security_id=f'{security_id}',
quantity=1,
price= take_price
)