No PositionManager is asynchronous when it comes to order processing. All interfacing with an external service such as a broker or data provider must be async. When you send a cancel order, we mark it as cancelled, or more specifically, we mark it with a "cancelpending" flag. So it should still be in the internal collections.
You certainly don't have to rewrite positionmanager. That would be quite a massive undertaking if you did.
But let me see if I follow this. You have a profit target and stop loss and one or the other is hit. You see RightEdge calling your plugin's CancelOrder() for the order that will not be filled. It follows with the error "Unable to cancel order".
Looking at the code in positionmanager, this should only happen if the call to CancelOrder fails. Are you returning false from that function? In this case, the call to your broker plugin is synchronous, but you should call OrderUpdated with a BrokerOrderState of rejected if something happens to where the cancellation doesn't occur. Until then, the system considers the order cancel pending.
I am just tracing the calls of your Positionmanager
I suppose your Positionmanager is synchronous...
the problem is that the FIX protocol is not synchronous..
when you cancel an order you do it directly.. I have to send a Message "cancel order" and later I receive the message "order cancelled"
but the PositionManager isnot waitingme......
If I am right I have to rethink the overall structure... Probably I have to write my own Positon Manager.