Due to Bid/Ask dynamics sometimes it gets me out of a position when it shouldn't, and then if I disable/enable the strategy because of overnight/closing ninja, I get a mismatch in strategy position vs. account position, because then he calculate the position in historical terms.
the result of that is: when he tries to get me out, he gets me out in the old position for example 200, and now I am in 100 position, so I will now be short 100.
In short, I want to do a double check whenever he exit a trade, to make sure the position is equal to the account position.
I am using for the stop quantity the variable: Position.Quantity , which now I know could be wrong due to historical/real-time differences.
How can I do double check on Position.Quantity? + where should I put it? (in executionupdate?)
something like: if (Position.Quantity > Account.Quantity) then exit with Account.quantity.
the strategy is Long ONLY, so I know for sure that I will never want to be Short somehow.
If you thought about this problem already, will appreciate the solution, thanks in advance!
Comment