I have come across the issue using the Managed Approach when swapping positions with existing exit orders attached to previous position.
It appears the "Close Position" is generated but the OnPositionUpdate() has not yet run yet and does not recognise the new position, so when ExitLongStopMarket & ExitShortStopMarket are then called based on a filled position, i then get the error message Reason='This was an exit order but no position exists to exit'
So how do i swap a position and wait to re-submit the exit orders to the new position after the onPositionUpdate is called? There are no arguments in onPoisitonUpdate to pass the order name etc to track this position, is there an example of swapping a position using exit orders under the managed approach i have missed? All the examples i have seen only have 1 direction and do not swap.
Thankyou for your help.
Regards,
Comment