Profile Picture

OrderCancelled / OrderFilled events

Posted By FlipFlop 8 Years Ago
Message
Posted Tuesday May 19 2009

1 * In which situation do we received an OrderCancelled event ? My understanding is we receive this event only:
- when we close a position, we receive it for the stop loss and take profit orders
- unexpectedly when the broker has canceled our order (in that case order.CancelPending would be set to false), in that case we should resubmit the order or do whatever we want, the order is not at the broker anymore.

2 * When we receive an OrderFilled event, can we suppose the order has been filled correctly and fully ? How do you manage orders which are not filled completely ?

3 * Where is the best place to put some code to be executed once at the end of a backtesting ?

Thanks
Posted Tuesday May 19 2009
Any time any order is cancelled. The stop loss and profit target orders are cancelled when a position is closed. Are you seeing them unexpectedly?

Shutdown?

FlipFlop (5/19/2009)

1 * In which situation do we received an OrderCancelled event ? My understanding is we receive this event only:
- when we close a position, we receive it for the stop loss and take profit orders
- unexpectedly when the broker has canceled our order (in that case order.CancelPending would be set to false), in that case we should resubmit the order or do whatever we want, the order is not at the broker anymore.

2 * When we receive an OrderFilled event, can we suppose the order has been filled correctly and fully ? How do you manage orders which are not filled completely ?

3 * Where is the best place to put some code to be executed once at the end of a backtesting ?

Thanks
Posted Tuesday May 19 2009
Actually, OrderFilled will be called for partial fills of an order as well as when the order has been completely filled. If the order hasn't been completely filled, the order status will be PartiallyFilled instead of Filled.

Daniel
Posted Wednesday May 20 2009
How can I access this order status ? The OrderFilled method has two parameters, position and trade.
   public override void OrderFilled(Position position, Trade trade)

Besides, if an order is partially filled, what would be the position.state (open or pending ?) ?

dplaisted (5/19/2009)
Actually, OrderFilled will be called for partial fills of an order as well as when the order has been completely filled. If the order hasn't been completely filled, the order status will be PartiallyFilled instead of Filled.

Daniel
Posted Wednesday May 20 2009
Position.State. It's open until it's completely filled.

FlipFlop (5/20/2009)
How can I access this order status ? The OrderFilled method has two parameters, position and trade.
   public override void OrderFilled(Position position, Trade trade)

Besides, if an order is partially filled, what would be the position.state (open or pending ?) ?

dplaisted (5/19/2009)
Actually, OrderFilled will be called for partial fills of an order as well as when the order has been completely filled. If the order hasn't been completely filled, the order status will be PartiallyFilled instead of Filled.

Daniel
Posted Saturday May 23 2009

I'm not sure I understand.
When I call OpenPosition, the state will be pending, right ?
Then, upon OrderFilled event, if the order has been partially filled, with the state remain in Pending or change to Open ? And if it changes to Open for a partially filled order, how do we know the order is fully filled or only partially filled ?


billb (5/20/2009)
Position.State. It's open until it's completely filled.

FlipFlop (5/20/2009)
How can I access this order status ? The OrderFilled method has two parameters, position and trade.
   public override void OrderFilled(Position position, Trade trade)

Besides, if an order is partially filled, what would be the position.state (open or pending ?) ?

dplaisted (5/19/2009)
Actually, OrderFilled will be called for partial fills of an order as well as when the order has been completely filled. If the order hasn't been completely filled, the order status will be PartiallyFilled instead of Filled.

Daniel
Posted Sunday May 24 2009
FlipFlop (5/23/2009)
how do we know the order is fully filled or only partially filled ?

check if(Trade.Order.OrderState == BrokerOrderState.PartiallyFilled)

Trade class members
http://www.rightedgesystems.com/documentation/developerguide/html/AllMembers_T_RightEdge_Common_Trade.htm


Order class members
http://www.rightedgesystems.com/documentation/developerguide/html/AllMembers_T_RightEdge_Common_Order.htm


BrokerOrderState enum
http://www.rightedgesystems.com/documentation/developerguide/html/T_RightEdge_Common_BrokerOrderState.htm
Posted Sunday May 24 2009
great, perfectly clear ! thanks a lot for the prompt support.
is there a way to "simulate" partially filled orders in backtesting ?
Posted Monday May 25 2009
FlipFlop (5/24/2009)
great, perfectly clear ! thanks a lot for the prompt support.
is there a way to "simulate" partially filled orders in backtesting ?

Not with the out-of-the-box paper trader. You could write your own paper trader (which would be very complicated) to simulate this. You might also be able to derive from the existing paper trader to add this functionality, although I'm not sure if we provide all the right hooks for this.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems