提示:个人翻译可能并不十分准确, 欢迎批评指正,交流学习
“Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?”- T. S. Eliot
“我们在哪里丢失了知识中的智慧?又在哪里丢失了信息中的知识?”- T. S. Eliot
1、Introduction
I love quant investing and have been doing it since university, about 30 years ago. Quant investing covers several disciplines (investing, trading, statistics, artificial intelligence and programming) and most articles and books about quant investing are theoretical and complex. In this article, I want to demystify quant investing and show you what&how in simple and practical terms.The hypothesis in this article: is it possible to create and implement a simple working quant investing trading rule that outperforms bitcoin buy&hold investment?We will see that we can out perform buy&hold, by a wide margin.Nothing in this article is financial advice. All content is for informational and educational purposes only. No investment is without risk.Make sure you read the risk paragraph in this article.
1、简介
我喜欢量化投资,大约 30 年前从大学开始就一直这样做。量化投资涵盖多个学科(投资、交易、统计、人工智能和编程),大多数关于量化投资的文章和书籍都是理论性的和复杂的。在本文中,我想揭开量化投资的神秘面纱,并以简单实用的术语向您展示什么是量化投资以及我们如何去做。本文中的假设:是否有可能创建和实施一个简单的、有效的量化投资交易规则,其表现优于比特币买入和持有投资?我们将看到我们可以在很大程度上超越买入并持有。本文中的任何内容都不是财务建议。所有内容仅供参考和教育目的。没有投资是没有风险的。请务必阅读本文中的关于风险的内容。
2. Data, Information, Knowledge, Wisdom(DIKW)
Quant investing uses data, information and models for investment decisions. The concept of DIKW describes the relationships between Data, Information, Knowledge and Wisdom [2][3]. In my opinion, DIKW aligns beautifully with the four process steps in quant investing. All DIKW steps are equally important: if the data is of low quality, information is low signal, or the correlations are spurious, then the trading rules are useless. Quant investing is both art and science.
2. 数据、信息、知识、智慧
量化投资使用数据、信息和模型进行投资决策。DIKW 的概念描述了数据、信息、知识和智慧之间的关系 [2][3]。在我看来,DIKW 与量化投资的四个流程步骤完美结合。所有 DIKW 步骤都同样重要:如果数据质量差、信息没有体现有意义的信号,或者毫无相关性,那么交易规则就毫无用处。量化投资既是艺术也是科学。
Data
Data consists of facts and observations, which are unorganized and unprocessed. In quant investing, we mainly use price data. Sometimes other data is available, like volume data, order book data (bid-ask) and sentiment data. With bitcoin, we also have a unique and freely available database that contains all on-chain transactions, the bitcoin blockchain. An important aspect is the source and quality of the data. Garbage in is garbage out. I know cases where investment funds failed because of data errors. So I like to have at least two sources for the same data. Data cleaning is another topic. Data can contain errors or missing data. Smoothing is one technique that averages data points to get rid of data errors. Error correction and filtering techniques are interesting areas of research.
数据
数据由无组织和未经处理的事实和监测组成。在量化投资中,我们主要使用价格数据。有时还有其他数据可用,例如交易量数据、订单数据(买卖)和情绪数据。关于比特币,我们还拥有一个独特且可免费使用的数据库,其中包含所有链上交易,即比特币区块链。一个重要方面是数据的来源和质量,进来的是垃圾,得出的结论就是垃圾。我知道投资基金因数据错误而失败的案例。所以我喜欢的数据是至少从两个不同来源得来的。净化数据是另一个话题。数据可能包含错误或缺失数据。“平滑”是一种平均数据以消除数据错误的技术。纠错和过滤技术是有趣的研究领域。
Information
Information is processed and structured data. Examples of information are tables and charts.Processing and transforming data into usable information for analysis is a real art. It requires experience and creativity. If we do data processing correctly, the next step can be straightforward.The data processing step is so critical that it is sometimes called feature http://engineering.In quant investing, we create all kinds of indicators from raw data: patterns, averages, indexes and indicators. Most indexes and indicators are well known and freely available, but some are the secret sauce of quant funds.
信息
信息是经过处理和结构化的数据。信息的示例是表格和图表。处理数据并将其转换为可用信息以供分析是一门真正的艺术。这个需要经验和创造力。如果我们正确地进行数据处理,下一步可以很简单。数据处理步骤非常关键,有时被称为特征工程。在量化投资中,我们从原始数据创建各种指标:模式、平均值、指数和指标。大多数指数和指标都是众所周知的并且可以免费获得,但有些是量化基金的秘密武器。
Knowledge
Knowledge is a combination of information with a goal. It is all about analyzing and modeling patterns between the information available and a target. The goal/target in quant investing is usually the price level or return of a financial asset. Three common analysis/modeling approaches in quant investing:
知识
知识是信息与目标的结合。这一切都是关于分析和建模可用信息和目标之间的模式。量化投资的目标通常是金融资产的价格水平或回报。量化投资中三种常见的分析/建模方法:
(1)Technical Analysis (TA) looks for patterns in historical price charts. TA uses many patterns and indicators that mark momentum, trends and reversals. Examples of TA patterns are flags, triangles, rectangles, wedges, cup&handle, head&shoulders. TA indicator examples are moving averages, relative strength index, Bollinger bands and Ichimoku clouds. Some investors call TA “astrology for men” but most traders use TA in their daily work. A good read on TA is: [4]
(1)技术分析 (TA) ,在历史价格图表中寻找模式。技术分析使用许多标记动量、趋势和反转的模式和指标。技术分析中模式的示例是旗形、三角形、矩形、楔形、杯柄、头肩。技术分析指标示例是移动平均线、相对强度指数、布林带和 云图指标。一些投资者称 技术分析 为“男性的占星术”,但大多数交易者在日常工作中使用 技术分析。关于 技术分析 的好读物是:[4]
(2)Statistics goes beyond just looking for patterns. Statistics applies mathematical techniques to distinguish between random, spurious patterns or nonrandom, statistically significant correlations. Examples of statistical tools used in quant investing are correlation, regression, principle component and cluster analysis. Statistics is not about certainty but uncertainty and probability. Statistics on economic data is called econometrics. Many quant investors have studied econometrics. A great intro to econometrics is: [5].
(2)统计不仅仅是寻找模式。统计学应用数学技术来区分随机的、虚假的模式或非随机的、统计上显着的相关性。量化投资中使用的统计工具的示例是相关性、回归、主成分和聚类分析。统计不是关于确定性,而是关于不确定性和概率。经济数据的统计被称为计量经济学。许多量化投资者研究过计量经济学。计量经济学的一个很好的介绍是:[5]
(3)Artificial Intelligence (AI) is the statistical analysis of big data sets with fast, dedicated computers. AI uses tools like neural nets, genetic algorithms and machine learning. A good book on AI is: [6]. Although AI is great at finding patterns in big datasets, it also amplifies a well-known statistical problem, overfitting. Overfitting happens when an algorithm memorizes a dataset (including the noise) instead of generalizing the underlying signal. Overfitting gives good model performance when making a model but poor model performance on new out-ofsample data. Preventing overfitting is an art in TA, statistics and AI. My preferred solution is to keep the model as simple as possible (few variables, few parameters) and to fit multiple data sets simultaneously (this does require a specialized fitting tool).
(3)人工智能 (AI) 是使用快速、专用的计算机对大数据集进行统计分析。人工智能使用神经网络、遗传算法和机器学习等工具。一本关于人工智能的好书是:[6]。尽管人工智能擅长在大数据集中寻找模式,但它也放大了一个众所周知的统计问题,即过度拟合。当算法记住数据集合(包括噪声)而不是概括基础信号时,就会发生过度拟合。过拟合在制作模型时提供了良好的模型性能,但在新的样本外数据上模型性能较差。防止过度拟合是“技术分析、统计学和人工智能”中的一门艺术。我首选的解决方案是使模型尽可能简单(变量少,参数少)并拟合多个数据同时设置(这确实需要专门的装配工具)。
All models (TA, statistical and AI) are simplifications of reality. So all models are wrong because they are not the same as reality. Models try to generalize instead of memorizing reality. Generalization tries to cut through the noise and capture the underlying signal. There is always some variable different or missing. Models try to capture similarities and structures. Take this simple beach visitor model that predicts the number of beach visitors (y-axis) based on temperature (x-axis):
所有模型(技术分析、统计和人工智能)都是对现实的简化。所以所有模型都是错误的,因为它们和现实不一样。模型试图概括而不是记忆现实。泛化尝试以消除噪声并捕获潜在信号。总是有一些变量不同或失踪。模型试图捕捉相似之处和结构。以这个简单的海滩游客模型为例根据温度(x 轴)预测海滩游客数量(y 轴):
The model shows a positive relationship between temperature and visitors: the higher the temperature, the more visitors. The model is not flawless, it is not always correct and there is uncertainty. Of course, this model does not include all relevant variables like rain, weekends, holidays, etc. For example, the rain could have caused the 87F-130visitors outlier and a holiday weekend could have caused the 89F-525visitors outlier. However, this simple model could be sufficient for beach bar staff planning.
该模型显示温度与游客之间存在正相关关系:温度越高,游客越多。该模型并非完美无缺,它并不总是正确的并且存在不确定性。当然,该模型不包括所有相关变量,如雨、周末、节假日等。例如,下雨可能导致 87F-130visitors 异常值,假期周末可能导致 89F-525 访客异常值。然而,这个简单的模型对于海滩酒吧员工的规划来说已经足够了。
Wisdom
Wisdom is knowledge applied in action. As beach bar owners, we could use the beach visitors model for a staff planning decision rule: IF the temperature is below 88F THEN one person in the bar ELSE two persons in the bar. In quant investing, the decision rule is usually a trading rule (buy&sell) based on a correlation captured by a TA, statistical, or AI model. A crucial step in making quant investing rules is backtesting. Backtesting is evaluating how a trading rule performs over some historical period in terms of risk and return. The holy grail of quant investing is high return with low risk. Most quant investors use risk-adjusted return as a performance criterion. The Sharpe ratio (return divided by the standard deviation of returns), Sortino ratio (return divided by the standard deviation of negative returns) and Calmar ratio (return divided by drawdown) are examples of risk-adjusted return performance criteria.
智慧
智慧是应用在行动中的知识。作为海滩酒吧老板,我们可以使用海滩游客模型来做员工计划决策规则:如果温度低于 88F,那么酒吧里只留一个人,否则酒吧里留两个人。在量化投资中,决策规则通常是基于交易规则(买卖)的由技术分析、统计或人工智能模型捕获的相关性。制定量化投资规则的一个关键步骤是回测。回测是评估交易方式规则在风险和回报方面在某个历史时期内执行。量化投资的圣杯是低风险及高回报。大多数量化投资者使用风险调整后的回报作为业绩标准。夏普比率(回报除以回报的标准差),索提诺比率(回报除以负回报的标准差)和卡尔马比率(回报除以回撤)是风险调整回报绩效标准的例子。
3. Quant Investing Example
Enough theory. Let us create and implement a real-life quant investing trading rule! This trading rule will be simple, only based on monthly bitcoin (BTC) data and the relative strength index (RSI). The goal is to outperform buy&hold BTC. BTC buy&hold: if you had bought 1 BTC in April 2011 for $3.5 and hodled until July 2022, you would have 1 BTC worth $23,322. That is 119% annualized return. However, you would have to stomach big risks, like -82% drawdown (max cumulative loss) in 2014.
3.量化投资示例
理论够了。让我们创建并实施一个真实的量化投资交易规则!此交易规则将很简单,仅基于每月比特币 (BTC) 数据和相对强度指数 (RSI)。目标是跑赢买入和持有 BTC。BTC 买入并持有:如果您在 2011 年 4 月以 3.5 美元的价格购买了 1 个 BTC 并一直持有到 2022 年 7 月,那么您将拥有 1 个价值 23,322 美元的 BTC。那是 119% 的年化回报率。但是,您将不得不承受巨大的风险,例如 2014 年的 -82% 回撤(最大累积损失)。
Data
Our BTC price data source is TradingView. They provide free data and charts [7]. We use January 2011 – July 2022 BTC monthly closing data.
数据
我们的 BTC 价格数据来自 TradingView。他们提供免费的数据和图表 [7]。我们使用 2011 年 1 月至 2022 年 7 月的 BTC 月度收盘数据。
Information
From the BTC monthly closing data, we calculate RSI (14 months). RSI is a well-known TA momentum indicator, calculated as an index with a 0-100 scale [8]. RSI can be used to recognize overbought and oversold conditions. Traditionally, RSI above 70 indicates an overbought situation and RSI below 30 indicates an oversold condition. However, the BTC range is different because BTC RSI can go as high as 90-100 and has never been lower than 40. You can see 2011-2022 RSI going from below 50 to over 90 and back to below 50 again.
根据 BTC 月收盘数据,我们计算 RSI(14 个月)。RSI 是著名的技术分析动量指标,计算为 0-100 范围内的指数 [8]。RSI 可用于识别超买和超卖情况。传统上,RSI 高于 70 表示超买情况,RSI 低于 30 表示超卖情况。但是,BTC 的范围不同,因为 BTC RSI 可以高达 90-100 并且从未低于 40。您可以看到 2011-2022 RSI 从低于 50 到超过 90 并再次回到低于 50。
Knowledge
So how does RSI correlate with our target BTC?
We can see that 2011, 2013, 2017 and 2021 BTC tops correlate with high RSI. Similarly, 2011, 2015, 2018/19 and 2022 BTC bottoms correlate with low RSI. Bull markets seem to run out of steam when RSI>90. Bear markets seem to fizzle out when RSI<50. We can use this pattern for a trading rule that avoids bear markets and outperforms buy&hold BTC.
知识
那么 RSI 与我们的目标 BTC 有什么关系呢?
我们可以看到 2011、2013、2017 和 2021 BTC 顶部与高 RSI 相关。同样,2011、2015、2018/19 和 2022 BTC 底部与低 RSI 相关。当 RSI>90 时,牛市似乎失去了动力。当 RSI<50 时,熊市似乎消失了。我们可以将此模式用于避免熊市并优于买入并持有 BTC 的交易规则。
Wisdom
Optimization over multiple periods on the Calmar ratio results in the following trading rule:IF (RSI was above 90% last six months AND drops below 65%) THEN sell, IF (RSI was below 50% last six months AND jumps +2% from the low) THEN buy, ELSE hold.The trading rule does 8 transactions and turns $3.5 start capital in April 2011 into $229K (10 BTC) in July 2022. 10x buy&hold outperformance, 168% annualized return, and less risk (-57% drawdown).
对卡玛比率的多个时期的优化导致以下交易规则:如果(RSI 过去六个月高于 90% 并且跌至 65% 以下)然后卖出,如果(RSI 过去六个月低于 50% 并且从低点上涨 +2%)那么买入,否则持有。交易规则进行了 8 次交易,并将 2011 年 4 月的 3.5 美元启动资金变成了 22.9 万美元(10 BTC)2022 年 7 月。10 倍的买入和持有表现,年化回报率为 168%,风险更低(-57% 回撤)。
It is exciting that the trading rule gave a BUY signal based on July 2022 BTC closing price!We can make a second/improved implementation by adding a little leverage. Leverage is usually done with futures, but I chose in-the-money (ITM) call options. The benefit of buying options is that no stoploss is needed and positions can not be liquidated. ITM call options have a strike (X) below spot price (S). ITM call option position is determined by aiming for ~4x leverage. The position size is set at 33%.
令人兴奋的是,交易规则基于 2022 年 7 月的 BTC 收盘价给出了买入信号!我们可以通过增加一点杠杆来进行第二次/改进的实施。杠杆通常是做的期货,但我选择了价内看涨期权。购买期权的好处是不需要止损,也不能平仓。价内看涨期权的行使价 (X) 低于现货价格(S)。价内看涨期权头寸是通过以约 4 倍杠杆为目标来确定的。仓位大小设置为33%。
The implementation with options/leverage turns $3.5 start capital in April 2011 into $5M (214 BTC) in July 2022. 214x buy&hold outperformance, 252% annualized return, and less risk (-58% drawdown).In this example, I use call options with 4x leverage and a position size of only 33%. This means 67% of the portfolio is in cash, with little risk. Even if there is a month with a very negative BTC return and the call option expires worthless, our maximum loss would still be only -33% per month.
期权/杠杆的实施将 2011 年 4 月的 3.5 美元启动资金在 2022 年 7 月变成了 500 万美元(214 BTC)。214 倍的买入和持有表现优异,年化回报率为 252%,风险更低(-58% 回撤)。在此示例中,我使用看涨期权 具有 4 倍杠杆和仅 33% 的头寸规模的期权。这意味着 67% 的投资组合是现金,风险很小。即使有一个月的 BTC 回报率非常负且看涨期权到期时毫无价值,我们的最大损失仍仅为每月 -33%。
4. DIY
Since it is all about out-of-sample performance, I will implement the trading rule with and without leverage. On Twitter, I will inform you about RSI buy and sell signals, spot (no leverage) and option (leverage) positions and out-of-sample performance of the trading rule.You can copy my trades and do it yourself (DIY) with the tweets and/or the trading rule above. Bybit exchange has a great BTC options market. That is why I use Bybit for implementation. They also have email-only sign-up without KYC (for withdraws below 2 BTC per day). You can create a Bybit account using my referral link: https://partner.bybit.com/b/planb
4. 自己动手做
由于这完全是关于样本外的表现,我将在有或没有杠杆的情况下执行交易规则。在 Twitter 上,我将通知您有关 RSI 买卖信号、现货(无杠杆)和期权(杠杆)头寸和交易规则的样本外表现。您可以使用上面的推文和/或交易规则复制我的交易并自己动手(DIY)。Bybit 交易所拥有巨大的 BTC 期权市场。这就是我使用 Bybit 实现的原因。他们也在没有 KYC 的情况下仅通过电子邮件注册(对于每天低于 2 BTC 的提款)。您可以使用我的推荐链接创建一个 Bybit 帐户:https://partner.bybit.com/b/planb
5. Risks, Disclosures & Disclaimers
No investment is without risk. Risks in this quant investing example are (but not limited to):
• Data: the data could contain errors.
• Information: the calculation of RSI could be wrong.
• Knowledge: the correlation between RSI and BTC could be spurious.
• Wisdom: overfitting of the trading rule, the backtest could be wrong, there could be black swansand past performance is no guarantee of future results.
• Trading: there is credit risk on exchanges (“not your keys not your coins”).
• Do not invest or trade more than you are willing and able to lose.
• I do not promise or guarantee anything.
5. 风险、披露和免责声明
没有投资是没有风险的。这个量化投资示例中的风险是(但不限于):
• 数据:数据可能包含错误。
• 信息:RSI 的计算可能有误。
• 知识:RSI 和BTC 之间的相关性可能是虚假的。
• 智慧:交易规则过拟合,回测可能出错,可能出现黑天鹅,过去的表现并不能保证未来的结果。
• 交易:交易所存在信用风险(“不是你的钥匙,不是你的硬币”)。
• 不要投资或交易超过您愿意和能够损失的金额。
• 我不承诺或保证任何事情。
Disclosures and disclaimers:
• My BTC portfolio is 90% buy&hold and only 10% trading (mainly because of credit risk).
• I partner with Bybit exchange.
• Nothing in this article is financial advice.
• All content is for informational and educational purposes only.
• Past performance is no guarantee of future results.
披露和免责声明:
• 我的 BTC 投资组合是 90% 的买入和持有,只有 10% 的交易(主要是因为信用风险)。
• 我与Bybit 交易所合作。
• 本文中的任何内容都不是财务建议。
• 所有内容仅供参考和教育目的。
• 过去的表现并不能保证将来的结果。
6. Conclusion
The hypothesis in this article is: is it possible to create and implement a simple working quant investing trading rule that outperforms a bitcoin buy&hold investment?
Following a four-step DIKW (Data, Information, Knowledge, Wisdom) process, we are able to
construct a simple trading rule based on RSI that outperforms buy&hold BTC. We also backtest an
implementation with call options (4x leverage and 33% position size) that performs even better.
• BTC buy&hold: if you had bought 1 BTC in April 2011 for $3.5 and hodled until July 2022,
you would have 1 BTC worth $23,322 (119% annualized return, with -82% max drawdown.
• The trading rule does 8 transactions and turns $3.5 start capital in April 2011 into $229K (10
BTC) in July 2022 (10x buy&hold outperformance, 168% annualized return, -57% drawdown).
• The implementation with options/leverage turns $3.5 capital in April 2011 into $5M (214 BTC)
in July 2022 (214x buy&hold outperformance, 252% annualized return, -58% drawdown).
Since it is all about out-of-sample performance, I will implement the trading rule with and without
leverage. On Twitter, I will inform you about RSI buy and sell signals, spot (no leverage) and option
(leverage) positions and out-of-sample performance of the trading rule.
It is exciting that the trading rule gave a BUY signal based on BTC July 2022 closing price!
Nothing in this article is financial advice. All content is for informational and educational purposes
only. No investment is without risk. Make sure you read the risk paragraph in this article.
6. 结论
本文中的假设是:是否有可能创建和实施一个简单的工作量化投资交易规则优于比特币买入并持有投资?
遵循四步 DIKW(数据、信息、知识、智慧)流程,我们能够构建一个基于 RSI 的简单交易规则,其表现优于买入并持有 BTC。我们还回测了一个使用表现更好的看涨期权(4 倍杠杆和 33% 头寸规模)实施。
• BTC 买入并持有:如果您在 2011 年 4 月以 3.5 美元的价格买入 1 个 BTC 并持有至 2022 年 7 月,你将拥有价值 23,322 美元的 1 BTC(119% 的年化回报,最大回撤 -82%)
• 交易规则进行 8 次交易,并将 2011 年 4 月的 3.5 美元启动资金变成 22.9 万美元(10BTC)在 2022 年 7 月(10 倍买入和持有表现优异,168% 年化回报,-57% 回撤)。
• 期权/杠杆的实施将 2011 年 4 月的 3.5 美元资本变为 500 万美元(214 BTC)2022 年 7 月(买入并持有 214 倍表现优异,年化回报率为252%,回撤 -58%)。
由于这完全是关于样本外的表现,我将在有和没有的情况下实施交易规则
杠杆作用。在 Twitter 上,我将通知您有关 RSI 买卖信号、现货(无杠杆)和期权(杠杆)头寸和交易规则的样本外表现。
令人兴奋的是,交易规则基于 BTC 2022 年 7 月的收盘价给出了买入信号!
本文中的任何内容都不是财务建议。所有内容仅供参考和教育目的
只要。没有投资是没有风险的。确保您阅读了本文中的风险段落。
7. References
[1] Eliot, T. S. (1934) “Choruses from The Rock”.
[2] Boulding, Kenneth (1955). “Notes on the Information Concept”. Exploration.
[3] Henry, Nicholas L. (1974). “Knowledge Management: A New Concern for Public Administration”.
[4] Faith, Curtis (2007). “Way of the Turtle”.
[5] Verbeek, M. (2004). “A Guide to Modern Econometrics”.
[6] Vinod Chandra & Anand Hareendran (2014). “Artificial Intelligence and Machine Learning”.
[7] https://www.tradingview.com
[8] J. Welles Wilder Jr. (1978). “New Concepts in Technical Trading Systems”. Trend Research.
7. 参考文献
[1] Eliot, T. S. (1934) “摇滚合唱”。
[2] Boulding, Kenneth (1955)。“关于信息概念的注释”。勘探。
[3] Henry, Nicholas L.(1974)。“知识管理:公共管理的新关注点”。
[4] Faith, Curtis (2007)。“乌龟之路”。
[5] Verbeek, M. (2004)。《现代计量经济学指南》。
[6] inod Chandra & Anand Hareendran (2014)。“人工智能与机器学习”。
[7] https://www.tradingview.com
[8] J. Welles Wilder Jr. (1978)。“技术交易系统的新概念”。趋势研究。