0% found this document useful (0 votes)
17 views

Gold-Bitcoin Trading Strategy Based On Time Series

This document discusses developing an ARIMA time series model and trading strategy to predict daily gold and bitcoin prices and help traders optimize trading of these assets. It describes building an ARIMA model to forecast prices based on previous data, plotting original and predicted price graphs, and modeling a trading strategy based on daily price increases.

Uploaded by

Kherrati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Gold-Bitcoin Trading Strategy Based On Time Series

This document discusses developing an ARIMA time series model and trading strategy to predict daily gold and bitcoin prices and help traders optimize trading of these assets. It describes building an ARIMA model to forecast prices based on previous data, plotting original and predicted price graphs, and modeling a trading strategy based on daily price increases.

Uploaded by

Kherrati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Highlights in Science, Engineering and Technology ISET 2023

Volume 68 (2023)

Gold-Bitcoin Trading Strategy Based on Time Series Modeling


Diancheng Song 1, *, &, Xiaolu Tao 2, & and Qijing Chen 3, &
1 Faculty of Science, Wuhan University of Science and Technology, Wuhan, China
2 School of Public Policy and Management, Northwestern Polytechnical University, Xian, China
3 Xulun Academy, Shanghai Lixin University of Accounting and Finance, Shanghai, China
* Corresponding Author Email: [email protected]
&These authors contributed equally to this work
Abstract. Market traders often earn income by buying and selling assets through market
transactions with the goal of maximizing total returns. Since each asset purchased has a certain
amount of gain and loss, traders need to develop a trading strategy, which may affect their total profit.
In the case of gold and bitcoin, this paper develops an ARIMA daily price forecasting model and a
trade strategy model based on price increases to help market traders develop optimal trading
strategies for gold and bitcoin.
Keywords: ARIMA; Gold; Bitcoin; Trading Strategies.

1. Introduction
With the prevalence of globalization in the world economy, various economic problems in market
trading have become a stumbling block to the economic development of the world today. In the
process of market trading, stocks are commonly sought after by market traders. As a kind of securities,
stocks can be transferred, bought and sold, and are a long-term credit instrument in the trade market.
The goal of the market trader is to maximize profits through various means, the most common of
which are buying and selling, where there are commission returns and losses. Gold and Bitcoin are
two such assets [1].
We were given data on the price of gold and bitcoin (USD) from November 9, 2016, to October 9,
2021. On each trading day, a trader will have a portfolio consisting of cash, gold, and bitcoin [C, G,
B] in USD, troy ounces, and bitcoin, respectively. The initial state is [1000, 0, 0]. The commission
for each transaction (purchase or sale) is α% of the transaction amount. Assume = 1% and = 2%.
There is no cost to hold the asset. Notice that Bitcoin can be traded daily, while gold can only be
traded on open days (Monday through Friday). In this paper, we will develop a mathematical model
that uses only past daily prices to determine whether a trader should buy or sell an asset in his or her
portfolio. The best trading strategy for each day will then be given based on the price data up to that
day [2].

2. Daily price prediction model based on ARIMA


To forecast the stock prices of gold and bitcoin for the current day through the previous day's data,
we built a Daily Price Prediction Model for prediction and fitting based on the ARIMA model. After
checking its reasonableness, we can predict the price of the day as required by the question based on
this model [3].
To meet the needs of the ADF Test, a minimum of 10 samples per prediction is required to meet
the number of valid samples in the ARIMA Model. To meet the test needs and the validity of the test,
we chose to start predicting the data from day 25 based on the results after our testing.
Based on the above reasoning, we make the following steps:
(1) We collect data on the market value of Bitcoin and gold in the first 25 days.
(2) Then we sequentially use the ARIMA Model on n(n  25) day to predict the data from
day n + 1 to n + 3 :

73
Highlights in Science, Engineering and Technology ISET 2023
Volume 68 (2023)

Pt (t = 1, 2,3..., n) (1)
based on the data from day 1 today n :
Pt (t = n + 1, n + 2, n + 3) (2)
(3) Convert time and date of gold value data and bitcoin value data into time series values using
the Date Conversion Function (The principle of the function is shown in Figure 1);

Fig. 1 The principle of Date Conversion Time Series Function


(4) Perform differential smoothing time series: We test whether Pt (t = 1, 2,3..., n) is smoothed by
using ADF Test and KPSS Test [4];
1) For the ADF Test, a value of 0 for  is equivalent to unstable and a value of 1 for  is
equivalent to stable. For the KPSS Test, a value of 1 for  is equivalent to unstable and a value of
0 for  is equivalent to stable.
① Auto-regressive process with no drift term:
k
Pt =   Pt −1 +  Ci  Pt −i +  t , (t = 1, 2,..., n), P0 = 0 (3)
i =1

② Auto-regressive process with drift term:


k
Pt =  +   Pt −1 +  Ci  Pt −i +  t , (t = 1, 2,..., n), P0 = 0 (4)
i =1

③ Auto-regressive process with drift and trend terms:


k
Pt =  +   t +   Pt −1 +  Ci  Pt −i +  t , (t = 1, 2,..., n), P0 = 0 (5)
i =1

(  is a constant term,  t is a time trend term, and  t is a random perturbation term)


We conclude that Pt (t = 1, 2,3..., n) is not smoothed using the double test method. Then we
perform the difference to it by using the difference function (the Diff Function). The difference
equation is:
f ( xk ) = f ( xk +1 ) − f ( xk −1 ) (6)

Then the differential data is:

74
Highlights in Science, Engineering and Technology ISET 2023
Volume 68 (2023)

d Pt (t = 1, 2,3..., n) (7)
2) After performing the difference once, we conclude that this time series has been smoothed by
performing the ADF Test and the KPSS Test again. Then the number of differences is derived:
d =1 (8)
(5) To carry out the fixed order of the model: we use PACF (partial auto-correlation function) for
auto-regression on the time series after being performed the difference (linear regression). The
regression equation is:
1 Pt = c + 1  1 Pt −1 + 2  1 Pt − 2 + ... +  p  1 Pt − p +  t (9)

( 1 P is the observation at moment Yt of the time series, t is the coefficient obtained by


optimizing the model on the training data, t is the residual at the moment t , and c is the constant
term of the model)
(6) We perform a moving average of the time series using the ACF (auto-correlation function).
The formula is:
1 Pt = c +  t + 1   t −1 +  2   t − 2 + ... +  q   t − q (10)

(7) The auto-regressive moving average model is obtained. The formula is:
1 Pt = c + 1  1 Pt −1 + 2  1 Pt − 2 + ... +  p  1 Pt − p +  t + 1   t −1 +  2   t − 2 + ... +  q   t −q (11)

Then we can derive the values of p and q simultaneously.


(8) Use the iddata function to convert the data into data that can be recognized by the armax
function, and then use the armax function to find out the value of AIC. The formula for calculating
the AIC criterion is as follows:
AIC = 2  (Number of parameters in the model) − 2 ln The great approximation function
(12)
of the model
(9) We choose the model with the minimum value of AIC and then perform the prediction of order
d. Finally, we then perform a reduced difference and use the prediction trend to return the results from
day 1 to day 2 of the prediction, taking the results of day 2 as the value of the prediction graph.

3. Daily Price Forecast


3.1. Gold price
Based on the ARIMA model, we improved on it to derive the Daily Price Prediction Model. Based
on the analysis, filtering and modification of the error values, we derived the daily price prediction
data of gold, and then we used MATLAB software to plot the original and predicted images of gold
price, as shown in Figures 2 and 3:

Fig. 2 The Given Image of Gold Fig. 3 The Predicted Image of Gold

75
Highlights in Science, Engineering and Technology ISET 2023
Volume 68 (2023)

3.2. Bitcoin price


Based on the ARIMA model, we improved on it to derive the Daily Price Prediction Model. Based
on the analysis, filtering and modification of the error values, we derived the daily price prediction
data of bitcoin, and then we used MATLAB software to plot the original and predicted images of
bitcoin price, as shown in Figures 4 and 5:

Fig. 4 The Given Image of Bitcoin Fig. 5 The Predicted Image of Bitcoin

4. Best Trading Strategies


Based on the movement of the price increase, we modeled the trading strategy on the daily gold
and bitcoin price increases to come up with the best trade strategy [5]. The model is as follows.
Note: Use an array d to mark the dates when the gold market is open as 1 and the dates when it is
not open as -1.
(1) In the first 25 days, we use the Equal Weight Model for decision-making. Since gold is not
open on the first day and the value of an ounce of gold is greater than the cash owned on the second
day, gold is not considered in the equal weighting model on the first day. The formula of the model
is
1 1
 i = =
n 2
(13)

1
That is, spend of the cash c to buy bitcoin on the first day.
2
The cost of buying bitcoins is.
1
cb1 = c (14)
2
The remaining cash is
c1 = 1000 − cb1 − %1 cb1 (15)
The number of bitcoins owned is
cb1
ib1 = (16)
Pb1
(2) After 25 days, at day n (n = 25, 26, 27,...1826) , based on the price data of bitcoin and gold at
day n+1, n+2, n+3 predicted by the ARIMA Model, we find the approximate slope of the increase of
bitcoin at day n for the next three days and the approximate slope of the increase of gold at day n for
the next three days according to the equation:

76
Highlights in Science, Engineering and Technology ISET 2023
Volume 68 (2023)

Pbn +1 + Pbn + 2 + Pbn +3 Pbn +1 + Pbn + 2 + Pbn +3


− Pbn − Pbn
kbn = 3 = 3 (17)
n +1+ n + 2 + n + 3 2
−n
3
Pgn +1 + Pgn + 2 + Pgn +3 Pgn +1 + Pgn + 2 + Pgn +3
− Pgn − Pgn
k gn = 3 = 3 (18)
n +1+ n + 2 + n + 3 2
−n
3
We can find the approximate slope of the rise of bitcoin on day n over the next three days kbn and
the approximate slope of the rise of gold on day n over the next three days k gn . The image of kbn
and the image of k gn are shown in Figures 6 and Figure 7.

Fig. 6 Predicted Graph of the Slope of Bitcoin's Rise

Fig. 7 Predicted Graph of the Slope of Gold's Ris


(3) There will be four cases for the slope of the rise on day n (25  n  1826) .
(4) Based on the equation:
TAn = cn + Pbn  ibn + Pgn  ign (19)
We can calculate the total assets at day n and plot a line graph, as in Figure 8.

77
Highlights in Science, Engineering and Technology ISET 2023
Volume 68 (2023)

Fig. 8 Total Assets


And we can calculate the total assets owned on the last day: $14100.48.

5. Summary
In this paper, on the one hand, an ARIMA-based daily price prediction model is developed, which
is very simple and requires only endogenous variables without resorting to other exogenous variables;
and it is more accurate in its prediction of data. However, it requires time data to be static or stable
after differencing; it can only capture linear relationships by itself but not nonlinear relationships; and
it requires a large amount of data to provide a forecasting basis for the model.
On the other hand, this paper establishes a trade strategy model based on price increase, which can
improve the accuracy of prediction based on the future slope; and it can reduce the risk value of the
decision based on the accuracy of the prediction of the previous data, making the decision more secure.
However, it relies too much on past data and requires a large amount of data to provide the model
with a basis for prediction. In this paper, it is used as a decision-making model, which is more
subjective, and the standard setting is not reasonable enough.

References
[1] Li, Zhan & Huang, Yuanda. Stock Trading Price Prediction Model Study [N]. Shanghai Jiao Tong
University Newspaper, 1992-6-26 (6).
[2] Li, Hongjie. Bitcoin - A New Kind of Gold in the Digital Age [J]. China Business Review,2018(2):33-34.
[3] Ding,Wenjuan. Comparison of ARIMA Model and LSTM Model Based on Stock Forecast [J]. Industrial
Control Computers, 2021, 34(7): 109~116.
[4] Zhao, Kangyin & Xue, Yanan. Stock Forecast and Evaluation of TCL Group Based on ARIMA Model
[J]. Hot Insights, 2020: 144~145.
[5] Huang Li-Shan. Portfolio Research Based on ARIMA and Comprehensive Evaluation Methods--Taking
Gold and Bitcoin as an Example [J]. Modern Information Technology,2022,6(23):98-102.

78

You might also like