Posted 2/8/2012 4:16:52 PM
|
|
|
|
Good afternoon everyone,
I'm working on a plugin for MBT and have run into a problem while testing it live on a demo account. I keep working myself into a situation where RE and MBT become out of sync, and I am wondering if there's anything I can do to fix it. Consider the following example.
I am long 100 shares of ABC. I also have a pending stoploss order to sell 100 shares of ABC. These are both reflected correctly in the RE open positions and pending orders tabs. My system then issues a Position.CloseAtMarket() for the ABC position. My stop order gets cancelled correctly but then let's say the Sell 100 ABC order gets rejected for whatever reason. The broker plugin sends an OrderUpdated event with the new BrokerOrderState.Rejected status. RightEdge keeps the position marked "Pending close". If I try to manually close it, I get an error that says something to the effect of "this position is already pending close".
My question is: How can I make RightEdge realize this position is still open and no longer "pending close" ? It appears that I've done everything I can from the plugin side by updating the order with BrokerOrderState.Rejected. Is there something more I can do from the plugin side or do I need to create something in my system to look for this?
Thanks for any insight
|
|
Posted 2/16/2012 2:10:11 AM
|
|
|
|
Hi Gillean,
Right now there's not really a good way to get out of this situation. For the next build, I've fixed it so that if the close order is cancelled or rejected, the pending close flag will be reset to false.
For now, instead of calling CloseAtMarket(), you can just submit a market order to close the position with SubmitOrder(), and cancel any profit targets or stop losses. (Those orders will still automatically be cancelled once the close order is filled, so you don't necessarily need to do this part.) This way the position won't be marked "pending close" in the first place.
Thanks,
Daniel
|
|
Posted 2/20/2012 3:20:33 PM
|
|
|
|
dplaisted (2/16/2012) For the next build, I've fixed it so that if the close order is cancelled or rejected, the pending close flag will be reset to false.
Thanks Daniel, glad to hear this. I'll try what you suggested to see if I can make it work that way
|
|
|
|