这是用户在 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.