RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Position "pending close" Expand / Collapse
Message
Posted 2/8/2012 4:16:52 PM Post #14008
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
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 Post #14046
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
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 Post #14067
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
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
« 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, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 9:42am

2005-2007 © RightEdge Systems