82
Finance, Accounting and Business Analysis
Volume 7 Issue 1, 2025
http://faba.bg/
ISSN 2603-5324
DOI: https://doi.org/10.37075/FABA.2025.1.07
Portfolio Optimization Based on MPT-LSTM Neural Networks:
A case study of Cryptocurrency Markets
Habib Zouaoui
1
* , Meryem-Nadjat Naas
2
Department of Finance and Accounting, University of Relizane, Relizane, Algeria
1
Department of Management, University of Relizane, Relizane, Algeria
2
* Corresponding author
Info Articles
Abstract
History Article:
Submitted 19 February 2025
Revised 19 May 2025
Accepted 22 May 2025
Purpose: This study aims to examines advanced portfolio management
techniques using Long Short-Term Memory (LSTM) networks, the study was
applied to investing in cryptocurrencies whose markets are characterized by
high-frequency trading, and using behavioral finance models based on the
concept of return-risk and deep learning based on the work of artificial neural
networks (ANN) and long-term memory (LSTM) algorithms
Design/Methodology/Approach: This study adopts quantitative approach.
Moreover, A random portfolio consisting of 25 cryptocurrencies was selected
based on the database of the website: https://finance.yahoo.com/crypto/
during the period 2021-2024 AD and programming the Python language. And
an attempt to evaluate the performance of the models used in accurately
predicting the optimal relative weights of the investment portfolio, which proved
the relative effectiveness of deep learning models by estimating the values of the
mean square error (MSE) at a level of 0.0218% to predict the optimal portfolio
weights for 5 days based on training 80% and testing 20% of the study data.
Findings: The second hypothesis of this study was accepted, which states the
effectiveness of deep learning algorithms to predict the weights of optimal
portfolios with a return estimated at 1.7239% and a risk of 1.1219% and a Sharpe
index value estimated at 1.5365%, while the Markowitz return-risk model
portfolio came with a return rate estimated at 31.15% and a risk of 39.05%. With
no diversification of investment on all portfolio assets and a Sharpe index value
of 0.7978%.
Practical Implications: This study provides important insights that machine
learning offers significant advantages in portfolio optimization, from improved
forecasting of asset returns to dynamic rebalancing, better risk management, and
automation. The ability to handle high-dimensional, non-linear, and non-
stationary data makes ML an ideal tool for optimizing portfolios in complex and
fast-moving markets; especially in cryptocurrency markets. However, challenges
like data quality, overfitting, and interpretability must be addressed to ensure
effective deployment of ML in real-world portfolio.
Originality/Value: This study provides an original and timely contribution to
understanding the use of deep learning for portfolio optimization represents a
significant advancement over traditional financial models by offering several
original and valuable benefits. These include the ability to capture complex non-
linear relationships, dynamic rebalancing in response to real-time data,
processing of unstructured data (like sentiment analysis), advanced risk
management, and the integration of high-dimensional data. The combination of
these capabilities enables more accurate, adaptive, and robust portfolio
optimization, ultimately enhancing portfolio performance and reducing risk.
Paper Type: Research Paper
Keywords:
Markowitz Model,
Deep Learning,
Portfolio Optimization,
Cryptocurrencies,
LSTM Neural Networks
JEL: C38, C4, C45, C5,
C58, G1, G11.
*
Address Correspondence:
E-mail: habib.zouaoui@univ-relizane.dz
1
meryemnadjat.naas@univ-relizane.dz
2
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
83
INTRODUCTION
Portfolio optimization is a cornerstone of modern finance, focusing on the strategic allocation of
capital across various assets to achieve specific investment objectives, such as maximizing returns or
minimizing risk. Traditional methods, such as the Markowitz mean-variance model, rely on statistical
assumptions and linear relationships, which may not adequately capture the complexities of financial
markets. Given that these markets often exhibit non-linear dynamics and intricate interdependencies, Deep
Learning (DL) emerges as a compelling alternative for portfolio optimization. This literature review explores
the application of DL techniques in optimizing portfolios, highlighting their capacity to model non-linear
relationships and enhance predictive accuracy. We examine various DL architectures, including neural
networks and reinforcement learning, and their efficacy in addressing the limitations of traditional models.
The review also discusses practical implications, such as feature selection and data preprocessing, and
identifies future research directions to further integrate DL methods into portfolio optimization frameworks.
Ultimately, this review underscores the potential of deep learning to revolutionize portfolio management in
an increasingly complex financial landscape (Zhang et al. 2025).
However, Artificial intelligence is one of the sciences that the world has begun to rely on in various
areas of life due to the ability of this science to collect and analyze big data (Big Data) and make decisions
and reach accurate results that exceed the ability of the human element. As for the field of financial markets,
with the increasing complexities of financial globalization that have increased the conditions of future
uncertainty and high risks, asymmetry of circulating information and problems of fear and panic among
investors, and in light of the emergence of the Fourth Industrial Revolution, automation of financial services
and high-frequency trading, more than 80% of daily global stock market trading has become trading done
through artificial intelligence (AI) and algorithmic trading, as they are trading done without any human
intervention. Artificial intelligence enables investors to trade by creating, examining and testing data and
making investment decisions automatically through machine learning. Machine learning is programmed
through algorithms and placing orders according to specific criteria such as average daily trading and
comparing them with trading averages in past periods, price changes, offered quantities, market fluctuations
as a whole, price changes in the derivatives market and the future outlook of the economy, taking into
account, for example, news related to stimulus packages or any news affecting the market by decision
makers, in order to study and analyze them and reach a final result by machine learning, which leads to the
implementation of a specific investment order. Trading in this innovative method results in objectivity in the
investment decision. Behavioral Finance is predominant in humans during trading, meaning that they are
more likely to be affected behaviorally by the environment and economic changes, which leads to a change
in the investment decision that was previously taken, and this change in behavior and investment decision
may result in unexpected losses. One of the benefits of this innovative trading method is the speed of
executing trading orders, as an investment opportunity is searched for, information about it is collected, and
a huge amount of data is analyzed accurately, and the appropriate investment decision is made through
machine learning. This entire process is completed in a matter of seconds. As the human being’s ability to
search for a similar opportunity and implement the appropriate investment decision regarding it takes longer,
which may lead to wasting the investment opportunity.
Generally, our study will try to test the following hypotheses:
H1: The DL models provides the forecasting of cryptocurrencies portfolio optimization with higher
accuracy than MPT model.
H2: The MPT model provides the forecasting of cryptocurrencies portfolio optimization with higher
accuracy than DL models.
LITERATURE REVIEW
Table below is a summarized comparison of results from recent studies (2020–2025) on portfolio
optimization using deep learning models versus Harry Markowitz's Modern Portfolio Theory (MPT) model.
These results highlight the key findings and performance metrics from the studies.
However, MPT remains a cornerstone of portfolio optimization due to its simplicity and effectiveness
in diversification. However, its limitations in handling dynamic and complex markets have led to the rise of
alternative approaches like Deep Learning (DL) models (e.g., LSTM, GRU), which offer superior
adaptability and predictive power. Hybrid models combining MPT and DL are emerging as a promising
direction for robust portfolio optimization
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
84
Table 1. Reviewed Previous Studies
Authors/Year
StudyTitle
Key Findings
Heydarpour et
al. (2024)
Robust Portfolio
Optimization using
LSTM-based Stock
And Cryptocurrency
Price Prediction: An
Application of
Algorithmic
Trading Strategies
LSTM and RNN capture temporal
dependencies, outperforming MPT
in dynamic markets.
LSTM/RNN adapt better to time-
series data; MPT assumes static
correlations.
Yu (2023)
Mean-variance
Portfolio
Optimization by
LSTM-based
Predictions
Hybrid model which combine the
stock price forecasting with asset
allocation can indeed bring excess
returns
Xu et al.(2022)
LSTM-MPT Based
Quantitative
Portfolio Decision
Model,
a comparative analysis with the four
commonly used portfolio model
strategies shows that the LSTM-
MPT decision model is valid and
reliable for long-term investments
Cui et al.
(2023)
Portfolio
constructions in
cryptocurrency
market: A CVaR-
based deep
reinforcement
learning
unfolding that CVaR measure with
deep learning outperforms the
traditional portfolio construction
technique
Xu
et al. (2025)
Cryptocurrency
Portfolio
Optimisation Based
on LSTM Time
Series Forecasting
The results indicate that the LSTM-
enhanced portfolio optimization
method yields higher returns and
better risk management compared to
traditional methods
Zhang
)2025(et al.
Portfolio
Optimization with
Lstm-Based Return
and Risk
Information
LSTM and RNN capture temporal
dependencies, outperforming MPT
in dynamic markets
Durall (2022)
Asset Allocation:
From Markowitz to
Deep Reinforcement
Learning
DRL method has the potential to
construct a promising
investment strategy
Sebastian et al.
(2024)
Deep Learning for
Stock Price
Prediction and
Portfolio
Optimization
The study hence concludes that
combining forecasting theory with
portfolio selection could
improve portfolio returns
Source: Authors’ analysis from literature review (2025).
Broadly, the integration of deep learning techniques into cryptocurrency portfolio optimization has
garnered increasing attention due to the unique challenges posed by the highly volatile and non-linear nature
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
85
of cryptocurrency markets. This literature review systematically examines recent advancements in applying
deep learning methods for optimizing cryptocurrency portfolios. We analyze various architectures, including
recurrent neural networks (RNNs), convolutional neural networks (CNNs), and reinforcement learning,
assessing their effectiveness in predicting price movements and enhancing portfolio performance. The review
highlights key findings on the ability of deep learning models to capture complex relationships and patterns
within cryptocurrency price data, leading to improved risk-adjusted returns. Additionally, we discuss the
implications of feature selection, data preprocessing, and model evaluation metrics critical for successful
implementation. The review concludes by identifying gaps in the current literature and proposing directions
for future research, particularly in the areas of model interpretability and the incorporation of
macroeconomic factors into deep learning frameworks for cryptocurrency portfolio optimization. (Ashy et
al. 2024).
MATERIALS AND METHODS
Modern Portfolio Theory (MPT) model
Modern Portfolio Theory (MPT) provides a rigorous, quantitative framework for portfolio
construction that emphasizes diversification and the tradeoff between risk and return. While it has become
a cornerstone of modern investment theory, its assumptions of normal returns and constant correlations can
limit its practical application in volatile or non-normal market conditions. However, MPT continues to serve
as a benchmark, and modern variations (e.g., Black-Litterman model, Dynamic MPT) have been developed
to address some of its shortcomings (Zouaoui and Naas 2021).
Furthermore, We should present the MPT mathematical model, moreover, we consider a more
general case with n risky securities Notations: for i = 1,..., n,
󰇛
󰇜
: is the vector of portfolio weights.
󰇛
󰇜
: is the vector of asset returns.
󰇛
󰇜
: is the vector ofasset returns expectations.
󰇛

󰇜
: is the vector with all components equal to 1.



: is the (n × n) variance-covariance matrix of returns. The matrix V is supposed to be
invertible.
Denote by W' the vector deduced from transposition of the vector W. For each given expected return,
we have to determine the minimal variance portfolio.
Therefore, following the Markowitz approach to determine optimal weights of portfolio, we have to
determine the set of portfolios which minimize the variance for given expected returns
󰇟
󰇠
. This leads to
the following quadratic optimization problem (Prigent 2007):

󰆒


󰆒
󰆒

󰇟
󰇠
󰆒

(1)
The first constraint corresponds to the fixed expectation level. The second constraint is simply that w
is a vector of weights. However, short selling is allowed and no other specific constraints are introduced.
The expected return of any portfolio P with weights w is given by:
󰇟
󰇠
󰇟
󰇠


󰆒
(2)
The variance of the return of P is equal to:
󰇛
󰇜
󰆒








(3)
The previous relation shows the decomposition of the variance of the portfolio return into two
components. This relation proves that the marginal contribution of a given asset to the risk of the whole
portfolio is not reduced to its own risk (its variance), but also takes account of its potential correlations to
other securities. This latter property induces the diversification effect.
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
86
From relation below, the partial derivative with respect to any weight w
i
is deduced:

󰇛
󰇜



(4)
Denote by σ
iP
the correlation coefficient between asset i and portfolio P. Then:




 󰇭

󰇮
(5)
and finally:

󰇛
󰇜


(6)
Deep learning (DL) models
This section is devoted to briefly describe the basic principle of four Non-linear machine learning
models or deep learning models that will be used later for cryptocurrency forecasting namely RNN, LSTM
(Zouaoui and Naas 2023).
Recurrent neural networks (RNN)
Forecasting with recurrent neural networks (RNNs) is a common application in time series analysis,
where the goal is to predict future values based on past observations. RNNs are particularly well-suited for
sequential data due to their ability to capture temporal dependencies. Here's a general guide on how to use
RNNs for forecasting (Ibri and Slimane 2022):
a. Data Preparation:
o Collect and preprocess the time series data (e.g., normalize or standardize the data).
o Create input-output pairs by sliding a window over the sequence. For example:
Input: (x
t
,x
t+1
,…,x
t+n−1
)
Output: x
t+n
(the value to predict).
b. Model Design:
o Choose the RNN architecture (e.g., LSTM, GRU).
o Define the number of layers, hidden units, and activation functions.
o Add a dense layer at the end to produce the final output (e.g., a single value for univariate
forecasting or a vector for multivariate forecasting).
c. Training:
o Use a loss function like Mean Squared Error (MSE) or Mean Absolute Error (MAE) to
measure the difference between predicted and actual values.
o Optimize the model using backpropagation through time (BPTT) and an optimizer like Adam
or SGD.
d. Evaluation:
o Evaluate the model on a test set using metrics like RMSE, MAE, or MAPE.
o Visualize the predictions against the actual values to assess performance.
e. Forecasting:
o Use the trained model to predict future values by feeding it the most recent sequence of data.
Longshort-term memory (LSTM) model
LSTM (Long Short-Term Memory) is a specialized type of Recurrent Neural Network (RNN) that is
capable of learning long-term dependencies. It was introduced by Hochreiter & Schmidhuber in 1997 to
address the vanishing gradient problem encountered by traditional RNNs. LSTM achieves this by using
gates that regulate the flow of information in the network (Brown et al. 2023).
Moreover, the LSTMs are highly effective for tasks involving sequential data, such as time series
forecasting, natural language processing (NLP), speech recognition, and more (Zeroual et al. 2020).
Furthermore, Figure 1 shows a complete diagram of LSTM, similar to Figure1 with RNN. The LSTM has
four components: input gates, forget gate, cell state, and output gate.
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
87
Figure 1. Schematic diagram of LSTM model
o Input Gate (r
t
) &Candidate Cell State(d
t
):The input gate decides which new information to store in
the cell state:

󰇟

󰇠
(7)
The candidate cell state represents the new information that could be added to the cell state.

󰇛
󰇟

󰇠
󰇜

(8)
o Forget Gate: The forget gate decides how much of the previous memory should be discarded from
the cell state:
󰇛
󰇟

󰇠
󰇜
(9)
When: σ = Sigmoid function that outputs values between 0 and 1 (0 means “forget” and 1 means
“retain”).
o Cell State Update: The new cell state is updated based on the forget gate and input gate decisions:

(10)
The forget gate C
t
scales the previous cell state C
t−1
, and the input gate r
t
scales the candidate cell
state d
t
.
o Output gate: The output gate controls what part of the cell state to output as the next hidden state h
t
:
󰇛
󰇟

󰇠
󰇜
(11)

(12)
The output gate decides how much of the cell state should be passed to the next time step.
Performance Metrics
Table below summarizing the key risk-adjusted performance metrics in portfolio optimization: Sharpe
Ratio, Sortino Ratio, Variance (Var), and Conditional Value at Risk (CVaR). Moreover, this table highlights
how these metrics are used in portfolio optimization to balance risk and return, such as purpose in
optimization and interpretation of results.
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
88
Table 2. Key risk-adjusted performance metrics in portfolio optimization
Metric
Formula
Purpose in Optimization
Interpretation
Sharpe Ratio

󰇟
󰇠
Maximize risk-adjusted
return relative to a risk-free
rate
Higher values indicate
better risk-adjusted
performance.
Sortino Ratio

󰇟
󰇠

Maximize risk-adjusted
return, focusing only on
downside risk.
Higher values indicate
better performance
with less downside
risk.
Variance
(Var)

󰇛
󰇜



Minimize the dispersion of
returns around the mean
(reduce volatility).
Lower variance
indicates less risk and
more stable returns.
Conditional
Value at Risk
(CVaR)


󰇛
󰇜



Minimize the average loss
in the worst α% of cases
(reduce tail risk).
Lower CVaR
indicates less exposure
to extreme losses.
Source: Prigent (2007).
RESULTS AND ANALYSIS
Data description
This study constructs an optimal investment portfolio for high-frequency, high-risk cryptocurrency
markets by conducting a comparative analysis between traditional Markowitz mean-variance optimization
and advanced deep learning models. By evaluating their performance across key metrics—such as risk-
adjusted returns, volatility resilience, and scalability—we aim to identify the most effective strategy for
algorithmic cryptocurrency trading. Our findings will provide actionable insights for quantitative investors,
hedge funds, and automated trading systems operating in ultra-volatile digital asset environments.
Therefore, The study was applied to real data of time series of daily prices of a financial portfolio
consisting of twenty-five (25) cryptocurrencies with high market values and the most traded in the market,
during the period between (08/15/2021-08/16/2024) at 1093 observations based on the database of the
website: https://finance.yahoo.com/crypto/ and Python programming. However, the following figure
shows the development of the returns of the portfolio assets during the study period.
Source: based on python code github/https://github.com/dimasthoriq/DL-portfolio
optimization/blob/main/experiment.ipynb/ Yahoo, https://finance.yahoo.com/markets/crypto/all
Figure 2. The returns of cryptocurrency portfolio assets
The cryptocurrency market witnessed many fluctuations during the study period, especially with the
beginning of the Covid-19 crisis, which was a difficult and harsh year, until 2022, when cryptocurrencies
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
89
faced more than one dilemma that caused them to face the largest wave of losses since the Corona crisis.
The losses are not only due to the return of central banks around the world to warn against this market,
which has no controls yet. But with central banks moving to tighten monetary policy and raise US interest
rates to high levels, 2022 witnessed a mass wave of investors fleeing risky asset markets, including "crypto"
and stocks, to hold the US dollar. Due to the waves of mass exodus of investors, some platforms failed to
return customers' dues, which is what happened with the "FTX" platform, which declared bankruptcy and
is currently being investigated, and its CEO is scheduled to appear before an investigation committee in the
US Congress. In terms of trading during 2022, the combined market value of cryptocurrencies fell by 614
percent, losing about $1,340 billion after their total value fell from $2,182.5 billion at the beginning of the
year’s trading to about $842.5 billion at the end. During 2023, the market value of cryptocurrencies witnessed
mixed developments, as the total market value of cryptocurrencies increased from about $800 billion at the
beginning of the year to nearly $1.1 trillion by the end of 2023, an increase of 37.5%. Bitcoin (BTC)
maintained its position as the largest cryptocurrency in terms of market value, reaching $450 billion by the
end of the year, followed by Ethereum (ETH), which came in second place with a market value of $300
billion. Thus, the gap between Bitcoin and Ethereum narrowed during the year, as it was about $250 billion
at the beginning of 2023 and decreased to $150 billion by the end of the year. Other cryptocurrencies such
as Ripple (XRP) and Coin Lite (LTC) recorded growth in their market value, but at lower rates than Bitcoin
and Ethereum. In general, the cryptocurrency market witnessed a remarkable growth in total market value
during 2023, with Bitcoin and Ethereum dominating the sector. The analysis of these fluctuations is linked
to several reasons, including the occurrence of many fraud operations through cryptocurrencies, which led
to tarnishing their reputation.
Moreover, the occurrence of more than one hacking operation on cryptocurrency platforms. The
declaration of bankruptcy by some platforms, the most famous of which was the largest platform, FTX,
which was declared bankrupt.
Furthermore, the exit of cryptocurrency platforms and their cessation in some major countries due to
tightening restrictions and their move to other less powerful markets. The rules and laws began to be
tightened more in some countries, perhaps the most prominent of which is the United States of America,
which was the opposite of the year 2022. Some political unrest and geopolitical factors around the world
also boosted the rise in the price of Bitcoin in particular, which recorded record increases exceeding 100
percent (but it has not reached peak levels yet), which analysts attributed to technical and economic effects,
in addition to the impact of recent geopolitical tensions (the Russian-Ukrainian war - and the war on Gaza),
so that its price exceeded forty thousand dollars. In 2024, cryptocurrency markets are witnessing a noticeable
decline during today's trading, with the prices of many major digital currencies declining. Bitcoin, the largest
cryptocurrency by market value, recorded a 0.83% decline to reach $64.8 thousand, after approaching the
$70,000 barrier in the past weeks. Ethereum was not immune to these declines, as it fell by 0.80% to reach
$3,514, and other currencies such as Tether, BNB, and Solana also declined by varying percentages, as these
currencies fell by 0.04%, 0.49%, and 0.68% respectively, reflecting a general downward trend in the market
until August.
Broadly, the period from 2021 to 2024 has been marked by extreme volatility and varying returns in
the cryptocurrency market. Understanding these dynamics is crucial for effective portfolio management and
optimization strategies. Investors should continuously monitor market conditions and adjust their strategies
accordingly.
Application of the MPT model
Before applying the Mean-variance model and finding the optimal portfolio weights as well as the
return and risk of the investment portfolio, we calculated the model inputs for the cryptocurrency prices to
be invested in, including calculating the returns and standard deviation and extracting the variance-
covariance matrix that gives us an idea of the effectiveness of diversification in maximizing the objective
function as shown in the tables below:
o Download study data using Jupyter Notebook:
Using yfinance in Jupyter Notebook, you can easily download financial data from Yahoo Finance
for analysis. This approach is particularly useful for portfolio optimization studies, where you need historical
price data, returns, and other financial metrics. By automating the data download process and organizing
your data efficiently, you can streamline your analysis workflow:
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
90
#Import Libraries
import math
importnumpy as np
import pandas as pd
importtensorflow as tf
fromtensorflow import keras
fromkeras.models import Sequential
fromkeras.layers import Dense
fromkeras.layers import LSTM
importmatplotlib as mpl
importmatplotlib.pyplot as plt
importseaborn as sns
importplotly.express as px
importplotly.graph_objects as go
import plotly.io as pio
importrandom
importos
importyfinance as yf
importdatetime
data = yf.download(dji_stocks, start=start_date, end=end_date)
stocks_df = data['Close']
[*********************100%%**********************] 25 of 25 completed
Source: based on python code github/https://github.com/dimasthoriq/DL-portfolio-
optimization/blob/main/experiment.ipynb
o Heatmap Correlation Matrix
A heatmap of the correlation matrix (appendix 1) is a valuable tool for portfolio optimization. It helps
investors identify diversification opportunities, manage risk, and make informed decisions about asset
allocation. By combining this visualization with tools like Modern Portfolio Theory (MPT) or Deep
Learning (DL), you can build robust and efficient portfolios (Figure 6).
fig = px.imshow(returns_df.iloc[:,0:25].corr(), text_auto=True, aspect="auto",title='Correlation Heatmap')
fig.write_image("correlation_Heatmap.png")
fig.write_html("correlation_Heatmap.html")
fig.show()
The table below summarizes the statistical characteristics of the MPT framework allows for effective
risk-return trade-offs, enabling investors to construct optimized portfolios tailored to their investment goals.
Understanding these metrics is crucial for effective portfolio management and decision-making.
Table 3. Characteristics of Statistics for MPT optimization
STOCKS
P-Weights
(Cvar)
P-Weights
(Sortino)
P-Weights
(Variance)
P-Weights
(Sharpe)
ADA-USD
0
0
0
0
BNB-USD
0
0
0
0
BTC-USD
0
0
0
0
DAI-USD
0
0
0
0
DOGE-USD
0
0
0
0
ETH-USD
0
0
0
0
LINK-USD
0
0
24.09
4.21
LTC-USD
0
0
0
0
USDT-USD
0
0
0
0
XRP-USD
0
0
0
0
XLM-USD
0
0.67
0.08
40.03
BCH-USD
0
0
0
0
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
91
STOCKS
P-Weights
(Cvar)
P-Weights
(Sortino)
P-Weights
(Variance)
P-Weights
(Sharpe)
WETH-USD
0
0
0
0
WBTC-USD
0
0
0
0
AVAX-USD
0
0.2
0
16.39
SHIB-USD
0
0
0
22.9
DOT-USD
0
0
0
0
LEO-USD
15.38
0.86
25
4.78
SOL-USD
43.79
0
25.4
4.69
USDC-USD
0.24
0.2
0
0
STETH-USD
40.58
98.07
25.42
7.01
AAVE-USD
0
0
0
0
VUSDT-USD
0
0
0
0
RARE11294-USD
0
0
0
0
VBTC-USD
0
0
0
0
Annualized Return
0.39
1.26
0.27
31.15
Annualized
Volatility
0.47
0.63
0.96
39.05
Skewness
-16.88
-29.22
-245.2
65.63
Kurtosis
2905.05
3066.74
20780.99
678.6
Max Drawdown
-0.34
-0.55
-1.19
-59.42
Count Data
1093.00
1093.00
1093
1093
Sharpe Ratio
0,8331
2.0032
0.2781
0.7978
CVaR
1.16
2.29
1.84
95.38
Sortino Ratio
100.42
257.00
29.22
122.77
Variance
0.00
0
0.01
15.25
Source: based on python code github/ https://github.com/dimasthoriq/DL-portfolio
optimization/blob/main/experiment.ipynb
This study investigates the optimal relative weights derived from the Markowitz Mean-Variance
model, focusing on a comprehensive summary of statistical characteristics for each optimal portfolio. We
implemented various strategies to enhance the objective function, utilizing performance evaluation
indicators such as the Sharpe Ratio, Sortino Ratio, variance, and Conditional Value at Risk (CVaR). The
analysis highlights the benefits of Markowitz diversification in managing risk through an examination of the
correlation matrix between the returns of the portfolio's assets (Zaki 2021). Furthermore, we compare the
performance of these traditional optimization approaches with those derived from deep learning algorithms
(DL). By assessing the strengths and weaknesses of both methodologies, this research aims to provide
insights into the effectiveness of deep learning in enhancing portfolio optimization, ultimately contributing
to more robust investment strategies in an increasingly complex financial environment (Yifu et al. 2024).
Application of the deep learning (DL) models
In order to create this type of portfolio, which consists of assets with different risk levels, a
comprehensive analysis was conducted. Unlike previous portfolios that were created based on historical data
only, this portfolio will leverage the predictions of the LSTM model to predict the optimal combination of
assets that will generate the highest returns over 5, 10, 15, and 30 days. The process followed to build this
diversified portfolio involves a series of sequential steps. The figure below illustrates and summarizes the
general approach taken to create the model (Li and Liu 2023).
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
92
Figure 3. Portfolio Construction Process
Therefore, splitting the data into training and testing or splitting it into training, validation, and testing
is common in supervised machine learning projects (Espiga-Fernández et al. 2025) The training set is used
to fit and train the model while the test set is used to evaluate the trained model to get a better idea of how
well the model will perform on new data and how it will behave in a production environment. Therefore,
the test data should be similar to what is expected to be seen in a production environment. Another common
splitting technique is splitting the data into three datasets: training, validation, and testing. The validation
dataset will be used to choose the best hyperparameters for each model (Ketkar et al. 2021):
n = len(returns_df)
# Split the data
train_data = returns_df[:int(0.8*len(returns_df))]
val_data = returns_df[int(0.8*len(returns_df)):int(0.2*len(returns_df))]
test_data = returns_df[int(0.2*len(returns_df)):]
train_data.shape, val_data.shape, test_data.shape
((874, 25), (0, 25), (875, 25))
We proceeded to build an LSTM model algorithm. To build the RNN to accurately predict the returns
of cryptocurrencies and from there build an optimal portfolio based on return and risk and evaluate its
performance using the Sharpe ratio, some modules had to be imported from Keras. After that, an LSTM
layer and other dropout layers were added. Regarding the LSTM layer, the dimensions of the output space
were set to 50 units. 20% of the layer was selected to be dropped and a dense layer with a single unit output
was added. Adam was chosen as the optimizer for the model clustering and the loss was set to be the mean
square error (MSE). After that, the model was fit to 100 epochs, a batch size of 32, a learning rate of 0.001,
and a neural network of 200 cells (Nafia et al.2023):
#Model 1 (5-day window)
model1 = tf.keras.models.Sequential([
LSTM(64, return_sequences=True, input_shape=(5, stocks_df.shape[1])),
LSTM(32, return_sequences=True),
Dense(units=stocks_df.shape[1])])
history1 = compile_and_fit(model1, window1.train_ds, window1.val_ds)
perf_v=}{
perf= }{
perf_v['5 days'] = model1.evaluate(window1.val_ds)
perf['5 days'] = model1.evaluate(window1.test_ds, verbose=0)
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
93
Table 4.The effectiveness of LSTM models for predicting optimal portfolio returns
Validation Performance
Test Performance
Time
Date
Loss
MAE
Loss
MAE
Epochs/Time
5 days
0,0016
0,0230
0,0012
0,0218
14/14--1s 29ms/step
10 days
0,0016
0,0233
0,0011
0,0219
13/13--1s 42ms/step
15 days
0,0017
0,0246
0,0012
0,0222
12/12--2s 110ms/step
30 days
0,0018
0,0255
0,0012
0,0228
10/10--0s 4ms/step
Source: based on python code github/ https://github.com/dimasthoriq/DL-portfolio-
optimization/blob/main/experiment.ipynb
We noted from the outputs of the application of the LSTM model to predict the returns of the
cryptocurrencies that make up the portfolio assets, (Junhuan et al. 2024) where we note the superiority of
the LSTM model in predicting for 5 days to the last day in the series of subsequent returns with the lowest
mean square error rate estimated at 0.0218 for the test (Test_loss) and 0.0230 for the verification (Val_loss).
Thus, the algorithm of this model can be adopted to estimate the optimal portfolio and extract the ratios for
financial investments in the cryptocurrency assets that make up the investment portfolio, and then compare
them to the space of previous solutions for the Markowitz model and trying to compare them based on the
Sharpe index to evaluate the quality of the performance of the extracted portfolio (Das et al. 2024).
o The Efficient Frontier of cryptocurrency optimal portfolio
# Plot efficient forntier and our portfolio
fig = go.Figure()
fig.add_trace(go.Scatter(x=portfolio_volatilities,y=portfolio_returns,mode='markers',marker=dict(size=5,c
olor='blue',opacity=0.5),name='Random Portfolios'))
fig.add_trace(go.Scatter(x=[sigma],y=[portfolio_return],mode='markers',marker=dict(size=6,color='red',s
ymbol='x'),name='Calculated Portfolio'))
fig.update_layout(title='EfficientFrontier',xaxis_title='Risk',yaxis_title='Return',showlegend=True,hoverm
ode='closest')
fig.write_image("efficient_forntier.png")
fig.write_html("efficient_forntier.html")
fig.show()
Source: based on python code github/ https://github.com/dimasthoriq/DL-portfolio-
optimization/blob/main/experiment.ipynb
Figure 4. Efficient frontier
RESULTS AND DISCUSSION
Through the previous simulation of time series of cryptocurrency returns using one of the traditional
behavioral finance models (Markowitz model) and deep learning models using the LSTM algorithm based
on the Sharpe index in evaluating the quality of the solution (optimal portfolio performance), (Tamuly et al.
2024).the outputs of the comparative study were summarized in the following table:
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
94
Table 5. The performance comparison of MPT-LSTM Models
STOCKS
P-Weights(Sharpe)
P-Weights(LSTM)
ADA-USD
0
0.014606
BNB-USD
0
-0.05918
BTC-USD
0
-1.44428
DAI-USD
0
-4.74505
DOGE-USD
0
4.70012e-05
ETH-USD
0
2.26891
LINK-USD
4.21
0.0689542
LTC-USD
0
0.0518116
USDT-USD
0
0.57744
XRP-USD
0
0.0210249
XLM-USD
40.03
-0.0330404
BCH-USD
0
-0.035509
WETH-USD
0
-2.70253
WBTC-USD
0
1.41132
AVAX-USD
16.39
0.00331112
SHIB-USD
22.9
0.00729518
DOT-USD
0
-0.0759262
LEO-USD
4.78
0.0481682
SOL-USD
4.69
0.033132
USDC-USD
0
-0.315186
STETH-USD
7.01
0.443353
AAVE-USD
0
0.0234812
VUSDT-USD
0
5.36088
RARE11294-USD
0
0.00904898
VBTC-USD
0
0.0679007
Annualized Return
31.15
0.017239
Annualized Volatility
39.05
0.011219
Count Data
1093
1093
Sharpe Ratio
0.7978
1.5365
Source: based on python code github/ https://github.com/dimasthoriq/DL-portfolio-
optimization/blob/main/experiment.ipynb
Source: based on python code github/ https://github.com/dimasthoriq/DL-portfolio-
optimization/blob/main/experiment.ipynb
Figure 5. Cumulative returns comparison of crypto10 vs LSTM
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
95
Through the results shown above and according to the distribution of optimal weights for the
investor's expected investments during the year 2024 AD for the next 5 days, we note the effectiveness of the
deep learning model using the LSTM algorithm (Alzaman 2024) with an expected rate of return for the
optimal portfolio estimated at: 1.7239%, the highest and lowest risk level estimated at 1.1219% compared to
the outputs of the Markowitz model, which estimated the rate of return for the optimal portfolio at 31.15%,
and a relatively higher risk rate estimated at 39.05%. The results confirm the validity of the second
hypothesis, which states that deep learning algorithms can benefit better from the investment diversification
method. As for the Markowitz portfolio weights, investment in most cryptocurrencies was not employed
and only seven (7) were used, namely LINK-USD, XLM-USD, AVAX-USD, LEO-USD, SOL-USD,
STETH-USD, due to the limited operation of the model-based on the correlation coefficient and generating
a limited number of possible portfolios, which achieved an average Sharpe index that is not motivating for
investment according to the selected portfolio, estimated at 0.7978%. In contrast, the deep learning model
that trains a large number of predicted portfolios gave an excellent Sharpe index estimated at 1.5365% for
the performance of the selected optimal portfolio. This means that this may be an ideal investment decision.
While adding a new asset class to the portfolio increases risk, the sharply higher ratio indicates that it is a
risk worth taking. The high risk of cryptocurrency price fluctuations can also be explained by the global
conditions that the world has gone through, especially since the study period coincided with the
repercussions of the Corona pandemic (Covid-19) and political factors (the US elections) and geopolitical
factors (the Ukraine war, the war on Gaza), where cryptocurrency trading platforms experienced several
collapses due to investors' fears for their assets. However, the results of the study remain relative, especially
in the field of deep learning, which raises the issue of the transparency of big data that depends on its training
in the field of making investment decisions in financial markets, with the possibility of changing the basic
parameters in building the LSTM model to reduce errors and even the possibility of adding GRU and Bilstm
algorithms in future studies to increase the power of deep learning in the investment process in high-risk
markets (the cryptocurrency market) while increasing the number of observations to become big data that
helps in training and testing (Xu et al. 2025).
CONCLUSION
This study has highlighted the transformative potential of deep learning techniques in the realm of
cryptocurrency portfolio optimization. Traditional methods often fall short in capturing the inherent
complexities and non-linear dynamics of cryptocurrency markets. Deep learning approaches, including
neural networks and reinforcement learning, demonstrate a superior ability to model intricate relationships
among assets, leading to enhanced predictive accuracy and improved risk-adjusted returns.
The review also underscored the importance of data preprocessing, feature selection, and the
evaluation of model performance metrics, which are critical for effective implementation. Despite the
promising results, several gaps remain in the literature, particularly concerning the interpretability of deep
learning models and their adaptability to changing market conditions.
Therefore, future research should focus on integrating macroeconomic factors and exploring hybrid
models (Das et al. 2024) that combine traditional financial theories with advanced machine learning
techniques. Additionally, empirical studies assessing the long-term performance of deep learning-based
portfolios could provide valuable insights. Ultimately, leveraging deep learning in cryptocurrency portfolio
optimization represents a significant advancement in investment strategies, offering a more nuanced
approach to navigating the complexities of modern financial markets
However, the integration of Long Short-Term Memory (LSTM) neural networks with MPT for
cryptocurrency portfolio optimization presents a compelling solution to these challenges. LSTM, a deep
learning model designed for sequential data, can effectively capture the time-series dependencies inherent in
cryptocurrency prices, which fluctuate based on factors like market sentiment, regulatory news, and
macroeconomic trends. When combined with MPT, LSTM can address many of the limitations of
traditional portfolio optimization methods by incorporating dynamic forecasting, non-linear relationships,
and the ability to adapt to changing market conditions.
Furthermore, based on current results, future research can anticipate substantial performance
enhancements by further optimizing the parameters of deep learning models. Fine-tuning these parameters
is expected to increase the accuracy of predictions and overall portfolio performance. Additionally, exploring
hybrid approaches that combine deep learning with traditional financial models could yield new insights
and strategies for effective portfolio management.
Finally, as the cryptocurrency landscape continues to evolve, continued investment in developing
robust, data-driven optimization techniques will be essential for navigating its inherent volatility and
complexity. This ongoing exploration promises to advance both theoretical frameworks and practical
applications in the field of finance.
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
96
REFERENCES
Alzaman, C. 2024. Deep learning in stock portfolio selection and predictions, Expert Systems with Applications,
237(Part B): 121404, https://doi.org/10.1016/j.eswa.2023.121404.
Cui, T., S. Ding, H. Jin, and Y. Zhang. 2023, Portfolio constructions in cryptocurrency market: A CVaR-based deep
reinforcement learning approach. Economic Modelling, 119, 106078,
https://doi.org/10.1016/j.econmod.2022.106078.
Das, J. D., S. Bowala, R. Thulasiram, and A. Thavaneswaran. 2024. Hybrid Data-Driven and Deep Learning
Based Portfolio Optimization. Journal of Mathematical Finance, 14(3): 271-310.
https://doi.org/10.4236/jmf.2024.143016.
Durall, R. 2022. Asset Allocation: From Markowitz to Deep Reinforcement Learning (June 28, 2022). Available at
SSRN: https://ssrn.com/abstract=4148379.
Espiga-Fernández, F., A. García-Sánchez, and J. Ordieres-Meré. 2025. gymfolio: A Reinforcement learning
environment for Portfolio Optimization in Python. SoftwareX Journal, 30(2):1-9,
https://doi.org/10.1016/j.softx.2025.102106.
Heydarpour, M., H. Ghanbari, E. Mohammadi, and S. Shavvalpour. 2024. Robust Portfolio Optimization using
LSTM-based Stock and Cryptocurrency Price Prediction: An Application of Algorithmic Trading
Strategies; Iranian Journal of Accounting, Auditing and Finance, Articles in Press, Accepted
Manuscript, Available Online from 01 December 2024. https://ijaaf.um.ac.ir/article_46039.html.
Ibri, S., and M. Slimane. 2022. Probability Stochastic Processes and Simulation In Python. Book, Algeria.
https://www.researchgate.net/publication/360767027.
Junhuan, Z., C. Kewei, and W. Jiaqi. 2024. A survey of deep learning applications in cryptocurrency.
iScience Review, 27(1):1-40, 19 January, 108509 , https://doi.org/10.1016/j.isci.2023.108509.
Ketkar, N. and J. Moolayil. 2021. Learning with python: Learn Best Practices of Deep Learning Models with
PyTorch, Bangalore, Karnataka, India.
Li, H., and T. Liu. 2023. Portfolio Optimization Based on the LSTM Forecasting Model. Proceedings of the
2nd International Conference on Financial Technology and Business Analysis, 48(1): 97-106.
https://doi.org/10.54254/2754-1169/48/20230431.
Nafia, A., A. Yousfi, and A. Echaoui. 2023. Equity-Market-Neutral Strategy Portfolio Construction Using
LSTM-Based Stock Prediction and Selection: An Application to S&P500 Consumer Staples Stocks.
International Journal of Financial Studies, 11(2): 57. https://doi.org/10.3390/ijfs11020057.
Prigent, J.-L. 2007. Portfolio Optimization and Performance Analysis. Book, Financial Mathematics Series,
Chapman & Hall/CRC is an imprint of Taylor & Francis Group, U.S, 70-78.
Sebastian, A., and V. Tantia. 2024. Deep Learning for Stock Price Prediction and Portfolio Optimization.
International Journal of Advanced Computer Science and Applications, 15(9):926-941.
Tamuly, A., G. Bhutan, and Sukriti. 2024. Portfolio Optimization using Deep Reinforcement Learning. IEEE 5th
India Council International Subsections Conference (INDISCON), Chandigarh, India, 1-6, DOI:
10.1109/INDISCON62179.2024.10744403.
Xiong, Z., M. Li, and Y. Xu. 2022, LSTM-MPT Based Quantitative Portfolio Decision Model, International
Symposium on Intelligent Robotics and Systems (ISoIRS), IEEE, China,
https://doi.org/10.1109/ISoIRS57349.2022.00035.
Xu, Z., X. Zhang, and Z. Zhou. 2025. Cryptocurrency Portfolio Optimisation Based on LSTM Time Series
Forecasting. Applied and Computational Engineering, 134(1):144-151, https://doi.org/10.54254/2755-
2721/2025.22255.
Yahoo. https://finance.yahoo.com/markets/crypto/all/ (15.05.2025).
Yifu, J., J. Olmo, and M. Atwi. 2024. Deep reinforcement learning for portfolio selection. Global Finance
Journal, 62(4): 01-15, https://doi.org/10.1016/j.gfj.2024.101016.
Yu, M. 2023. Mean-variance Portfolio Optimization by LSTM-based Predictions. Advances in Economics
Management and Political Sciences, 61(1):102-109. https://doi.org/10.54254/2754-1169/61/20231061.
Zaki, S. 2021. A Deep Learning Portfolio Optimization Framework Using Cryptocurrencies. Master thesis, school
of science & engineering – al akhawayn university, Morocco.
Zeroual, A., F. Harrou, A. Dair, and Y. Sun. 2020. Deep Learning Methods for Forecasting COVID-19
Time-Series Data: A Comparative Study. Chaos, Solitons & Fractals, 140: 110121. DOI:
10.1016/j.chaos.2020.110121.
Zhang, Y., S. Yongbin, L. Weilong and Y. Xingyu. 2025. Portfolio Optimization with Lstm-Based Return and
Risk Information. Available at SSRN: https://ssrn.com/abstract=4215299 or
http://dx.doi.org/10.2139/ssrn.4215299 .
Zhang, Z., S. Zohren, and S. Roberts. 2020. Deep Learning for Portfolio Optimization. The Journal of
Financial Data Science, 2(4): 8-20. https://doi.org/10.3905/jfds.2020.1.042.
Habib Zouaoui, Meryem-Nadjat Naas / Finance, Accounting and Business Analysis, Volume 7, Issue 1, 2025
97
Zouaoui, H., and M. N. Naas. 2021. Loans Portfolio Optimization of Commercial Banks using Genetic
Algorithm: A Case Study of Saudi Arabia. International Journal of Banking, Risk and Insurance, 9(1): 20-
27.
Zouaoui, H., and M. N. Naas. 2023. Option pricing using deep learning approach based on LSTM-GRU
neural networks: Case of London stock exchange. Data Science in Finance and Economics, 3(3): 267–
284. https://doi.org/10.3934/DSFE.2023016.
98
APPENDIX 1
Source: based on python code github/https://github.com/dimasthoriq/DL-portfolio-optimization/blob/main/experiment.ipynb
Figure 6.Heatmap of the correlations matrix