In rare occasions I face the issue of missed OnPositionUpdate event what entails wrong further trading logic. Let me explain step by step.
The strategy logic has the following structure.
protected override void OnOrderTrace(DateTime timestamp, string message)
{
// Log #1
}
protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
{
// Log #2
}
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
// Log #3
}
protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition)
{
// Log #4
if (quantity == 3)
{
// Some logic #2
}
}
protected override void OnBarUpdate()
{
// Some logic #1
}
Let's suppose entry condition is met and the logic places 2 orders consecutively:
1. Entry for TP1 2 contracts.
2. Entry for TP2 1 contract.
In the most cases I see normal workflow in the log. I see 2 placed and filled orders. As result I have an opened position of size 3 and "Some logic #2" is executed. But in rare occasions I see the following sequence:
1. Log #1 shows entry for TP1 has been placed (2 contracts)
2. Log #1 shows entry for TP2 has been placed (1 contracts)
3. Log #3 shows execution for TP1 has been processed (1 contracts)
4. Log #2 shows order for TP1 has been filled (2 contracts)
5. Log #3 shows execution for TP1 has been filled (1 contract)
6. Log #2 shows order for TP2 has been filled (1 contract)
7. Log #4 shows the position has changed (quantity 2)
8. Log #3 shows execution for TP2 has been filled (1 contract)
And no any log records any more... The logic can't follow "Some logic #2" until the position size is 2. it waits for 3. But it seems OnPositionUpdate call was missed...
I posted something similar here https://forum.ninjatrader.com/forum/...ocessing-issue. I used IB connection that time. Now I use Continuum as market provider and the latest version of NT8 (8.1.3.0). Do you also experience any problems of position size calculation with Continuum?

Comment