In this work, we consider the optimal portfolio selection problem under hard constraints on trading amounts, transaction costs and different rates for borrowing and lending when the dynamics of the risky asset returns are governed by a discrete-time approximation of the Markov-modulated geometric Brownian motion. The states of Markov chain are interpreted as the states of an economy. The problem is stated as a dynamic tracking problem of a reference portfolio with desired return. Our approach is tested on a set of a real data from Russian Stock Exchange MICEX.