RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



OrderCancelled / OrderFilled events Expand / Collapse
Message
Posted 5/19/2009 04:56:04 Post #8502
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

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 5/19/2009 07:56:45 Post #8509
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
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 5/19/2009 09:14:24 Post #8510
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
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 5/20/2009 01:15:08 Post #8519
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru
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 5/20/2009 07:34:35 Post #8524
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
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 5/23/2009 22:54:26 Post #8565
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

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 5/24/2009 00:08:24 Post #8572
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
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 5/24/2009 02:05:33 Post #8573
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru
great, perfectly clear ! thanks a lot for the prompt support.
is there a way to "simulate" partially filled orders in backtesting ?
Posted 5/25/2009 15:01:50 Post #8589
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
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
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, young, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 6:56pm

2005-2007 © RightEdge Systems