markg wrote:
//1) make an order to buy on stop with SL
order = engine.submitOrder("order1", instrument, IEngine.OrderCommand.BUYSTOP, 1.000 , price, slippage, stopLossPrice, 0);
Entry stop is hit,
Partial fill buy 0.2
IOrder.State = “FILLED”
Order.getAmount() = 0.2
getRequestAmount() = 1.0
onMessage ORDER_FILL_OK
fill buy 0.8
IOrder.State = “FILLED”
Order.getAmount() = 1.0
getRequestAmount() = 1.0
onMessage ORDER_FILL_OK
Order.getAmount() = getRequestAmount(), so entry complete.
At this point it is unclear to me what happen with the IOrder.State, Order.getAmount(),getRequestAmount()?
They are as you described above.
markg wrote:
Is the Order.getAmount() reset to zero for closing the position?
No, it remains 1.0.
markg wrote:
Is there a way of telling if the fill was a buy or a sell?
IOrder.isLong.
markg wrote:
Stop loss price is hit
Partial fill sell 0.3
IOrder.State = “FILLED” or “CLOSED” ????
Order.getAmount() = 0.3 ????
getRequestAmount() = 1.0
onMessage ORDER_FILL_OK ?? or now IHistory to get fill??
Partial fill sell 0.7
IOrder.State = “CLOSED” ????
Order.getAmount() = 1.0 ????
getRequestAmount() = 1.0
onMessage ORDER_FILL_OK ?? or now IHistory to get fill??
onMessage ORDER_CLOSE_OK ??
Order.getAmount() = getRequestAmount(), so exit complete and order closed..
IOrder represents a postion - the main order with attached SL and TP conditional orders, thus:
Partial
close on SL sell 0.3:
IOrder.State = “FILLED”
Order.getAmount() = 0.7
getRequestAmount() = 1.0
onMessage ORDER_CLOSE_OK (as in the case of partical close)
Full
close on SL sell 0.7:
IOrder.State = “CLOSED”
Order.getAmount() = 1.0
getRequestAmount() = 1.0
onMessage ORDER_CLOSE_OK
now IHistory to get fill