Nonmyopic optimal portfolios in viable markets