In this work, we study the dynamic portfolio optimization problem related to the pairs trading, which is an investment strategy that matches a long position in one security with a short position in an another security with similar characteristics. The relation between pairs, called spread, is...