This paper addresses a method to solve a multi-period portfolio selection on the stock market. The portfolio problem seeks an investor to trade stocks with a finite budget and a given integer number of stocks to hold in a portfolio. The trade must be performed through a stockbroker that charges its respective transaction cost and has its minimum required trade amount. A mathematical model has been proposed to deal with the constrained problem. The objective function is to find the best risk-return rate; thus, Sharpe Ratio and Treynor Ratio are used as objective functions. The returns are the same for these ratios, but the risks are not Sharpe considering covariance and Treynor systematical risk. The returns are predicted using a Neural Net with Long-Short-Term Memory (LSTM). This neural net is compared with simple forecasting methods through Mean Absolute Percentage Error (MAPE). Computational experiments show the quality prediction performed by LSTM. The heteroskedastic risk is estimated by Generalized Autoregressive Conditional Heteroskedasticity (GARCH), adjusting the variance for every period; this risk measure is used in Sharpe Ratio. The experiment contemplates a weekly portfolio selection with 5 and 10 stocks in 122 weekly periods for each Chilean market ratio. The best portfolio is Sharpe Ratio with ten stocks, performing a 62.28% real return beating the market, represented by the Selective Stock Price Index (IPSA). Even the worst portfolio, Treynor Ratio, overcomes the IPSA cumulative yield with ten stocks.