这是用户在 2025-1-13 11:22 为 https://app.immersivetranslate.com/pdf-pro/bb71605f-3096-4d71-8a57-ca07e361518f 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?

Grid the profit: Adaptive Periodic Grid Model with ARIMA Prediction
网格带来利润采用 ARIMA 预测的自适应周期网格模型

Summary  摘要

In the financial market, higher profits and lower risks are the goals that people seek, but they are always contradictory. Therefore, researchers in the financial field are looking for more efficient and versatile quantitative trading strategies to meet the need of the market and traders. Based on this, our team establish an adaptive periodic grid model to predict the price of gold and bitcoin.
在金融市场中,较高的利润和较低的风险是人们追求的目标,但两者总是相互矛盾。因此,金融领域的研究人员一直在寻找更高效、更多变的量化交易策略,以满足市场和交易者的需求。基于此,我们的团队建立了一个自适应周期网格模型来预测黄金和比特币的价格。
First, our base model inherits a very classic trading strategy, the grid strategy. The grid strategy divides the asset into several parts and the model automatically trades when the price crosses the grid. To a certain extent, this model is as risk-averse as possible, preventing people from making bad decisions in a chaotic market. However, because the grid strategy over-diversifies risk, the rate of return is often not very high, just like a conservative investment strategy or a way of preserving the value of an asset. In this part, we analyze the property of isometric grid strategy and proportional grid strategy, then compare their profits. We conclude that the large-width isometric grid is more suitable for bitcoin and gold trading.
首先,我们的基础模型继承了一种非常经典的交易策略--网格策略。网格策略将资产分为几个部分,当价格越过网格时,模型会自动进行交易。在一定程度上,这种模型尽可能规避风险,防止人们在混乱的市场中做出错误的决定。然而,由于网格策略过度分散了风险,收益率往往并不高,就像保守的投资策略或资产保值的方法一样。在这一部分,我们将分析等距网格策略和比例网格策略的特性,然后比较它们的收益。我们的结论是,大宽度等距网格更适合比特币和黄金交易。
Next, since grid trading is too conservative and stable to satisfy our requirement for high profit, we have to make some improvements to it. From a long-term perspective, the moving average (MA), which is frequently used in stocks or futures trading, is introduced to make the model follow the overall market trend. To further improve our model, we notice the classic model, auto-regressive integrated moving average(ARIMA). ARIMA model can give a good prediction for stationary time series. Note that real market conditions do not guarantee that price changes will be stationary, but we can adjust the weight to correctly use this prediction. Considering that the market changes over time, we will periodically stop our model and perform a backtesting process to choose the best parameters for the next period. Finally, we flexibly combine these models and develop our adaptive periodic grid model, called APGM.
接下来,由于网格交易过于保守和稳定,无法满足我们对高利润的要求,因此我们必须对其进行一些改进。从长期角度来看,我们引入了股票或期货交易中经常使用的移动平均线(MA),使模型紧跟市场整体趋势。为了进一步完善我们的模型,我们注意到了经典模型--自回归整合移动平均线(ARIMA)。ARIMA 模型可以很好地预测静态时间序列。需要注意的是,实际市场情况并不能保证价格变化是静态的,但我们可以调整权重来正确使用这一预测。考虑到市场会随时间发生变化,我们会定期停止模型并执行回溯测试过程,为下一期选择最佳参数。最后,我们将这些模型灵活地结合起来,开发出我们的自适应周期网格模型,即 APGM。
After that, to prove that our model provides the best strategy, we compare it with other trading strategies. Under the recent price data of the gold market and bitcoin market specified under the problem framework, it does not have as a high profit rate as some simple strategies. However, under the perspective of risk assessment, these simple strategies have huge risks and randomness, which is inapplicable. Because our model has very good generalization ability, we consider our model to be very good when considering the factors of risk-return.
之后,为了证明我们的模型提供了最佳策略,我们将其与其他交易策略进行了比较。在问题框架下指定的黄金市场和比特币市场的近期价格数据下,它的收益率没有一些简单策略高。但是,从风险评估的角度来看,这些简单策略具有巨大的风险性和随机性,并不适用。由于我们的模型具有很好的泛化能力,因此在考虑风险收益因素时,我们认为我们的模型是非常好的。
Last but not least, we test the properties of our models from the perspective of sensitivity and robustness. Our model maintains high stability under the influence of changing transaction rates slightly and noisy price data. In the case of noisy data, the grid strategy takes advantage of the shock market and arbitrage more. In the event of a slight change in transaction rate, the model automatically switched to a larger grid and reduces transaction frequency to adapt to different environments.
最后,我们从敏感性和稳健性的角度测试了模型的特性。我们的模型在交易率略有变化和价格数据有噪声的情况下保持了很高的稳定性。在有噪声数据的情况下,网格策略会更多地利用震荡市场和套利。在交易率略有变化的情况下,模型会自动切换到更大的网格并降低交易频率,以适应不同的环境。
Keywords: grid strategy, ARIMA, time series analysis, quantitative trading, statistical test
关键词:网格策略、ARIMA、时间序列分析、量化交易、统计检验

Contents  目录

1 Introduction … 2  1 引言 ... 2
1.1 Problem Background … 2
1.1 问题背景 ... 2

1.2 Restatement of the problem … 2
1.2 问题的重述...... 2

1.3 Literature Review … 2
1.3 文献综述 ... 2

1.4 Our work & & model overview … 3
2 Assumptions … 3
2 假设 ... 3

3 Notations … 4
3 注释 ... 4

4 Vanilla Grid Strategy … 5
4 香草网格战略 ... 5

4.1 The fundamental of Grid Strategy … 5
4.2 Isometric Grid and Proportional Grid … 7
4.2 等距网格和比例网格...... 7

5 Adaptive Periodic Grid Model … 9
5 自适应周期网格模型 ... 9

5.1 ARIMA … 10
5.1 Arima ... 10

5.1.1 Model Settings of ARIMA … 10
5.1.2 ACF and PACF function - p,q selection … 10
5.1.3 q-test … 10
5.1.4 Results in ARIMA prediction … 11
5.2 APGM … 11
5.2 应用项目管理...... 11

5.3 Backtesting Process … 12
5.3 回溯测试过程 ... 12

6 Results and Comparison … 13
6 结果与比较 ... 13

6.1 Comparison with other strategies … 13
6.2 Detailed procedure and final result … 15
7 Model Evaluation … 17
7 模型评估 ... 17

7.1 Sensitivity Analysis … 17
7.1 敏感性分析 ... 17

7.2 Robustness Analysis … 18
8 Strengths and Weaknesses … 19
8.1 Strengths … 19
8.1 优势 ... 19

8.2 Weaknesses … 19
9 Conclusion … 20
10 Memorandum … 21
10 备忘录 ... 21

11 Reference … 23
11 参考资料 ... 23

12 Appendix … 24
12 附录 ... 24

1 Introduction  1 引言

Radhakrishna Rao said, “In the ultimate analysis, all knowledge in history; in the abstract sense, all science is mathematics; in a rational world, all judgment is statistically.” - Statistics and Truth [9]
拉达克里希纳-拉奥说:"从终极分析来看,历史中的一切知识;从抽象意义上来看,一切科学都是数学;从理性世界来看,一切判断都是统计学"。- 统计与真理[9]

1.1 Problem Background  1.1 问题背景

Gold has always been considered a general equivalent asset due to its scarcity and chemical stability. In recent years, with the frequent changes in the international situation, gold, due to the property of good value preservation, becomes more and more popular. At the same time, Bitcoin, as the earliest developed and largest cryptocurrency, is called “digital gold”, and blockchain technology is also popular due to its decentralization property and no need for supervision. In face of these assets, many people will try to invest personally, but their investment results are mixed. To ensure lower risk and higher profit, quantitative investment strategies have developed rapidly in recent years. Quantitative investment mainly depends on the analysis of historical data, the prediction of the market development trend, potential profit and risk in order to make a suitable decision. In the establishment of quantitative investment strategies, we usually need to find an appropriate model to replace manual prediction and decision-making.
黄金因其稀缺性和化学稳定性,一直被视为一般等价资产。近年来,随着国际形势的频繁变化,黄金因其保值性好的特性,越来越受到人们的青睐。同时,比特币作为发展最早、规模最大的加密货币,被称为 "数字黄金",区块链技术也因其去中心化、无需监管的特性而备受青睐。面对这些资产,很多人都会尝试个人投资,但投资结果却喜忧参半。为了保证较低的风险和较高的收益,量化投资策略近年来发展迅速。量化投资主要依靠对历史数据的分析,对市场发展趋势、潜在利润和风险的预测,从而做出合适的决策。在量化投资策略的建立过程中,我们通常需要找到一个合适的模型来代替人工进行预测和决策。

1.2 Restatement of the problem
1.2 问题的重述

Considering the background of the question and the limitations, we decide to focus on the following questions:
考虑到问题的背景和局限性,我们决定把重点放在以下问题上:
  • Using the officially provided dataset, develop a mathematical model to describe the price change trend and give the best daily strategy based only on price data up to the current day. In addition, the model should use the strategy which maximize the final profit as of 2021/9/10 with an initial $1000 investment.
    使用官方提供的数据集,建立一个数学模型来描述价格变化趋势,并仅根据截至当日的价格数据给出最佳每日策略。此外,该模型应使用初始投资额为 1000 美元、截至 2021/9/10 年最终利润最大化的策略。
  • Compare the performance of different trading strategies using a noisy dataset to illustrate the advantage of our model.
    使用噪声数据集比较不同交易策略的性能,以说明我们模型的优势。
  • Test our model with different transaction cost rates and compare the final results for different cost rates and evaluate the stability of our model.
    用不同的交易费率测试我们的模型,比较不同费率下的最终结果,评估模型的稳定性。
  • Write a two-page memorandum. This memorandum is used to communicate the strategy, model and results with the trader.
    撰写一份两页的备忘录。这份备忘录用于与交易员交流策略、模型和结果。

1.3 Literature Review  1.3 文献综述

In the field of quantitative trading, financial time series modeling mainly focus on the field of ARIMA(auto-regressive integrated moving average) model and some modifications to this model. The popularity of the ARIMA model is due to its statistical properties as well as the well-known Box-Jenkins methodology[2]. The work of Minyong Kim in 2015[4] showed that ARIMA provided more accurate forecasts than the back-propagation neural network, which shows the potential of quantitative trading. A huge amount of algorithm frameworks was proposed in the quantitative trading field.
在量化交易领域,金融时间序列建模主要集中在 ARIMA(自回归整合移动平均)模型领域,以及对该模型的一些修正。ARIMA模型的流行是由于其统计特性以及著名的Box-Jenkins方法[2]。Minyong Kim 在 2015 年的研究[4]表明,ARIMA 比反向传播神经网络提供了更准确的预测,这显示了量化交易的潜力。量化交易领域提出了大量算法框架。
For example, in 1999, The Technical analysis proposed by Murphy used the charts of Opening-High-Low-Closing prices (OHLC), which is one of the most commonly used traditional methods. Recently, some ML-based or DL-based quantitative models were proposed including the work of Sreelekshmy in 2017[11] and the work of Thien Hai and Nguyen in 2015[6], etc. Besides, grid strategy is a method to control the positions in the market, the potential of which remains to be tapped. Two important traditional grid strategies are the Forex Grid strategy[7] and the Gann Grid strategy[10]
例如,1999 年,墨菲提出的技术分析(The Technical analysis)使用了开盘价-高价-低价-收盘价(OHLC)图表,这是最常用的传统方法之一。最近,一些基于 ML 或 DL 的量化模型被提出,包括 Sreelekshmy 在 2017 年的工作[11]以及 Thien Hai 和 Nguyen 在 2015 年的工作[6]等。此外,网格策略是一种控制市场仓位的方法,其潜力还有待挖掘。两个重要的传统网格策略是外汇网格策略[7] 和江恩网格策略[10]。

1.4 Our work && model overview
1.4 我们的工作&&模式概述

We proposed an APGM(Adaptive Periodic Grid Model) to decide when and how to change our positions in the Gold and Bitcoin markets. This model uses ARIMA predictions and AM to shift the grid. This approach enables grid model to make decisions when market price change immediately. We also design a backtesting process to adaptively adjust the parameters of our APGM. At the end, we write a memorandum to communicate your strategy, model, and results to the trader.
我们提出了一个 APGM(自适应周期网格模型)来决定何时以及如何改变我们在黄金和比特币市场的仓位。该模型使用 ARIMA 预测和 AM 来移动网格。这种方法使网格模型能够在市场价格发生变化时立即做出决策。我们还设计了一个回溯测试流程,以自适应地调整 APGM 的参数。最后,我们会撰写一份备忘录,将您的策略、模型和结果传达给交易者。
The following is a flow chart of our model framework.
以下是我们的模型框架流程图。

2 Assumptions  2 假设

Since we can only use the data provided, we make the following assumption:
由于我们只能使用所提供的数据,因此我们做出如下假设:
  • Assumption 1. We can trade any amount of gold or Bitcoin on any day with the given price.
    假设 1.我们可以在任何一天以给定的价格交易任意数量的黄金或比特币。
  • Reason 1. Following the requirement in the question sheet, we have only one price on certain trading. The initial funding is $ 1000 $ 1000 $1000\$ 1000, which is so little that has almost no effect on the price of gold or Bitcoin in the exchange, even though we have earned some times profit.
    原因 1.根据问题单的要求,我们在某些交易中只有一个价格。初始资金是 $ 1000 $ 1000 $1000\$ 1000 ,它是如此之少,以至于对交易所中黄金或比特币的价格几乎没有影响,尽管我们已经赚取了一些利润。
  • Assumption 2. The trend of daily price has periodicity to a certain degree.
    假设 2.每日价格趋势具有一定的周期性。
  • Reason 2. There exist economic cycles in years, because of the production cycle in the whole society.
    原因 2.由于整个社会的生产周期,每年都存在经济周期。
  • Assumption 3. The prices around a certain day have some similarities so that we can give a reasonable prediction from the price a few days ago.
    假设 3.某一天前后的价格具有一定的相似性,因此我们可以根据几天前的价格做出合理的预测。
  • Reason 3. The market has inertia to keep the trend unless some unpredictable incidents occur. Hence, this prediction might be inaccurate.
    原因 3.市场有保持趋势的惯性,除非发生一些不可预测的事件。因此,这种预测可能不准确。

3 Notations  3 备注

  • Time series  时间序列
Symbols  符号 Descriptions  说明
p { t } p { t } p^({t})p^{\{t\}} The price at time t t tt
t t tt 时的价格
a { t } a { t } a^({t})a^{\{t\}} The decision at time t t tt
时间 t t tt 时的决定
V { t } ( G ) V { t } ( G ) V^({t})(G)V^{\{t\}}(G) The value of Gold that the trader has at time t t tt
交易者在 t t tt 时间拥有的黄金价值
V { t } ( B ) V { t } ( B ) V^({t})(B)V^{\{t\}}(B) The value of Bitcoin that the trader has at time t t tt
交易者在 t t tt 时间拥有的比特币价值
V { t } ( C ) V { t } ( C ) V^({t})(C)V^{\{t\}}(C) The value of currency that the trader has at time t t tt
交易者在 t t tt 时间拥有的货币价值
Symbols Descriptions p^({t}) The price at time t a^({t}) The decision at time t V^({t})(G) The value of Gold that the trader has at time t V^({t})(B) The value of Bitcoin that the trader has at time t V^({t})(C) The value of currency that the trader has at time t| Symbols | Descriptions | | :---: | :--- | | $p^{\{t\}}$ | The price at time $t$ | | $a^{\{t\}}$ | The decision at time $t$ | | $V^{\{t\}}(G)$ | The value of Gold that the trader has at time $t$ | | $V^{\{t\}}(B)$ | The value of Bitcoin that the trader has at time $t$ | | $V^{\{t\}}(C)$ | The value of currency that the trader has at time $t$ |
  • Vanilla Grid Strategy  香草网格战略
Symbols  符号 Descriptions  说明
T start T start  T_("start ")T_{\text {start }} The start time of a Grid Model
网格模型的启动时间
T end T end  T_("end ")T_{\text {end }} The end time of a Grid Model
网格模型的结束时间
p max p max p_(max)p_{\max } The upper limit price
上限价格
p min p min p_(min)p_{\min } The lower limit price
下限价
α α alpha\alpha Transaction cost  交易成本
n u m in n u m in  num_("in ")n u m_{\text {in }} The grid number preset by users
用户预设的网格数
n u m 0 n u m 0 num_(0)n u m_{0} The maximum grid number considering α α alpha\alpha
考虑到 α α alpha\alpha 的最大网格数
n u m n u m numn u m The final grid number in the model
模型中的最终网格编号
n u m n u m numn u m The final grid number in the model
模型中的最终网格编号
r 0 r 0 r_(0)r_{0} The preset rate of return for each grid
每个网格的预设回报率
g i g i g_(i)g_{i} The i i ii th grid from lower to upper
从下至上的 i i ii 网格
p i p i p_(i)p_{i} The price of the i i ii th grid line from lower to upper
i i ii 从下到上的第 i i ii 条网格线的价格
Symbols Descriptions T_("start ") The start time of a Grid Model T_("end ") The end time of a Grid Model p_(max) The upper limit price p_(min) The lower limit price alpha Transaction cost num_("in ") The grid number preset by users num_(0) The maximum grid number considering alpha num The final grid number in the model num The final grid number in the model r_(0) The preset rate of return for each grid g_(i) The i th grid from lower to upper p_(i) The price of the i th grid line from lower to upper| Symbols | Descriptions | | :---: | :--- | | $T_{\text {start }}$ | The start time of a Grid Model | | $T_{\text {end }}$ | The end time of a Grid Model | | $p_{\max }$ | The upper limit price | | $p_{\min }$ | The lower limit price | | $\alpha$ | Transaction cost | | $n u m_{\text {in }}$ | The grid number preset by users | | $n u m_{0}$ | The maximum grid number considering $\alpha$ | | $n u m$ | The final grid number in the model | | $n u m$ | The final grid number in the model | | $r_{0}$ | The preset rate of return for each grid | | $g_{i}$ | The $i$ th grid from lower to upper | | $p_{i}$ | The price of the $i$ th grid line from lower to upper |
  • Adaptive Periodic Grid Model
    自适应周期网格模型
Symbols  符号 Descriptions  说明
M A { t } ( N ) M A { t } ( N ) MA^({t})(N)M A^{\{t\}}(N) The value of MA value with lag-time N N NN days on time t t tt
滞后时间 N N NN 天,时间 t t tt 的 MA 值
p ~ i { t } p ~ i { t } tilde(p)_(i)^({t})\tilde{p}_{i}^{\{t\}} The adjusted i i ii th grid line at time t t tt
时间 t t tt 时调整后的第 i i ii 条网格线
A R I M A { t } A R I M A { t } ARIMA^({t})A R I M A^{\{t\}} The predicted price given at time t t tt given by ARIMA Model
ARIMA 模型给出的时间 t t tt 时的预测价格
P R G , P R B P R G , P R B PR_(G),PR_(B)P R_{G}, P R_{B} The profit rate of Gold and Bitcoin
黄金和比特币的利润率
P P R G , P P R B P P R G , P P R B PPR_(G),PPR_(B)P P R_{G}, P P R_{B} The possible maximum profit rate of Gold and Bitcoin
黄金和比特币可能的最高利润率
G / B G / B G//BG / B The ratio of Gold and Bitcoin in portfolio ( Converted to $ ) $ ) $)\$)
黄金和比特币在投资组合中的比例 ( 换算成 $ ) $ ) $)\$) )
p max ( t 1 , t 2 ) p max t 1 , t 2 p_(max)(t_(1),t_(2))p_{\max }\left(t_{1}, t_{2}\right) The maximum price between t 1 t 1 t_(1)t_{1} and t 2 t 2 t_(2)t_{2}
t 1 t 1 t_(1)t_{1} t 2 t 2 t_(2)t_{2} 之间的最高价格
p min ( t 1 , t 2 ) p min t 1 , t 2 p_(min)(t_(1),t_(2))p_{\min }\left(t_{1}, t_{2}\right) The minimum price between t 1 t 1 t_(1)t_{1} and t 2 t 2 t_(2)t_{2}
t 1 t 1 t_(1)t_{1} t 2 t 2 t_(2)t_{2} 之间的最低价格
T i T i T_(i)T_{i} The start time of the i i ii th period and the end time of the ( i 1 ) ( i 1 ) (i-1)(i-1) th period
i i ii 期的开始时间和第 ( i 1 ) ( i 1 ) (i-1)(i-1) 期的结束时间
M S E M S E MSEM S E The Mean square error of ARIMA
ARIMA 的均方误差
Symbols Descriptions MA^({t})(N) The value of MA value with lag-time N days on time t tilde(p)_(i)^({t}) The adjusted i th grid line at time t ARIMA^({t}) The predicted price given at time t given by ARIMA Model PR_(G),PR_(B) The profit rate of Gold and Bitcoin PPR_(G),PPR_(B) The possible maximum profit rate of Gold and Bitcoin G//B The ratio of Gold and Bitcoin in portfolio ( Converted to $) p_(max)(t_(1),t_(2)) The maximum price between t_(1) and t_(2) p_(min)(t_(1),t_(2)) The minimum price between t_(1) and t_(2) T_(i) The start time of the i th period and the end time of the (i-1) th period MSE The Mean square error of ARIMA| Symbols | Descriptions | | :---: | :--- | | $M A^{\{t\}}(N)$ | The value of MA value with lag-time $N$ days on time $t$ | | $\tilde{p}_{i}^{\{t\}}$ | The adjusted $i$ th grid line at time $t$ | | $A R I M A^{\{t\}}$ | The predicted price given at time $t$ given by ARIMA Model | | $P R_{G}, P R_{B}$ | The profit rate of Gold and Bitcoin | | $P P R_{G}, P P R_{B}$ | The possible maximum profit rate of Gold and Bitcoin | | $G / B$ | The ratio of Gold and Bitcoin in portfolio ( Converted to $\$)$ | | $p_{\max }\left(t_{1}, t_{2}\right)$ | The maximum price between $t_{1}$ and $t_{2}$ | | $p_{\min }\left(t_{1}, t_{2}\right)$ | The minimum price between $t_{1}$ and $t_{2}$ | | $T_{i}$ | The start time of the $i$ th period and the end time of the $(i-1)$ th period | | $M S E$ | The Mean square error of ARIMA |

4 Vanilla Grid Strategy
4 香草网格战略

4.1 The fundamental of Grid Strategy
4.1 电网战略的根本

Vanilla Grid Strategy, which is known as the Forex grid trading strategy[1], is a technique that seeks to make a profit on the natural movement of the market by positioning buy stop orders and sell stop orders. This is performed on a predefined market distance with a preset size of take-profit and no stop-loss. The grid is divided by a sequence of assessments of current prices, from high to low, expressing expectations for long-term future prices.
香草网格策略(Vanilla Grid Strategy),即外汇网格交易策略[1],是一种通过定位买入止损单和卖出止损单,寻求在市场自然波动中获利的技术。这是在预先确定的市场距离上进行的,有预设的止盈规模,没有止损。网格由当前价格从高到低的评估序列划分,表达了对未来长期价格的预期。

Figure 1: A demo for Grid Strategy
图 1:网格策略演示
In response to the market, a buy or sell signal is generated when the actual price crosses the grid, and how much to buy or sell depends on the number of grids crossed. For example, the sell signal is generated at every 5 dollars interval above the current price, while putting buy orders at every 5 dollars below this price. The above Figure 1 visualized the idea of grid strategy. The specific algorithm for n u m 0 n u m 0 num_(0)n u m_{0} depends on the kind of grid strategy, which will be discussed in the following chapters.
根据市场情况,当实际价格越过网格时,就会发出买入或卖出信号,买入或卖出多少取决于越过网格的数量。例如,在当前价格之上每隔 5 美元就会发出卖出信号,而在该价格之下每隔 5 美元就会发出买入指令。上图 1 直观展示了网格策略的理念。 n u m 0 n u m 0 num_(0)n u m_{0} 的具体算法取决于网格策略的类型,这将在以下章节中讨论。
As a toy instance, the current price of an E.G. Coin, which only exists in the demo but not in the real world, is 6 dollars and we start the grid model with 4 E.G. Coins and 10 dollars. We ignore the transaction costs. So now the total price of all the property is 4 × 6 + 10 = 34 4 × 6 + 10 = 34 4xx6+10=344 \times 6+10=34 dollars. At the end of the second day, the price crossed down a margin of grid down. After we decide to buy an E.G coin with 4.57 dollars, we now have 5 E.G. Coins and 5.43 dollars. As a sequence, we sell 1 E.G. Coin at the end of the third day and sell 2 E.G. Coins at the end of the fourth day because the price of E.G. Coins has crossed one margin and two margins of the grid upward, respectively. As a result, we have 5 1 2 = 2 5 1 2 = 2 5-1-2=25-1-2=2 E.G. Coins and 5.43 + 5.26 + 2 × 7.48 = 25.95 5.43 + 5.26 + 2 × 7.48 = 25.95 5.43+5.26+2xx7.48=25.955.43+5.26+2 \times 7.48=25.95 dollars. In final, the total price of all the properties is 2 × 7.48 + 25.95 = 40.91 2 × 7.48 + 25.95 = 40.91 2xx7.48+25.95=40.912 \times 7.48+25.95=40.91 dollars. So far we have completed an arbitrage.
作为一个玩具实例,E.G. 硬币的当前价格是 6 美元,我们以 4 枚 E.G. 硬币和 10 美元开始网格模型,E.G. 硬币只存在于演示版中,而不存在于现实世界中。我们忽略交易成本。因此,现在所有财产的总价为 4 × 6 + 10 = 34 4 × 6 + 10 = 34 4xx6+10=344 \times 6+10=34 美元。第二天结束时,价格下降了一格。在我们决定以 4.57 美元买入一枚 E.G 硬币后,我们现在有 5 枚 E.G 硬币和 5.43 美元。作为一个序列,我们在第三天结束时卖出 1 枚 E.G. 硬币,在第四天结束时卖出 2 枚 E.G. 硬币,因为 E.G. 硬币的价格分别向上越过了网格的一个边际和两个边际。因此,我们有 5 1 2 = 2 5 1 2 = 2 5-1-2=25-1-2=2 枚 E.G. 硬币和 5.43 + 5.26 + 2 × 7.48 = 25.95 5.43 + 5.26 + 2 × 7.48 = 25.95 5.43+5.26+2xx7.48=25.955.43+5.26+2 \times 7.48=25.95 美元。最后,所有属性的总价格为 2 × 7.48 + 25.95 = 40.91 2 × 7.48 + 25.95 = 40.91 2xx7.48+25.95=40.912 \times 7.48+25.95=40.91 美元。至此,我们完成了一次套利。
Notice that the grid strategy does not perform as well as some simple strategies, e.g., Buy all the coins at first and wait for selling them at a high price. But this strategy has a stronger anti-risk ability and greater ability to use shocks to arbitrage. [5]
请注意,网格策略的表现不如一些简单的策略,例如一开始买入所有硬币,等待高价卖出。但这种策略的抗风险能力更强,利用冲击套利的能力也更强。[5]
The following algorithm shows the common steps for grid strategy when we actually apply it to make decisions.
下面的算法显示了我们在实际应用网格策略进行决策时的常用步骤。
Algorithm 1: Brief algorithm framework for grid strategy
        Input : A price sequence \(\left\{p^{\left\{T_{\text {start }}\right\}}, \cdots, p^{\left\{T_{\text {start }}\right\}}\right\}\) from \(T_{\text {start }}\) to \(T_{\text {end }}\) and parameters of grid strategy
        \(p_{\text {max }}, p_{\text {min }}, r_{0}\)
    Output: A decision sequence \(\left\{a^{\left\{T_{\text {start }}\right\}}, \cdots, a^{\left\{T_{\text {start }}\right\}}\right\}\)
    1. Calculate maximum number of grids num \(_{0} \leftarrow\) CalculateMaxGrid \(\left(p_{\max }, p_{\min }, r_{0}\right)\)
    2. \(n и т \leftarrow \min \left\{\right.\) num \(_{\text {in }}\), num \(\left._{0}\right\}\)
    3. Calculate the price of each grid
    4. Initialize the property portfolio in the first day
    5. Set \(t \leftarrow T_{\text {start }}+1\)
    6. If \(p^{\{t\}}>p^{\{t-1\}} \& \&\) Cross \(k\) grids then \(a^{\{t\}} \leftarrow\) Sell \(k\) units
    7. Else If \(p^{\{t\}}<p^{\{t-1\}} \& \&\) Cross \(k\) grids then \(a^{\{t\}} \leftarrow\) Buy \(k\) units
    9. Else \(a^{\{t\}} \leftarrow\) Hold
    8. \(t \leftarrow t+1\)
    10. If \(t \leqslant T_{\text {end }}\) then Go back to Step 6 .
    11. End
As the algorithm is shown above, we use grid strategy as the core of our decision model. Every decision is made after knowing the daily price. In the algorithm, the parameter T start T start  T_("start ")T_{\text {start }} is the start time of the decision task for the grid model, and T end T end  T_("end ")T_{\text {end }} is the end time of the decision task for the grid model. p max p max  p_("max ")p_{\text {max }} is the upper limit of price for the grid strategy and p min p min p_(min)p_{\min } is the lower limit price for the grid strategy.
如上图所示,我们使用网格策略作为决策模型的核心。每个决策都是在了解每日价格后做出的。在算法中,参数 T start T start  T_("start ")T_{\text {start }} 是网格模型决策任务的开始时间, T end T end  T_("end ")T_{\text {end }} 是网格模型决策任务的结束时间。 p max p max  p_("max ")p_{\text {max }} 是网格策略的价格上限, p min p min p_(min)p_{\min } 是网格策略的价格下限。

n u m in n u m in  num_("in ")n u m_{\text {in }} indicates the number of grids preset by the user, depending on the degree of risk aversion, when someone is risk-averse, num in in _(in)_{\mathrm{in}} should increase. num 0 0 _(0)_{0} is the number of grids calculated by function CalculateMaxGrid. The input of CalculateMaxGrid is p max , p min , r 0 p max , p min , r 0 p_(max),p_(min),r_(0)p_{\max }, p_{\min }, r_{0}. Finally, num is the grid number determined by n u m in n u m in  num_("in ")n u m_{\text {in }} and num 0 0 _(0)_{0} which is actually applied in the model.
是函数 CalculateMaxGrid 计算出的网格数。CalculateMaxGrid 的输入是 p max , p min , r 0 p max , p min , r 0 p_(max),p_(min),r_(0)p_{\max }, p_{\min }, r_{0} 。最后,num 是由 n u m in n u m in  num_("in ")n u m_{\text {in }} 和 num 0 0 _(0)_{0} 确定的网格数,实际应用于模型中。
In the example introduced above, we ignore the transaction costs. By contrast, if we apply transaction cost on every trade, we have cannot make the width for every grid to be too small[12]. This CalculateMaxGrid function considers transaction cost and depends on the type of Grid. Notice that different types of grid, i.e., isometric grid and proportional grid, have different CalculateMaxGrid. So the specific calculate function for num 0 0 _(0)_{0} will be discussed in the following two subsections
在上面介绍的例子中,我们忽略了交易成本。相比之下,如果我们对每笔交易都计算交易成本,就无法使每个网格的宽度过小[12]。CalculateMaxGrid 函数考虑了交易成本,并取决于网格类型。请注意,不同类型的网格,即等距网格和比例网格,有不同的 CalculateMaxGrid。因此,num 0 0 _(0)_{0} 的具体计算函数将在以下两个小节中讨论

4.2 Isometric Grid and Proportional Grid
4.2 等距网格和比例网格

Isometric Grid is the Grid Model which has the same width grids. In this model, we have the maximum grid number num 0 0 _(0)_{0} and the minimum width of grid l 0 = ( p max p max ) / n u m 0 l 0 = p max p max / n u m 0 l_(0)=(p_(max)-p_(max))//num_(0)l_{0}=\left(p_{\max }-p_{\max }\right) / n u m_{0}. Otherwise, we will lose money in trade because of the transaction cost. We need to guarantee
等距网格是具有相同宽度网格的网格模型。在该模型中,我们有最大的网格数 0 0 _(0)_{0} 和最小的网格宽度 l 0 = ( p max p max ) / n u m 0 l 0 = p max p max / n u m 0 l_(0)=(p_(max)-p_(max))//num_(0)l_{0}=\left(p_{\max }-p_{\max }\right) / n u m_{0} 。否则,我们会因为交易成本而在交易中亏损。我们需要保证
p i + 1 ( 1 ( 1 α ) 2 + r 0 ) p i p i + 1 1 ( 1 α ) 2 + r 0 p i p_(i+1) >= ((1)/((1-alpha)^(2))+r_(0))p_(i)p_{i+1} \geqslant\left(\frac{1}{(1-\alpha)^{2}}+r_{0}\right) p_{i}
where r 0 r 0 r_(0)r_{0} is the preset rate of return for each grid. Particularly, for the first and last grid, we have
其中, r 0 r 0 r_(0)r_{0} 是每个网格的预设收益率。特别是第一个和最后一个网格,我们有
g 1 = p 2 p 1 ( 1 ( 1 α ) 2 + r 0 1 ) p min , g num = p max p num ( 1 1 1 ( 1 α ) 2 + r 0 ) p max g 1 = p 2 p 1 1 ( 1 α ) 2 + r 0 1 p min , g num  = p max p num  1 1 1 ( 1 α ) 2 + r 0 p max g_(1)=p_(2)-p_(1) >= ((1)/((1-alpha)^(2))+r_(0)-1)p_(min),quadg_("num ")=p_(max)-p_("num ") >= (1-(1)/((1)/((1-alpha)^(2))+r_(0)))p_(max)g_{1}=p_{2}-p_{1} \geqslant\left(\frac{1}{(1-\alpha)^{2}}+r_{0}-1\right) p_{\min }, \quad g_{\text {num }}=p_{\max }-p_{\text {num }} \geqslant\left(1-\frac{1}{\frac{1}{(1-\alpha)^{2}}+r_{0}}\right) p_{\max }
According to the monotonicity of p i p i p_(i)p_{i} and r 0 r 0 r_(0)r_{0} is extremely small (about 0.005 0.02 0.005 0.02 0.005∼0.020.005 \sim 0.02 ), we can get
根据 p i p i p_(i)p_{i} 的单调性和 r 0 r 0 r_(0)r_{0} 的极小值(约 0.005 0.02 0.005 0.02 0.005∼0.020.005 \sim 0.02 ),我们可以得到
l 0 = max { inf { g 1 } , inf { g num } } , num 0 = p max p max l 0 . l 0 = max inf g 1 , inf g num  ,  num  0 = p max p max l 0 . l_(0)=max{i n f{g_(1)},i n f{g_("num ")}},quad" num "_(0)=(p_(max)-p_(max))/(l_(0)).l_{0}=\max \left\{\inf \left\{g_{1}\right\}, \inf \left\{g_{\text {num }}\right\}\right\}, \quad \text { num }_{0}=\frac{p_{\max }-p_{\max }}{l_{0}} .
The above indicates the function CalculateMaxGrid of the Isometric Grid Model. Then we get each line of the grid is
上面显示的是等距网格模型的 CalculateMaxGrid 函数。然后我们得到网格的每一行是
p i = p min + ( i 1 ) p max p min n u m , i { 1 , 2 , num + 1 } . p i = p min + ( i 1 ) p max p min n u m , i { 1 , 2 ,  num  + 1 } . p_(i)=p_(min)+(i-1)(p_(max)-p_(min))/(num),quad i in{1,2,cdots" num "+1}.p_{i}=p_{\min }+(i-1) \frac{p_{\max }-p_{\min }}{n u m}, \quad i \in\{1,2, \cdots \text { num }+1\} .
However, for the Proportional Grid Model, it satisfies the following formula
但是,对于比例网格模型,它满足以下公式的要求
p max = ( 1 + r 0 ) n u m 0 p min , p max = 1 + r 0 n u m 0 p min , p_(max)=(1+r_(0))^(num_(0))p_(min),p_{\max }=\left(1+r_{0}\right)^{n u m_{0}} p_{\min },
which is equivalent to
相当于
num 0 = log p max log p min log ( 1 + r 0 )  num  0 = log p max log p min log 1 + r 0 " num "_(0)=(log p_(max)-log p_(min))/(log(1+r_(0)))\text { num }_{0}=\frac{\log p_{\max }-\log p_{\min }}{\log \left(1+r_{0}\right)}
After we get num 0 0 _(0)_{0}, the price of each grid line can be represented as follows
在得到数字 0 0 _(0)_{0} 之后,每条网格线的价格可以表示如下
p i = p min ( p max p min ) i 1 n u m , i { 1 , 2 , n u m + 1 } . p i = p min p max p min i 1 n u m , i { 1 , 2 , n u m + 1 } . p_(i)=p_(min)**((p_(max))/(p_(min)))^((i-1)/(num)),quad i in{1,2,cdots num+1}.p_{i}=p_{\min } *\left(\frac{p_{\max }}{p_{\min }}\right)^{\frac{i-1}{n u m}}, \quad i \in\{1,2, \cdots n u m+1\} .
Then, the following Figure 2 shows an example of Isometric Model and Proportional Model.
下图 2 展示了等距模型和比例模型的示例。

Figure 2: The difference between ISO and Pro
图 2:ISO 和 Pro 之间的区别

Finally, we attempt to use the basic grid strategy to trade Bitcoin for six months. Both results of the isometric and proportional grid are displayed in the following Figure 3.
最后,我们尝试使用基本网格策略进行为期六个月的比特币交易。等距网格和比例网格的结果都显示在下图 3 中。


Figure 3: Application of ISO and Pro to the given data in the first 6 months
图 3:在前 6 个月对给定数据应用 ISO 和 Pro 标准

From the above pictures, we noticed that the isometric grid takes 0.731 times profit while the proportional grid takes 0.595 times profit. However, the latter has a larger number of exchanges since the proportional grids are denser in the low price range.
从上面的图片中,我们注意到等距网格的利润为 0.731 倍,而比例网格的利润为 0.595 倍。不过,后者的交换次数更多,因为比例网格在低价位区间更密集。

5 Adaptive Periodic Grid Model
5 自适应周期网格模型

According to the traditional grid model introduced in the previous section, if we apply it to the bitcoin market, we will find that this model will sell bitcoins when the price continues to rise. However, when the price has a significant increase or decrease, this model cannot make a good profit from the long-term upward trend or stop the loss in time. In order to deal with such a problem, we decided to consider the changes in the time dimension first. Specifically, we divide the total time into semi-annual or quarterly parts and assume that the model performs well over time. Every time a period is passed, we think that the previous model is no longer applicable, so we perform backtesting and adaptively adjust the model parameters. We divide the change of price into two parts, overall trend and local changes. The indicator of the overall trend comes from the moving average(MA) indicator and the local price change, that is, the price rise or fall on a certain day, can be predicted using ARIMA model. In our model, we preset the period to be half a year.
根据上一节介绍的传统网格模型,如果将其应用于比特币市场,我们会发现这种模型会在价格持续上涨时卖出比特币。然而,当价格出现大幅上涨或下跌时,该模型无法从长期上涨趋势中获得良好收益,也无法及时止损。为了解决这个问题,我们决定先考虑时间维度的变化。具体来说,我们将总时间分为半年或季度部分,并假设模型在一段时间内表现良好。每过一段时间,我们就会认为之前的模型不再适用,因此我们会进行回溯测试,并自适应地调整模型参数。我们将价格变化分为两部分,即整体趋势和局部变化。整体趋势的指标来自移动平均线(MA)指标,而局部价格变化,即某一天价格的涨跌,可以用 ARIMA 模型来预测。在我们的模型中,我们将周期预设为半年。
MA indicator is a commonly used indicator in stock and futures trading and can be calculated with the following formula,
MA 指标是股票和期货交易中常用的指标,可用以下公式计算、
M A { t } ( N ) = p { t N } + p { t N + 1 } + + p { t 1 } N . M A { t } ( N ) = p { t N } + p { t N + 1 } + + p { t 1 } N . MA^({t})(N)=(p^({t-N})+p^({t-N+1})+cdots+p^({t-1}))/(N).M A^{\{t\}}(N)=\frac{p^{\{\mathrm{t}-\mathrm{N}\}}+p^{\{\mathrm{t}-\mathrm{N}+1\}}+\cdots+p^{\{\mathrm{t}-1\}}}{N} .
This model is similar to the moving average filter in the Fourier transform, which smoothes sharply changing time series. Furthermore, the advantage of MA is that this model not only removes the noise part but also preserves the overall trend, which can avoid meaningless trades. The parameter N N NN represents the lag-time of the MA model and we initialize N N NN to 30 in our model. The following Figure 4 provides a demo for moving average line and the adaptive movement of the grid through time.
这种模型类似于傅立叶变换中的移动平均滤波器,可以平滑急剧变化的时间序列。此外,MA 模型的优势还在于它不仅能去除噪声部分,还能保留整体趋势,从而避免无意义的交易。参数 N N NN 代表 MA 模型的滞后时间,我们在模型中将 N N NN 初始化为 30。下图 4 演示了移动平均线和网格随时间的自适应移动。

Figure 4: Adjusted grids of Bitcoin price with MA(30)
图 4:调整后的比特币价格网格与 MA(30)
In the above picture, the price of Bitcoins, the moving average line and the movement of grids are colored as deep blue, red and shallow green, respectively. In the following sections, we will detail the ARIMA model, our APGM model and the backtesting procedure in order.
在上图中,比特币的价格、移动平均线和网格的移动分别用深蓝、红色和浅绿色表示。在下面的章节中,我们将依次详细介绍 ARIMA 模型、我们的 APGM 模型和回溯测试程序。

5.1 ARIMA

5.1.1 Model Settings of ARIMA
5.1.1 ARIMA 的模型设置

Auto-regressive integer moving average, which is known as ARIMA, is a statistical analysis model that uses time-series data to predict the future trend. The basic idea of ARIMA is that the data sequence formed by the prediction over time is regarded as a random sequence and a model can be used to approximately describe this sequence. Once this sequence is identified, the model can predict future values from past and present values of the time series. In this model, we seek to predict the future prices of gold and Bitcoin only based on price data up to that day.
自回归整数移动平均法,即 ARIMA,是一种利用时间序列数据预测未来趋势的统计分析模型。ARIMA 的基本思想是将随时间推移进行预测所形成的数据序列视为随机序列,并用一个模型来近似描述这一序列。一旦确定了这个序列,模型就可以根据时间序列的过去值和现在值预测未来值。在这个模型中,我们仅根据截至当天的价格数据来预测黄金和比特币的未来价格。
ARIMA model comprises of auto-regression (AR) model and moving average (MA) model. AR model describes the relationship between the current value and lagged value and predicts the future value with the historical data. MA model leverage the linear combination of the past residual term to observe the future residual. The ARIMA prediction model can be written as the following formula:
ARIMA 模型由自动回归 (AR) 模型和移动平均 (MA) 模型组成。AR 模型描述当前值与滞后值之间的关系,并利用历史数据预测未来值。MA 模型利用过去残差项的线性组合来观察未来残差。ARIMA 预测模型可写成以下公式:
p ^ { t } = p 0 + j = 1 p γ j p { t j } + j = 1 q θ j ε { t j } p ^ { t } = p 0 + j = 1 p γ j p { t j } + j = 1 q θ j ε { t j } hat(p)^({t})=p_(0)+sum_(j=1)^(p)gamma_(j)p^({t-j})+sum_(j=1)^(q)theta_(j)epsi^({t-j})\hat{p}^{\{t\}}=p_{0}+\sum_{j=1}^{p} \gamma_{j} p^{\{t-j\}}+\sum_{j=1}^{q} \theta_{j} \varepsilon^{\{t-j\}}
where p p pp is the order of Autoregressive Model (AR), q q qq is the order of Moving Average Model (AM), ε { t } ε { t } epsi^({t})\varepsilon^{\{t\}} is the Error term between time t t tt and t 1 , γ j t 1 , γ j t-1,gamma_(j)t-1, \gamma_{j} and θ j θ j theta_(j)\theta_{j} are the fitting coefficients, p 0 p 0 p_(0)p_{0} is constant term.
其中, p p pp 为自回归模型(AR)的阶数, q q qq 为移动平均模型(AM)的阶数, ε { t } ε { t } epsi^({t})\varepsilon^{\{t\}} 为时间 t t tt 间的误差项, t 1 , γ j t 1 , γ j t-1,gamma_(j)t-1, \gamma_{j} θ j θ j theta_(j)\theta_{j} 为拟合系数, p 0 p 0 p_(0)p_{0} 为常数项。

5.1.2 ACF and PACF function - p,q selection
5.1.2 ACF 和 PACF 函数 - p,q 选择

Respectively, ACF (autocorrelation function) and PACF (partial autocorrelation function) are both functions to evaluate the linear relationship between historical data and the current value. The formula of ACF is
ACF(自相关函数)和 PACF(偏自相关函数)都是评估历史数据与当前值之间线性关系的函数。ACF 的计算公式为
ACF ( q ) = Cov ( X j , X j q ) Var ( X 0 ) = 1 n q j = q + 1 n ( x j x ¯ ) ( x j q x ¯ ) 1 n j = 1 n ( x j x ¯ ) 2 ACF ( q ) = Cov X j , X j q Var X 0 = 1 n q j = q + 1 n x j x ¯ x j q x ¯ 1 n j = 1 n x j x ¯ 2 ACF(q)=(Cov(X_(j),X_(j-q)))/(Var(X_(0)))=((1)/(n-q)sum_(j=q+1)^(n)(x_(j)-( bar(x)))(x_(j-q)-( bar(x))))/((1)/(n)sum_(j=1)^(n)(x_(j)-( bar(x)))^(2))\operatorname{ACF}(q)=\frac{\operatorname{Cov}\left(X_{j}, X_{j-q}\right)}{\operatorname{Var}\left(X_{0}\right)}=\frac{\frac{1}{n-q} \sum_{j=q+1}^{n}\left(x_{j}-\bar{x}\right)\left(x_{j-q}-\bar{x}\right)}{\frac{1}{n} \sum_{j=1}^{n}\left(x_{j}-\bar{x}\right)^{2}}
for the order q q qq and the time series { x 1 , x 2 , , x n } x 1 , x 2 , , x n {x_(1),x_(2),cdots,x_(n)}\left\{x_{1}, x_{2}, \cdots, x_{n}\right\}.
阶数 q q qq 和时间序列 { x 1 , x 2 , , x n } x 1 , x 2 , , x n {x_(1),x_(2),cdots,x_(n)}\left\{x_{1}, x_{2}, \cdots, x_{n}\right\}

The formula of PACF is so sophisticated that we will not list it in this article. Further information about PACF can be referred to [8].
PACF 的计算公式非常复杂,本文不再一一列举。有关 PACF 的更多信息,请参阅 [8]。

5.1.3 quad\quad q-test  5.1.3 quad\quad Q 测试

To guarantee residuals are independent we should use Ljung-Box Q test (q-test). We take the Statistic
为了保证残差的独立性,我们应该使用 Ljung-Box Q 检验(q 检验)。我们取统计量
Q ( q ) = n ( n + 2 ) j = 1 q A C ~ F ( j ) n i Q ( q ) = n ( n + 2 ) j = 1 q A C ~ F ( j ) n i Q(q)=n(n+2)sum_(j=1)^(q)(A( tilde(C))F(j))/(n-i)Q(q)=n(n+2) \sum_{j=1}^{q} \frac{A \tilde{C} F(j)}{n-i}
where A C ~ F ( j ) A C ~ F ( j ) A tilde(C)F(j)A \tilde{C} F(j) is the autocorrelation function of { x 1 2 , x 2 2 , , x n 2 } x 1 2 , x 2 2 , , x n 2 {x_(1)^(2),x_(2)^(2),cdots,x_(n)^(2)}\left\{x_{1}^{2}, x_{2}^{2}, \cdots, x_{n}^{2}\right\} with order j j jj. And Q ( q ) Q ( q ) Q(q)Q(q) takes χ 2 χ 2 chi^(2)\chi^{2} distribution. [3]
其中, A C ~ F ( j ) A C ~ F ( j ) A tilde(C)F(j)A \tilde{C} F(j) 是阶数为 j j jj { x 1 2 , x 2 2 , , x n 2 } x 1 2 , x 2 2 , , x n 2 {x_(1)^(2),x_(2)^(2),cdots,x_(n)^(2)}\left\{x_{1}^{2}, x_{2}^{2}, \cdots, x_{n}^{2}\right\} 的自相关函数。而 Q ( q ) Q ( q ) Q(q)Q(q) χ 2 χ 2 chi^(2)\chi^{2} 分布。[3]

5.1.4 Results in ARIMA prediction
5.1.4 ARIMA 预测的结果

Following the above theory, we apply ARIMA to predict the price of Bitcoin. To satisfy the requirement in this question, we only use the nearest 30 -day data to train our model with the parameter vector ( p , q , d ) = ( 6 , 9 , 1 ) ( p , q , d ) = ( 6 , 9 , 1 ) (p,q,d)=(6,9,1)(p, q, d)=(6,9,1) and predict the price of the next day. Our result of prediction is shown as the following Figure 5.
根据上述理论,我们应用 ARIMA 来预测比特币的价格。为了满足这个问题的要求,我们只使用最近 30 天的数据来训练模型,使用参数向量 ( p , q , d ) = ( 6 , 9 , 1 ) ( p , q , d ) = ( 6 , 9 , 1 ) (p,q,d)=(6,9,1)(p, q, d)=(6,9,1) ,并预测第二天的价格。我们的预测结果如下图 5 所示。

Figure 5: Prediction of ARIMA model
图 5:ARIMA 模型的预测结果

5.2 APGM  5.2 亚太性别平等主流化协会

With the help of the ARIMA model, we can use the past data to make a simple prediction of the next day’s price. We can optimize the grid strategy so that it can shift the grid according to the prediction given by ARIMA. The following picture depicts the effect of grid shift in our model over time.
在 ARIMA 模型的帮助下,我们可以利用过去的数据对第二天的价格进行简单预测。我们可以优化网格策略,使其能够根据 ARIMA 预测移动网格。下图描述了模型中网格移动随时间变化的效果。
In our model, the movement of the grid is determined by the weighted sum of the long-term indicator from the MA and the short-term indicator from the ARIMA model. The amount of movement of the grid is calculated by the following formula:
在我们的模型中,网格的移动是由 MA 的长期指标和 ARIMA 模型的短期指标的加权和决定的。网格移动量按以下公式计算:
p ~ i { t } = p i + ω ( M A { t } ( N ) M A { t 1 } ( N ) ) + μ ( A R I M A { t + 1 } A R I M A { t } ) p ~ i { t } = p i + ω M A { t } ( N ) M A { t 1 } ( N ) + μ A R I M A { t + 1 } A R I M A { t } tilde(p)_(i)^({t})=p_(i)+omega(MA^({t})(N)-MA^({t-1})(N))+mu(ARIMA^({t+1})-ARIMA^({t}))\tilde{p}_{i}^{\{t\}}=p_{i}+\omega\left(M A^{\{t\}}(N)-M A^{\{t-1\}}(N)\right)+\mu\left(A R I M A^{\{t+1\}}-A R I M A^{\{t\}}\right)
The parameters ω ω omega\omega and μ μ mu\mu control the weights of two indicators in the procedure of grid movement. These two parameters will be adjusted adaptively in the backtesting phase and we initialize ω ω omega\omega to 0.3 and μ μ mu\mu to 0.3 in the first period. Therefore, the final decision was made by the adjusted grid model to control positions in the gold market and the Bitcoins market.
参数 ω ω omega\omega μ μ mu\mu 控制网格移动过程中两个指标的权重。这两个参数将在回溯测试阶段进行自适应调整,我们在第一阶段将 ω ω omega\omega 初始化为 0.3,将 μ μ mu\mu 初始化为 0.3。因此,调整后的网格模型最终决定控制黄金市场和比特币市场的仓位。

5.3 Backtesting Process  5.3 回溯测试过程

When a trade period ends, we terminate the APGM model for the current period and run the backtesting process. The goal of this process is to adjust the parameters of our model so that they can perform better in the next period of trading. During the backtesting process, we will obtain the following metrics and adaptively adjust the parameters related to them. The following table contains the updating criteria for related parameters.
当交易期结束时,我们会终止当期的 APGM 模型,并运行回溯测试流程。这一过程的目的是调整模型参数,使其在下一期交易中表现更好。在回溯测试过程中,我们将获得以下指标,并自适应地调整与之相关的参数。下表列出了相关参数的更新标准。
Indicators  指标 Parameters  参数 Descriptions  说明
P R G , P R B , P P R G , P R B P R G , P R B , P P R G , P R B PR_(G),PR_(B),PPR_(G),PR_(B)P R_{G}, P R_{B}, P P R_{G}, P R_{B} G / B G / B G//BG / B These denote the potential of increment of the two assets
这表示两种资产的增量潜力
p max ( t 1 , t 2 ) , p min ( t 1 , t 2 ) p max t 1 , t 2 , p min t 1 , t 2 p_(max)(t_(1),t_(2)),p_(min)(t_(1),t_(2))p_{\max }\left(t_{1}, t_{2}\right), p_{\min }\left(t_{1}, t_{2}\right) p max , p min p max , p min p_(max),p_(min)p_{\max }, p_{\min } These prevent price going beyond boundaries
防止价格越界
M S E M S E MSEM S E, ACF and PACF
M S E M S E MSEM S E 、ACF 和 PACF
p , q , d p , q , d p,q,dp, q, d These influence the accuracy of ARIMA Model
这些都会影响 ARIMA 模型的准确性
q-test , retest  Q 测试 , 复测 ω , μ ω , μ omega,mu\omega, \mu These evaluate the significance of ARIMA and MA
这些数据评估了 ARIMA 和 MA
Indicators Parameters Descriptions PR_(G),PR_(B),PPR_(G),PR_(B) G//B These denote the potential of increment of the two assets p_(max)(t_(1),t_(2)),p_(min)(t_(1),t_(2)) p_(max),p_(min) These prevent price going beyond boundaries MSE, ACF and PACF p,q,d These influence the accuracy of ARIMA Model q-test , retest omega,mu These evaluate the significance of ARIMA and MA| Indicators | Parameters | Descriptions | | :---: | :---: | :--- | | $P R_{G}, P R_{B}, P P R_{G}, P R_{B}$ | $G / B$ | These denote the potential of increment of the two assets | | $p_{\max }\left(t_{1}, t_{2}\right), p_{\min }\left(t_{1}, t_{2}\right)$ | $p_{\max }, p_{\min }$ | These prevent price going beyond boundaries | | $M S E$, ACF and PACF | $p, q, d$ | These influence the accuracy of ARIMA Model | | q-test , retest | $\omega, \mu$ | These evaluate the significance of ARIMA and MA |
The following gives some formulas to quantify parameters of the i i ii th period :
下面给出了一些量化 i i ii 周期参数的公式:
G / B = ( 1 + P R G 1 + P R B ) λ 1 ( 1 + P P R G 1 + P P R B ) λ 2 , λ 1 , λ 2 { 1 , 2 , 3 } p max = λ 3 p max ( T 1 , T i ) , λ 3 { 2 , 3 , 4 } p min = λ 4 p min ( T i 1 , T i ) , λ 4 { 0.5 , 1 , 1.25 } ω , μ { 0 , 0.1 , 0.3 , 0.5 } G / B = 1 + P R G 1 + P R B λ 1 1 + P P R G 1 + P P R B λ 2 , λ 1 , λ 2 { 1 , 2 , 3 } p max = λ 3 p max T 1 , T i , λ 3 { 2 , 3 , 4 } p min = λ 4 p min T i 1 , T i , λ 4 { 0.5 , 1 , 1.25 } ω , μ { 0 , 0.1 , 0.3 , 0.5 } {:[G//B=((1+PR_(G))/(1+PR_(B)))^(lambda_(1))((1+PPR_(G))/(1+PPR_(B)))^(lambda_(2))","quadlambda_(1)","lambda_(2)in{1","2","3}],[p_(max)=lambda_(3)p_(max)(T_(1),T_(i))","quadlambda_(3)in{2","3","4}],[p_(min)=lambda_(4)p_(min)(T_(i-1),T_(i))","quadlambda_(4)in{0.5","1","1.25}],[omega","mu in{0","0.1","0.3","0.5}]:}\begin{gathered} G / B=\left(\frac{1+P R_{G}}{1+P R_{B}}\right)^{\lambda_{1}}\left(\frac{1+P P R_{G}}{1+P P R_{B}}\right)^{\lambda_{2}}, \quad \lambda_{1}, \lambda_{2} \in\{1,2,3\} \\ p_{\max }=\lambda_{3} p_{\max }\left(T_{1}, T_{i}\right), \quad \lambda_{3} \in\{2,3,4\} \\ p_{\min }=\lambda_{4} p_{\min }\left(T_{i-1}, T_{i}\right), \quad \lambda_{4} \in\{0.5,1,1.25\} \\ \omega, \mu \in\{0,0.1,0.3,0.5\} \end{gathered}
Then we show the detailed process of backtesting:
然后,我们将展示回溯测试的详细过程:
  • Use price data of last period to update p max ( T 1 , T i ) p max T 1 , T i p_(max)(T_(1),T_(i))p_{\max }\left(T_{1}, T_{i}\right) and p min ( T i 1 , T i ) p min T i 1 , T i p_(min)(T_(i-1),T_(i))p_{\min }\left(T_{i-1}, T_{i}\right), which are the historical maximum price and the minimum price in the last period.
    使用上一期的价格数据更新 p max ( T 1 , T i ) p max T 1 , T i p_(max)(T_(1),T_(i))p_{\max }\left(T_{1}, T_{i}\right) p min ( T i 1 , T i ) p min T i 1 , T i p_(min)(T_(i-1),T_(i))p_{\min }\left(T_{i-1}, T_{i}\right) ,它们是上一期的历史最高价和最低价。
  • Calculate P R G P R G PR_(G)P R_{G} and P R B P R B PR_(B)P R_{B} with the following formula,
    用以下公式计算 P R G P R G PR_(G)P R_{G} P R B P R B PR_(B)P R_{B}
P R G = V { T i } ( G ) V { T i 1 } ( G ) V { T i 1 } ( G ) , P R B = V { T i } ( B ) V { T i 1 } ( B ) V { T i 1 } ( B ) P R G = V T i ( G ) V T i 1 ( G ) V T i 1 ( G ) , P R B = V T i ( B ) V T i 1 ( B ) V T i 1 ( B ) PR_(G)=(V^({T_(i)})(G)-V^({T_(i-1)})(G))/(V^({T_(i-1)})(G)),quad PR_(B)=(V^({T_(i)})(B)-V^({T_(i-1)})(B))/(V^({T_(i-1)})(B))P R_{G}=\frac{V^{\left\{T_{i}\right\}}(G)-V^{\left\{T_{i-1}\right\}}(G)}{V^{\left\{T_{i-1}\right\}}(G)}, \quad P R_{B}=\frac{V^{\left\{T_{i}\right\}}(B)-V^{\left\{T_{i-1}\right\}}(B)}{V^{\left\{T_{i-1}\right\}}(B)}
  • Retest the model in the last period supposing that we have known all days’ prices so that we can get a possible maximum profit rate for Gold and Bitcoin ( P P R G , P P R B ) P P R G , P P R B (PPR_(G),PPR_(B))\left(P P R_{G}, P P R_{B}\right).
    假设我们已经知道所有日期的价格,在最后一个时期重新测试模型,这样我们就可以得到黄金和比特币 ( P P R G , P P R B ) P P R G , P P R B (PPR_(G),PPR_(B))\left(P P R_{G}, P P R_{B}\right) 的可能最大利润率。
  • Enumerate all possible value of λ 1 , λ 2 , λ 3 , λ 4 , ω , μ λ 1 , λ 2 , λ 3 , λ 4 , ω , μ lambda_(1),lambda_(2),lambda_(3),lambda_(4),omega,mu\lambda_{1}, \lambda_{2}, \lambda_{3}, \lambda_{4}, \omega, \mu and restart the model of last period with corresponding parameters.
    枚举 λ 1 , λ 2 , λ 3 , λ 4 , ω , μ λ 1 , λ 2 , λ 3 , λ 4 , ω , μ lambda_(1),lambda_(2),lambda_(3),lambda_(4),omega,mu\lambda_{1}, \lambda_{2}, \lambda_{3}, \lambda_{4}, \omega, \mu 的所有可能值,并使用相应参数重新启动上一期模型。
  • According to the highest total profit rate apply that group of parameters in the new period.
    根据最高总利润率,在新时期应用该组参数。
  • Use ACF and PACF of the last period to find a responsible range of p , q p , q p,qp, q.
    使用上一期的 ACF 和 PACF 查找 p , q p , q p,qp, q 的负责范围。
  • Calculate MSE of the ARIMA model with different p , q , d p , q , d p,q,dp, q, d and find the minimum one. Then use them in the next period. The Figure 6 displays MSE for different p p pp and q q qq with d = 1 d = 1 d=1d=1 together with the ACF and PACF of the first period.
    计算不同 p , q , d p , q , d p,q,dp, q, d 的 ARIMA 模型的 MSE,找出最小值。然后在下一期使用它们。图 6 显示了不同 p p pp q q qq d = 1 d = 1 d=1d=1 的 MSE,以及第一期的 ACF 和 PACF。
To guarantee almost every point falls into the confidence interval, the blue area, we had best take p 2 , q 2 p 2 , q 2 p >= 2,q >= 2p \geqslant 2, q \geqslant 2. Then, by checking the heat map, we notice that when p = 9 , q = 6 p = 9 , q = 6 p=9,q=6p=9, q=6, the M S E M S E MSEM S E takes the minimum. Therefore, we determine p = 9 , q = 6 p = 9 , q = 6 p=9,q=6p=9, q=6 in the next period.
为了保证几乎每个点都落入置信区间,即蓝色区域,我们最好取 p 2 , q 2 p 2 , q 2 p >= 2,q >= 2p \geqslant 2, q \geqslant 2 。然后,通过查看热图,我们注意到当 p = 9 , q = 6 p = 9 , q = 6 p=9,q=6p=9, q=6 时, M S E M S E MSEM S E 取最小值。因此,我们确定下一期的 p = 9 , q = 6 p = 9 , q = 6 p=9,q=6p=9, q=6

Figure 6: Heat map, ACF and PACF figure
图 6:热图、ACF 和 PACF 图
  • Find the p-value of the q-test, which indicates the relationship between prices. Hence, when the p -vaule is smaller, the price data have a stronger relationship and vice versa. Therefore we replace μ μ mu\mu by
    求表示价格之间关系的 q 检验的 p 值。因此,当 p 值较小时,价格数据之间的关系较强,反之亦然。因此,我们将 μ μ mu\mu 替换为
μ e p -value μ e p -value  mue^(-p"-value ")\mu e^{-\mathrm{p} \text {-value }}
  • So far we have gained all parameters to start a new trading period.
    到目前为止,我们已经获得了开始新交易期的所有参数。
According to the criteria above, the model will adaptively adjust and decide the parameters for the next period. After initializing the parameters, the transaction goes to the next period.
根据上述标准,模型将自适应地调整和决定下一期的参数。参数初始化后,交易进入下一期。

6 Results and Comparison
6 结果与比较

6.1 Comparison with other strategies
6.1 与其他战略的比较

To compare the results of different trading strategies, we simulated each strategy for a fixed time period for testing. We first test our simple baseline strategy of buying all bitcoins at the beginning time and selling all the Bitcoins at the end time. We also test our fixed upper and lower bound periodic grid model with preset semiannual periods, adaptive grid model with ARIMA prediction, adaptive periodic grid model with MA prediction, adaptive periodic grid model with ARIMA prediction and adaptive periodic grid model with weighted MA and ARIMA prediction. The following Figure 7 shows the result of our test.
为了比较不同交易策略的结果,我们对每种策略都模拟了一个固定的测试时间段。我们首先测试了简单的基准策略,即在开始时间买入所有比特币,在结束时间卖出所有比特币。我们还测试了预设半年期的固定上下限周期网格模型、ARIMA 预测的自适应网格模型、MA 预测的自适应周期网格模型、ARIMA 预测的自适应周期网格模型以及加权 MA 和 ARIMA 预测的自适应周期网格模型。图 7 显示了测试结果。

Figure 7: Comparison of 8 different strategies
图 7:8 种不同策略的比较

From the above results, we find that the baseline strategy and fixed upper and lower bound periodic grid models perform very well. However, both strategies are extremely dependent on Bitcoin’s uptrend and insightful upper and lower bounds respectively. The baseline strategy is highly dependent on the ratio of the price on the beginning day and the price on the end day. The traditional grid strategy is too conservative and therefore cannot adapt to unilateral market conditions. In addition, the upper and lower bounds of the traditional grid strategy also seriously affect the final payoff. The following Figure 8 shows the difference between different upper and lower bound.
从上述结果中,我们发现基线策略和固定上下限周期网格模型的表现都非常出色。然而,这两种策略都极其依赖于比特币的上升趋势,以及分别具有洞察力的上下限。基线策略高度依赖于开始日和结束日的价格比率。传统的网格策略过于保守,因此无法适应单边市场条件。此外,传统网格策略的上下限也会严重影响最终收益。下图 8 显示了不同上下限之间的差异。

Figure 8: One-period strategies with different ranges
图 8:不同范围的单周期策略
From the above Figure 8, we will find that the main reason for the high profit of the traditional grid strategy is the unrealistic estimation of the upper bound (30000). The limitations of the baseline strategy and the traditional grid strategy make the generalization ability of these strategies low, which means that they are not suitable for many scenarios and have extremely high risks.
从上图 8 中我们可以发现,传统网格策略利润高的主要原因是对上限(30000)的估计不切实际。基线策略和传统网格策略的局限性使得这些策略的泛化能力较低,这意味着它们并不适用于很多场景,而且风险极高。
In our model, we do not apply neural networks because some traditional machine learning or deep learning methods such as LSTM, GRU, SVM have the following disadvantages under the framework of this problem:
在我们的模型中,我们没有使用神经网络,因为一些传统的机器学习或深度学习方法,如 LSTM、GRU、SVM 等,在这个问题的框架下有以下缺点:
  • The dataset is too small to support the training procedure of complex neural networks. While it may work very well in the final result, there is still a lot of randomnesses and theoretical generalization ability is questionable.
    数据集太小,无法支持复杂神经网络的训练过程。虽然最终结果可能很好,但仍有很多随机性,理论上的泛化能力值得怀疑。
  • Considering that the real market cannot be predicted by any individual due to its extreme complexity, it is impossible to generalize the market by a single model. To some extent, all predictions carry a great deal of risk.
    考虑到真实市场的极端复杂性,任何个人都无法对其进行预测,因此不可能用单一模型来概括市场。在某种程度上,所有预测都蕴含着巨大的风险。
In addition to these simple, high-risk or inappropriate strategies, we find that the adaptive periodic grid model with weighted MA and ARIMA prediction also performed very well. Notice that when we apply the APGM, different weighting coefficients correspond to different final profit margins. The reason for this phenomenon is that when different changes become more extreme over time, the time correlation between price changes, which in turn affects the final prediction results. So we need to change the weight coefficient of prediction to make different decisions at a different stage to get more profit.
除了这些简单、高风险或不恰当的策略外,我们还发现带有加权 MA 和 ARIMA 预测的自适应周期网格模型也有很好的表现。请注意,当我们应用 APGM 时,不同的加权系数对应不同的最终利润率。造成这种现象的原因是,当不同的变化随着时间的推移变得更加极端时,价格变化之间的时间相关性就会发生变化,进而影响最终的预测结果。因此,我们需要改变预测的权重系数,在不同的阶段做出不同的决策,以获得更多的利润。
To sum up, on the one hand, the best strategy should be able to grasp the overall trend of the market because the overall trend has a certain degree of stability without the occurrence of economic shocks. On the other hand, the model can also provide technical forecasts for local markets, thereby gaining some risk aversion and even arbitrage capabilities in runaway markets. Therefore, the APGM model satisfies the above criteria and we consider it the best model and the strategy provided by it is the best strategy considering not only the profit but also potential risk.
总之,一方面,最佳策略应该能够把握市场的整体趋势,因为在没有经济冲击的情况下,整体趋势具有一定的稳定性。另一方面,该模型还可以对局部市场进行技术预测,从而获得一定的风险规避能力,甚至在市场失控时获得套利能力。因此,APGM 模型符合上述标准,我们认为它是最佳模型,其提供的策略是不仅考虑利润而且考虑潜在风险的最佳策略。

6.2 Detailed procedure and final result
6.2 详细程序和最终结果

Due to the limitation of the problem framework, we assume that we don’t know anything about Gold and Bitcoins on the first day. So we decide to divide the asset into two equal parts and invest in gold and Bitcoin respectively. Parameters are initialized to the mean of the available interval for each parameter. The APGM model automatically finds the optimal portfolio depending on profitability. Specifically, we will change the weight parameters ω ω omega\omega and μ μ mu\mu in our APGM model during the backtesting process in a certain period. We also substitute it into the last period for retesting and we have the following Figure 9 which gives an example of an APGM model with the period parameter preset to 6 months.
由于问题框架的限制,我们假设第一天我们对黄金和比特币一无所知。因此,我们决定将资产分成两等份,分别投资于黄金和比特币。参数初始化为每个参数可用区间的平均值。APGM 模型会根据盈利能力自动找到最优投资组合。具体来说,我们将在某一时期的回溯测试过程中改变 APGM 模型中的权重参数 ω ω omega\omega μ μ mu\mu 。我们还将其代入上一期进行重新测试,下面的图 9 给出了一个 APGM 模型的示例,其周期参数预设为 6 个月。

Figure 9: Procedure of 6-month-per-period APGM
图 9:每期 6 个月 APGM 的程序
Due to Bitcoin’s extremely high profits, the model will tend to put more money into the Bitcoin market for profit. In the fourth period, due to the overall downward trend, there is no selling, but buying will be made to reduce the cost of holding positions. In the eighth period uptrend, the model predicted the uptrend well and did not sell too much Bitcoin. The vertical lines that appear in the image at the cut-off point at the end of the period represent the adjustment of the position and the resulting large-scale adjustment. This strategy ends up with a 42.271 times profit margin, i.e., from $ 1000 $ 1000 $1000\$ 1000 to $ 43271 $ 43271 $43271\$ 43271. The Figure 10 indicates how APGM adjust the proportion between Gold and Bitcoin in different periods.
由于比特币的利润极高,该模型会倾向于将更多的资金投入比特币市场获利。第四阶段,由于整体趋势向下,没有卖出,但会买入以降低持仓成本。在第八段上升趋势中,模型很好地预测了上升趋势,没有卖出太多比特币。图中在期末截点处出现的垂直线代表仓位的调整以及由此产生的大规模调整。该策略最终的利润率为 42.271 倍,即从 $ 1000 $ 1000 $1000\$ 1000 $ 43271 $ 43271 $43271\$ 43271 。图 10 显示了 APGM 在不同时期如何调整黄金和比特币的比例。

Figure 10: Positions of different assets in the first 3 periods
图 10:前三个时期不同资产的头寸情况
After the third period, the model almost only chooses Bitcoin investment, because of its ultrahigh profit. Although in the third period the price of Bitcoin decreases, our model still allocates a lot of fund in Bitcoin in the fourth period, because of its great profits in the first two periods and the result of backtesting.
第三期之后,由于比特币的超高利润,模型几乎只选择投资比特币。虽然在第三期比特币价格下降,但由于比特币在前两期的巨大利润和回溯测试的结果,我们的模型在第四期仍将大量资金分配给比特币。

7 Model Evaluation  7 模型评估

From the previous part, we selected the best strategy. In this section, we will test and evaluate our strategy in two dimensions, sensitivity analysis and robustness analysis, respectively. Sensitivity analysis is used to analyze how different values of a set of independent variables affect a specific dependent variable under certain specific conditions. Robustness analysis provides an approach to the structuring of problem situations in which uncertainty is high and where decisions can be stages sequentially. The following subsections will introduce them separately.
从上一部分中,我们选择了最佳策略。在本节中,我们将分别从敏感性分析和稳健性分析两个方面对我们的策略进行测试和评估。敏感性分析用于分析在某些特定条件下,一组自变量的不同值对特定因变量的影响。稳健性分析则提供了一种方法,用于构建不确定性较高、可分阶段连续决策的问题情境。以下各小节将分别介绍它们。

7.1 Sensitivity Analysis
7.1 敏感性分析

In market trading, especially in high-frequency trading strategies, the transaction cost rate has a large impact on the profits. In the case of increased transaction costs, the traditional grid strategy will produce some meaningless losses if there are no restrictions on the transaction frequency and width of the grid. In contrast, our model is able to control the maximum grid numbers and adjust the upper and lower bounds of the grid based on historical prices. This operation changes the width of each grid, which also changes the profit of each grid to reduce trading frequency. In other words, this operation enables our model to guarantee enough profit to allow some losses. We simulated six cases in which the transaction cost of gold was changed to 0.01 , 0.02 0.01 , 0.02 0.01,0.020.01,0.02, and the transaction cost of Bitcoin was changed to 0.01 , 0.02 0.01 , 0.02 0.01,0.020.01,0.02, and 0.03 . We get the following Figure 11 to show the number of trades and the final profit.
在市场交易中,尤其是在高频交易策略中,交易费用率对利润的影响很大。在交易成本增加的情况下,如果不限制交易频率和网格宽度,传统的网格策略会产生一些毫无意义的损失。相比之下,我们的模型能够控制最大网格数,并根据历史价格调整网格的上下限。这一操作改变了每个网格的宽度,也改变了每个网格的利润,从而降低了交易频率。换句话说,这一操作使我们的模型能够保证足够的利润,并允许一定的损失。我们模拟了六种情况,其中黄金的交易成本变为 0.01 , 0.02 0.01 , 0.02 0.01,0.020.01,0.02 ,比特币的交易成本变为 0.01 , 0.02 0.01 , 0.02 0.01,0.020.01,0.02 和 0.03。 我们得到了如下图 11 所示的交易次数和最终利润。

Figure 11: Trading procedure with different transaction cost rates
图 11:不同交易费率下的交易程序

In the above Figure 11, change g g _(g){ }_{g} is exchange times of gold during the whole 5 years and change b b _(b)_{b} is the same of bitcoin. From this figure, we will find that no matter whether the product is gold or bitcoin,
在上图 11 中,变化 g g _(g){ }_{g} 是整个 5 年中黄金的兑换次数,变化 b b _(b)_{b} 是比特币的兑换次数。从图中我们可以发现,无论是黄金还是比特币、

the number of the transaction will decrease as the transaction cost rate increases. When the trade is increased by 50 % 50 % 50%50 \%, there is a 20 % 20 % 20%20 \% decrease in final profit. From this, we can conclude that our model reacts somewhat as transaction cost rate increase to prevent unnecessary high-frequency trading.
随着交易费用率的增加,交易次数也会减少。当交易增加 50 % 50 % 50%50 \% 时,最终利润会减少 20 % 20 % 20%20 \% 。由此,我们可以得出结论,我们的模型在一定程度上随着交易费用率的增加而做出反应,以防止不必要的高频交易。

7.2 Robustness Analysis  7.2 稳健性分析

In this section, we add some noise based on the officially provided data. The noise added here follows a Gaussian distribution. We preset the variance of noise to be 0.01 and 0.02 times the original value. The following Figure 12 shows the simulation results.
在本节中,我们将根据官方提供的数据添加一些噪声。这里添加的噪声服从高斯分布。我们将噪声方差预设为原始值的 0.01 倍和 0.02 倍。图 12 显示了模拟结果。

Figure 12: Results on price data with Gaussian noise
图 12:使用高斯噪声的价格数据结果

From the above Figure 12, we found that due to the characteristics of the grid strategy, the profit in the volatile market will not decrease, but the advantages of the grid strategy are used to increase the number of trades and increase the profit obtained through arbitrage. But from a macro perspective, the changes are not obvious.
从上图 12 中我们发现,由于网格策略的特点,在震荡市中的利润并不会减少,而是利用网格策略的优势增加了交易次数,提高了通过套利获得的利润。但从宏观角度来看,变化并不明显。

8 Strengths and Weaknesses
8 优势和劣势

In the following sections, some strengths and weaknesses of our final APGM will be described in detail.
下文将详细介绍我们最终 APGM 的一些优缺点。

8.1 Strengths  8.1 优势

  • Strong arbitrage ability in volatile markets: Our APGM model inherits the traditional grid strategy, so it has a strong ability to arbitrage in some volatile markets as a result.
    波动市场中的强大套利能力:我们的 APGM 模型继承了传统的网格策略,因此在一些波动市场中具有很强的套利能力。
  • Low time and spatial complexity: The model is neural network-free, which means that less data is required to complete the parameter estimation and training process. Also, our model requires less time and less space because there is no neural network in our model.
    时间和空间复杂性低:该模型不含神经网络,这意味着完成参数估计和训练过程所需的数据更少。同时,由于我们的模型中没有神经网络,因此所需的时间和空间也更少。
  • High Flexibility and Elasticity: The adaptive periodic procedure guarantees the flexibility of our model, allowing it to react to changes in price trends. Also, our model gets rid of the upper and lower bounds of traditional grids, which makes our model very elastic to sharp changes in price.
    高度灵活性和弹性:自适应周期程序保证了我们模型的灵活性,使其能够对价格趋势的变化做出反应。此外,我们的模型还摆脱了传统网格的上下限,这使得我们的模型对价格的急剧变化具有很强的弹性。
  • High Anti-risk Ability: The grid strategy in our model divides the whole assets into multiple parts, so the model has a high ability to avoid potential risks.
    高抗风险能力:我们模型中的网格策略将整个资产分为多个部分,因此模型具有很强的规避潜在风险的能力。
  • High Stability and Robustness: The grid strategy is a very stable strategy and it does not depend on accurate prediction. Hence, the profit of our model has less variance in the face of noisy data.
    高稳定性和鲁棒性:网格策略是一种非常稳定的策略,它不依赖于准确的预测。因此,面对嘈杂的数据时,我们模型的收益差异较小。

8.2 Weaknesses  8.2 弱点

  • Likely to be Overfit: This model contains a large number of parameters, and the dataset is insufficient to guarantee finding suitable parameters, so the APGM model has the potential to overfit. However, due to the complexity of the real world, APGM might work better.
    可能过拟合:该模型包含大量参数,而数据集不足以保证找到合适的参数,因此 APGM 模型有可能过拟合。不过,由于现实世界的复杂性,APGM 可能会更好用。
  • Sensitive to the start time and the end time: The start and end times of each period have a large impact on the parameter update, so the model will have a huge difference when the start and end times change.
    对开始时间和结束时间敏感:每个周期的开始时间和结束时间对参数更新的影响很大,因此当开始时间和结束时间发生变化时,模型将产生巨大差异。
  • Less effective in extreme rapid price change: The extreme rapid price change will confuse the ARIMA predictor and make the grid strategy become more conservative. Therefore, some extreme rapid price changes make the final APGM model less effective and even worth than some simple strategies.
    在价格极端快速变化时效果较差:极端快速的价格变化会混淆 ARIMA 预测器,使网格策略变得更加保守。因此,一些极端快速的价格变化会使最终的 APGM 模型变得不那么有效,甚至比一些简单的策略更有价值。
  • Non-optimal parameters guaranteed: The parameters of our model are always discrete, i.e., not convex, which means that we cannot guarantee that the parameters obtained from the backtesting process are the optimal parameters with traditional optimization methods.
    保证非最佳参数:我们模型的参数总是离散的,即不是凸参数,这意味着我们无法保证回溯测试过程中获得的参数是传统优化方法的最优参数。

9 Conclusion  9 结论

In this paper, we improve the traditional grid strategy to adapt to the more sophisticated market environment, which is called the Adapted Periodic Grid Model (APGM). Our model can be divided into three parts: prediction, decision and backtesting. They play the following roles respectively:
在本文中,我们改进了传统的网格策略,以适应更复杂的市场环境,这就是自适应周期网格模型(APGM)。我们的模型可分为三个部分:预测、决策和回测。它们分别扮演以下角色:
  • According to the current price and historical data, calculate moving average and make a prediction based on ARIMA, then send these results to the decision Model.
    根据当前价格和历史数据,计算移动平均值,并基于 ARIMA 进行预测,然后将这些结果发送给决策模型。
  • Give different weights to different price indicators to adjust grid prices. Then make a decision and change the positions.
    对不同的价格指标赋予不同的权重,以调整网格价格。然后做出决定并改变仓位。
  • Calculate the new parameters for the next period from the historical price data and restart the model with the calculated data.
    根据历史价格数据计算下一时期的新参数,并使用计算出的数据重新启动模型。
Next, to demonstrate that our model is the best model, we compare it with some other strategies. Our model works well on both reward and risk dimensions. Also, we show more details in different periods and within one period.
接下来,为了证明我们的模型是最佳模型,我们将其与其他一些策略进行了比较。我们的模型在收益和风险两个维度上都运行良好。此外,我们还展示了不同时期和同一时期的更多细节。
Finally, we test our model on the sensitivity and robustness dimensions. In the robustness analysis, due to the characteristics of the grid model itself, the performance of the grid model does not get worse in noisy datasets but gets better. In the sensitivity analysis, when we slightly change the transaction costs, the profit also changes slightly and the frequency also becomes slower. Taken together, these analyses show that our model performs well in different settings.
最后,我们从灵敏度和稳健性两个维度测试了我们的模型。在稳健性分析中,由于网格模型自身的特点,网格模型的性能在有噪声的数据集中不仅不会变差,反而会更好。在敏感性分析中,当我们稍稍改变交易成本时,利润也会稍有变化,频率也会变慢。总之,这些分析表明,我们的模型在不同环境下表现良好。

10 Memorandum  10 备忘录

To: Traders  致贸易商
From: MCM Team 2200401
来自MCM 团队 2200401

Subject:Adjusted periodic grid model in quantitative trading
主题:量化交易中的调整周期网格模型

Date: February 20, 2022
日期: 2022 年 2 月 20 日日期: 2022 年 2 月 20 日
Gold has always been considered a general equivalent asset due to its scarcity and chemical stability. In recent years, with the frequent changes in the international situation, gold, due to the property of good value preservation, becomes more and more popular. At the same time, Bitcoin, as the earliest developed and largest cryptocurrency, is called “digital gold”, and blockchain technology is also popular due to its decentralization property and no need for supervision. In recent years, the price of Bitcoins has risen rapidly, which has attracted the attention of many people. Some lucky people made a lot of money from their Bitcoin investments. However, risks and benefits often coexist. In other words, when allocating assets, we should not only pursue higher returns but also avoid potential risks. Much of the work in quantitative trading has focused on developing a model that is not only concerned about profit maximization but is also robust against risk.
黄金因其稀缺性和化学稳定性,一直被视为一般等价资产。近年来,随着国际形势的频繁变化,黄金因其保值性好的特性,越来越受到人们的青睐。同时,比特币作为发展最早、规模最大的加密货币,被称为 "数字黄金",区块链技术也因其去中心化、无需监管的特性而备受青睐。近年来,比特币价格迅速上涨,吸引了很多人的关注。一些幸运儿通过比特币投资赚了不少钱。然而,风险与收益往往是并存的。换句话说,在配置资产时,我们不仅要追求更高的收益,还要规避潜在的风险。量化交易的大部分工作都集中在开发一种模型,这种模型不仅关注利润最大化,而且还能稳健地抵御风险。
Based on this, our team uses nearly five years of gold and bitcoins prices to analyze and provide strategies for controlling positions. Our team provides a novel adaptive periodic grid model called APGM for decision-making tasks. As an excellent model for arbitrage tasks in volatile markets, the grid model incorporates ARIMA prediction to adaptively shift the grid, allowing the model to adapt to sharp changes in prices. We also introduced a moving average of the last few days to capture the information about the overall trend and a weight factor to balance the impact of prediction and the impact of history in decisions.
在此基础上,我们的团队利用近五年的黄金和比特币价格进行分析,并提供控制仓位的策略。我们的团队为决策任务提供了一种名为 APGM 的新型自适应周期网格模型。作为在波动市场中执行套利任务的优秀模型,该网格模型结合了 ARIMA 预测来自适应性地移动网格,使模型能够适应价格的急剧变化。我们还引入了最近几天的移动平均值来捕捉整体趋势信息,并引入了权重系数来平衡预测和历史对决策的影响。
The following are some main steps in our model:
以下是我们模型的几个主要步骤:
  • According to the human evaluation, an appropriate parameter is decided, which is automatically optimized by the model over time. We preset a fixed period, and each day, the model provides a sell or buy or hold decision.
    根据人工评估结果,决定一个合适的参数,并由模型随时间自动优化。我们预设了一个固定的周期,每天,模型都会提供卖出、买入或持有的决策。
  • After every day, the model receives information about the price of gold and bitcoin for that day. Combining the previous information, ARIMA leverage the local trend to predict the price for the next day, while MA depicts the overall trend of the past few days. The APGM model combines the ideas of the grid model with information from ARIMA and MA to shift the grid into place. The moving grid provides a buy or sells or hold strategy for the next day.
    每天之后,模型都会收到当天黄金和比特币的价格信息。结合之前的信息,ARIMA 利用局部趋势预测第二天的价格,而 MA 则描述过去几天的整体趋势。APGM 模型将网格模型的思想与 ARIMA 和 MA 的信息相结合,将网格移动到位。移动网格提供了第二天的买入、卖出或持有策略。
  • When a period passes, the model runs a backtesting process according to the previous period and predicts new parameters for the next period.
    当一个时期过去后,模型会根据上一个时期运行回溯测试过程,并预测下一个时期的新参数。
Besides, our team also provides a user interface to control the parameters inside the model so that the model can be adapted to different users. For example, if someone is a profit-oriented user, he can change the number of grids to be less and the period shorter to make the model more flexible in pursuit of higher profit. Conversely, if someone is a risk-averse user, to get stable gains from the grid strategy, our team recommends the use of a longer period and lowering the weight of the prediction model to reduce the randomness.
此外,我们的团队还提供了一个用户界面来控制模型内部的参数,使模型能够适应不同的用户。举例来说,如果用户以盈利为目的,他可以减少网格数量,缩短周期,使模型更加灵活,以追求更高的收益。相反,如果某人是风险规避型用户,为了从网格策略中获得稳定收益,我们的团队建议使用更长的周期,并降低预测模型的权重,以减少随机性。

Our team also compares our model with some other strategies to demonstrate that our model performs very well in the gold and Bitcoins markets over the last five years.
我们的团队还将我们的模型与其他一些策略进行了比较,以证明我们的模型在过去五年的黄金和比特币市场中表现非常出色。
Period  期间 ω ω omega\boldsymbol{\omega} μ μ mu\boldsymbol{\mu} Total Profit from $1000
1000 美元的总利润

将所有网格(从 $ 300 $ 300 $300\$ 300 $ $ 3 0 0 0 0 ) $ $ 3 0 0 0 0 ) $$30000)\$ \mathbf{\$ 3 0 0 0 0})
once put all
(grids from $ 300 $ 300 $300\$ 300 to
$ $ 3 0 0 0 0 ) $ $ 3 0 0 0 0 ) $$30000)\$ \mathbf{\$ 3 0 0 0 0})
once put all (grids from $300 to $$30000)| once put all | | :---: | | (grids from $\$ 300$ to | | $\$ \mathbf{\$ 3 0 0 0 0})$ |
0 0 27034
0 0.5 42719
0.5 0 36959
6-month period  6 个月期间 0.5 0.5 56602
0 0 19154
0 0.5 41213
0.5 0 21863
Our Model (APGM)  我们的模式(APGM) 0.5 38933
Period omega mu Total Profit from $1000 "once put all (grids from $300 to $$30000)" 0 0 27034 0 0.5 42719 0.5 0 36959 6-month period 0.5 0.5 56602 0 0 19154 0 0.5 41213 0.5 0 21863 Our Model (APGM) 0.5 38933 | Period | $\boldsymbol{\omega}$ | $\boldsymbol{\mu}$ | Total Profit from $1000 | | :---: | :---: | :---: | :---: | | once put all <br> (grids from $\$ 300$ to <br> $\$ \mathbf{\$ 3 0 0 0 0})$ | 0 | 0 | 27034 | | | 0 | 0.5 | 42719 | | | 0.5 | 0 | 36959 | | 6-month period | 0.5 | 0.5 | 56602 | | | 0 | 0 | 19154 | | | 0 | 0.5 | 41213 | | | 0.5 | 0 | 21863 | | Our Model (APGM) | 0.5 | 38933 | |
Of course, our model also has certain shortcomings. The grid model requires the fluctuation or rise of the overall market. Therefore, investors should evaluate the value of assets and choose asset types with high value-added potential or some asset types with more dramatic price changes. Note that our APGM model does not work very well for certain asset types that are falling for a long time or are too stable. Additionally, if you are not optimistic about the market and think it is in a long-term downtrend, you can consider using the reverse grid instead of APGM, shorting instead of selling, and closing positions instead of buying, but this operation also means there is a greater risk.
当然,我们的模型也有一定的缺陷。网格模型需要整体市场的波动或上涨。因此,投资者应评估资产价值,选择增值潜力大的资产类型或一些价格变化较为剧烈的资产类型。需要注意的是,我们的 APGM 模型对于某些长期下跌或过于稳定的资产类型效果不佳。此外,如果你对市场不看好,认为市场处于长期下跌趋势,可以考虑使用反向网格来代替 APGM,用做空来代替卖出,用平仓来代替买入,但这种操作也意味着存在较大的风险。
Finally, we hope that our model can be enlightening. You can choose a strategy that is more suitable for your investment philosophy according to the market situation, and sincerely hope that you can create more profits in the future!
最后,我们希望我们的模型能够对您有所启发。您可以根据市场情况,选择更适合自己投资理念的策略,并衷心希望您能在未来创造更多利润!
Yours sincerely,  此致敬礼
Team # 2200401  团队编号 2200401

11 Reference  11 参考资料

References  参考资料

[1] What is grid trading? forex grid trading strategy explained, 2021.
[1] 什么是网格交易?

[2] George EP Box. Gm jenkins time series analysis: Forecasting and control. San Francisco, Holdan-Day, 1970.
[2] George EP Box.Gm Jenkins 时间序列分析:Forecasting and control.旧金山,Holdan-Day,1970 年。

[3] Hossein Hassani and Mohammad Reza Yeganegi. Sum of squared acf and the ljung-box statistics. Physica A: Statistical Mechanics and Its Applications, 520:81-86, 2019.
[3] Hossein Hassani 和 Mohammad Reza Yeganegi.Acf平方和与Ljung-box统计。Physica A: Statistical Mechanics and Its Applications, 520:81-86, 2019.

[4] Minyoung Kim. Cost-sensitive estimation of arma models for financial asset return data. Mathematical Problems in Engineering, 2015, 2015.
[4] Minyoung Kim.金融资产回报数据的arma模型成本敏感估计。工程数学问题,2015,2015.

[5] Fernando Pinhabel Marafão, Danilo Iglesias Brandão, Alessandro Costabeber, and Helmo Kelis Morales Paredes. Multi-task control strategy for grid-tied inverters based on conservative power theory. IET Renewable Power Generation, 9(2):154-165, 2015.
[5] Fernando Pinhabel Marafão、Danilo Iglesias Brandão、Alessandro Costabeber 和 Helmo Kelis Morales Paredes。基于保守功率理论的并网逆变器多任务控制策略。IET Renewable Power Generation,9(2):154-165,2015.

[6] Thien Hai Nguyen, Kiyoaki Shirai, and Julien Velcin. Sentiment analysis on social media for stock movement prediction. Expert Systems with Applications, 42(24):9603-9611, 2015.
[6] Thien Hai Nguyen、Kiyoaki Shirai 和 Julien Velcin。用于股票走势预测的社交媒体情感分析。专家系统与应用》,42(24):9603-9611,2015.

[7] HP Pan. A joint review of technical and quantitative analysis of the financial markets towards a unified science of intelligent finance. In Proc. 2003 Hawaii International Conference on Statistics and Related Fields, June, pages 5-9. Citeseer.
[7] HP Pan.金融市场技术分析和定量分析的联合综述,迈向统一的智能金融科学。In Proc. 2003 Hawaii International Conference on Statistics and Related Fields, June, pages 5-9.Citeseer.

[8] Fred L Ramsey. Characterization of the partial autocorrelation function. The Annals of Statistics, pages 1296-1301, 1974.
[8] Fred L Ramsey.偏自相关函数的特征。统计年鉴》,第 1296-1301 页,1974 年。

[9] C Radhakrishna Rao. Statistics and truth. Putting Chance to Work, 1989.
[9] C Radhakrishna Rao.统计与真理。让机会发挥作用》,1989 年。

[10] Francesco Rundo, Francesca Trenta, Agatino Luigi di Stallo, and Sebastiano Battiato. Grid trading system robot (gtsbot): A novel mathematical algorithm for trading fx market. Applied Sciences, 9(9):1796, 2019.
[10] Francesco Rundo、Francesca Trenta、Agatino Luigi di Stallo 和 Sebastiano Battiato。网格交易系统机器人(gtsbot):用于外汇市场交易的新型数学算法。应用科学》,9(9):1796,2019。

[11] Sreelekshmy Selvin, R Vinayakumar, EA Gopalakrishnan, Vijay Krishna Menon, and KP Soman. Stock price prediction using lstm, rnn and cnn-sliding window model. In 2017 international conference on advances in computing, communications and informatics (icacci), pages 16431647. IEEE.
[11] Sreelekshmy Selvin、R Vinayakumar、EA Gopalakrishnan、Vijay Krishna Menon 和 KP Soman。使用 LSTM、RNN 和 CNN 滑动窗口模型预测股价。In 2017 international conference on advances in computing, communications and informatics (icacci), pages 16431647.IEEE.

[12] Oliver E Williamson. The economics of organization: The transaction cost approach. American journal of sociology, 87(3):548-577, 1981.
[12] Oliver E Williamson.The economics of organization:The transaction cost approach.American journal of sociology,87(3):548-577,1981.

12 Appendix  12 附录

  • The correlation between the changes of price of Gold and Bitcoin
    黄金和比特币价格变化的相关性

The figure shows that they have almost no correlation!
从图中可以看出,它们之间几乎没有相关性!
  • The total return of God, who knows all of data on the first day, and only buy and sell on turning points.
    上帝的总回报,他在第一天就知道所有数据,只在转折点买卖。