Profile Picture

Cancel Orders

Posted By BigBerner 10 Years Ago
Message
Posted Thursday April 26 2007
I am having trouble with cancelling an order. The bit I am having trouble with is tracking the order ID. Lets say I am running a system on a number of symbols, I place an order to buy on stop, and the next bar I wish to cancel the order. How do I get the orderID for that order? If I call PositionManager.GetPendingOrdersForPosition(PosID) I need the PosID, so I tried setting a PosID in SystemData.OpenPosition and using that, but when I run a simulation I get the error message that the PosID has already been used. If I let RE assign a PosID in SystemData.OpenPosition how would I know what PosID goes with the order I am trying to cancel. I am sure there is a simple solution but I am not seeing it at the moment.
Posted Friday April 27 2007
BigBerner (4/26/2007)
I am having trouble with cancelling an order. The bit I am having trouble with is tracking the order ID. Lets say I am running a system on a number of symbols, I place an order to buy on stop, and the next bar I wish to cancel the order. How do I get the orderID for that order? If I call PositionManager.GetPendingOrdersForPosition(PosID) I need the PosID, so I tried setting a PosID in SystemData.OpenPosition and using that, but when I run a simulation I get the error message that the PosID has already been used. If I let RE assign a PosID in SystemData.OpenPosition how would I know what PosID goes with the order I am trying to cancel. I am sure there is a simple solution but I am not seeing it at the moment.

You can use PositionManager.GetUniqueID(), and then pass that value into OpenPosition.  There was a bug with this that I do not think was fixed in the current beta, though.  So for now you could keep a counter which you increment each time you call OpenPosition, which you use for the Position ID.  Or you could use Guid.NewGuid().ToString() to get a unique position ID.

Thanks,
Daniel

Posted Monday April 30 2007
Thanks, so if I place an order using SystemData.OpenPosition and then subsequently cancel the order, does RE automatically cancel the pending position, or does the pending position hang around with no orders associated with it?
Posted Monday April 30 2007
BigBerner (4/30/2007)
Thanks, so if I place an order using SystemData.OpenPosition and then subsequently cancel the order, does RE automatically cancel the pending position, or does the pending position hang around with no orders associated with it?

The pending position will be canceled.

Daniel

Posted Monday April 30 2007
I keep getting the following message when running a simulation. Is this a known issue or is it my code?

An exception of type System.ArgumentException was thrown.
An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at RightEdge.Common.SystemStatistics.NewBar(NewBarInfo info, List`1 openPositions)
   at RightEdge.Common.BaseSystemHistory.SimNewBar(NewBarInfo info)
   at RightEdge.Common.SystemData.SimNewBar(NewBarInfo info)
   at RightEdge.SystemWrapper.NewBar(Dictionary`2 bars)
   at RightEdge.SystemWrapper.RunSystem(SystemData systemData, SystemRunInfo runInfo, Dictionary`2 historicalData, String brokerService)
   at RightEdge.SystemWrapper.RunSystem(DateTime start, Byte[] bytes)
   at RightEdge.SystemWrapper.RunSystem(DateTime start, Byte[] bytes)
   at RightEdge.TradingModuleWrapper.RunSystem(SystemData system, Dictionary`2 historicalData, SystemRunInfo dndInfo, String brokerService)
   at RightEdge.SystemProgress.InitAndRunSystem()

Posted Monday April 30 2007
This looks like the bug I mentioned with GetUniqueID().  It will be fixed in the next build but for now you need to create your own ID.

Daniel



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems