API Support Forum
OEC API > Order Execution > Order Clearing
Author Topic: Order Clearing
(3 messages, Page 1 of 1)
Moderators: VPfau
NVerner2
Posts: 12
Joined: Apr 17, 2012


Posted: May 15, 2012 @ 04:20 AM             Msg. 1 of 3
Hello,

I am creating a trading algorithm, and I want it to have a method that offsets all existing orders, so that I can shut off the program and not have to worry. I believe I have figured out what to do for old market orders that I sent, but I'm not sure what I should do about filled stop orders. If a stop order is triggered, its state goes from Held to Accepted and it becomes a market order. After that, the state becomes Completed when the market order is filled, right?

I have references to my orders saved using the Order class. When a stop order becomes a market order, will my old reference work? Additionally, after the stop order becomes a market order and the market order is filled, how can I find that order to offset it? Will my original Order reference work or is there some better way to do this?

Thanks.

Nathan verner & Fred isabelle
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 17, 2012 @ 05:03 PM             Msg. 2 of 3
After login to the server OECAPI doesn't contain completed/cancelled/rejected orders from previous trading sessions.

Order ID is a persistent value even after modifications from stop to market order type.

You can find out state diagram here: http://www.openecry.com/api/api/OEC.Data.OrderState.html

Victor Vins
Lead Software Developer
NVerner2
Posts: 12
Joined: Apr 17, 2012


Posted: May 18, 2012 @ 07:39 AM             Msg. 3 of 3
OK, thanks a lot Victor!

Nathan verner & Fred isabelle