This article considers the problem of forecasting stock prices using the example of the largest oil companies in Russia (Rosneft, Lukoil, Gazpromneft and Surgutneftegaz) using artificial neural networks, and also analyzes the profitability of an investment portfolio formed from ordinary shares of the four largest oil companies in Russia in equal shares and with optimal their value determined in the course of solving the direct problem according to the G. Markowitz model using predictive values.