I am just practicing with pair trading. Due to code conditions new orders pair issues on start and any time when both orders of previous pair are closed. But code works in very strange way. One of securities traded only once and another security position changes very often despite of condition to change the position does not happen.
Could you please help me figure out where I make mistake.