Abstract
In recent years, with the increasing number of investors, traders frequently buy and sell products with high market volatility, such as gold, and bitcoin is used to maximize profits. This article studies the use of historical price data of currencies in the trading market to avoid risks in the investment process, predict the direction of product prices, and obtain maximum returns. For investors, if they can have a good trading strategy, this will bring them a stable income, while also ensuring the smooth operation and stability of the trading market. In order to better predict the currency trend, this paper uses historical data to predict the next day’s currency price to construct LSTM, random forest, gradient recovery tree and xgboost model for single-step prediction, through comparison, the random forest model has the best prediction effect. This paper uses the prediction results to propose a method for portfolio optimization based on dynamic programming, which considers the impact of risk factors on the portfolio management process, can automatically convert the portfolio optimization mode according to market conditions and asset information to cope with market style changes, and adjust the portfolio asset composition and asset allocation in real time through the dynamic trading of portfolio internal assets and external asset pools, so as to maximize theoretical profits.

This publication has 8 references indexed in Scilit: