It looks like you're new here. If you want to get involved, click one of these buttons!
'For placing Cover Order
Dim place_Order As Dictionary(Of String, Object) = kite.PlaceOrder(exchange, tradesymbol, transType, tradeqty, price, productType, ordType, validity, DisclosedQty, TriggerPrice, SqrOffValue, StopLossValue, TrailingStopLoss, variety, Tag)
Dim orderID As String = place_Order("data")("order_id")
Dim APIordstatus As List(Of Order) = kite.GetOrderHistory(orderID)
'Dim APItradestatus As List(Of Trade) = kite.GetOrderTrades(orderID)
Dim ordstatus As String
Dim entryprice As String
Dim parentOrderId As String
Dim sDate As Date
sDate = DateAdd("s", 3, Now.ToString)
Do While Now < sDate
For Each statsa In APIordstatus
If (orderID.ToString = statsa.OrderId.ToString) Then
ordstatus = statsa.Status.ToString
entryprice = statsa.AveragePrice.ToString()
If ordstatus = "COMPLETE" Then
parentOrderId = statsa.ParentOrderId.ToString
End If
End If
Next
Loop
Note : I tried this way for exiting the order :
Try
kite.CancelOrder(orderID , "co", parentOrderId)
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
Note :
When you place a cover order, the order id received in the success response is the parent order or first leg order. In order to find the second leg order, you need to fetch orderbook and look for an order which has this order id in the parent order id field.
Thanks once again for your support.