I have code where my Stops are entered in the OnExecutionUpdate. What appears to be happening is that with each partial fill I'm getting a stop submitted for the full order amount. Conceivably, I could have a stop associated with each partial fill but that causes problems for other parts of the code, so I'm just trying to submit a single stop following a complete fill based on the average fill price. My code looks like this:
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (isBuyCont1)
{
enterPrice = execution.Order.AverageFillPrice;
buyCont1TrailPrice = enterPrice-stopSize;
if(execution.Order.OrderState==OrderState.Filled)
{
stopOrder = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, execution.Order.Filled, 0, buyCont1TrailPrice, ocoSignal, stopSignal);
targetOrder = SubmitOrderUnmanaged(0,OrderAction.Sell, OrderType.Limit, execution.Order.Filled, enterPrice+targetSize,0,ocoSignal,targetSignal);
}
Sorry for the formatting. Does anything stick out as to why I might be getting multiple stops submitted when I get partial fills?
Thanks
Comment