The first generation of CTA trading systems appeared in the 1960s and 1970s. The CTA strategy gained considerable returns at the time due to the strong trends in the commodity market at the time. The strong trends in the commodity market during this period can be attributed to continued economic growth and rising inflation after World War II. Strong trend markets allowed simple trend tracking systems to achieve better returns.
The strategies used in the first generation trading system are those that are now familiar to trend-tracking strategies, such as moving average systems (plus some simple filtering conditions, such as when the short-term moving average exceeds the long-term moving average or vice versa), a simple trend-tracking strategy can effectively play out the continuity of the fundamental trends of the trading objective. Ongoing economic growth, inflation and the oil crisis are the reasons behind this continuity. However, when many traders use the same strategies and the fundamental continuity of trading no longer exists, the first generation strategy needs to evolve to adapt to the new environment.
Due to the decoupling of the dollar and gold, the financial futures market grew rapidly between 1970 and 1980, allowing futures management funds to participate in many futures markets, including the money market, bond market, stock index futures, and stock financial derivatives. In addition, the development of information technology and low costs made it easy to access data during the day. The increase in the size of the funds entering CTA funds and the intensification of competition made CTA strategies more complex and adaptable.
Based on the above market characteristics, the second generation CTA trading system and strategy has the following characteristics compared to the first generation CTA strategy:
More diversified trading topics. The inclusion of financial futures markets makes trading varieties and markets more diverse.
On top of trading strategies, the strategies of the second generation CTA trading system are not limited to pure trend tracking and price breakouts. More mathematical models are applied to monitor multiple markets. Trend tracking is used depending on different market conditions or average response strategies. Continuous periods of low volatility in the futures market have also emerged due to the liquidity of many institutions involved in the futures market.
The second generation CTA strategy allows for short-term trading in the trading window and holding time. Unlike the first generation CTA strategy, the second generation strategy has begun to monitor the intraday trading patterns of short and high-frequency trading. This feature stems from the development of computer technology, which makes the provision of financial data more timely and frequent.
The third generation CTA trading system is a further diversification, decentralization and more adaptability of the second generation trading system. The third generation CTA uses more trading systems to trade more markets and varieties. Strategically, it uses more profitable market models. All of these are based on a combination of multiple models operating in multiple markets.
Given the wide use of CTA strategies, combined with the dullness of time, and very mature, is the classic strategy model that a large number of traders are widely exposed to and want to understand (especially for beginners), inventors of quantitative platforms have developed a library of standard CTA strategies early on, readers of inventors of quantitative platforms if you want to apply the CTA strategy, just simply copy the code code in the past, or directly refer to this library.
The extensibility is also very convenient, the annotations of the code are very clear and simple to understand, and if you want to do deep customization or extension, just do it directly in the existing framework.
Some of the source code (JavaScript version):
function main() {
$.CTA(exchanges[0], 0.01, function(r, mp, pair){ // 第一个参数是要做的交易所对象,第二个参数0.01是交易所要求的最小下单数量,第三个匿名函数function(){...}是回调函数,交易逻辑就写在这个函数中,该回调函数第一个参数r接收最新的K线数据,第二个参数接收持仓数,第三个参数接收交易对名称
if (r.length < 20) { // 判断K线柱数量
return
}
var emaSlow = TA.EMA(r, 20)
var emaFast = TA.EMA(r, 5)
var cross = _Cross(emaFast, emaSlow); // 判断指标相交状态,_Cross参看:https://www.fmz.com/bbs-topic/1140
if (mp <= 0 && cross > 1) {
Log(pair, "买, 金叉周期", cross, "mp:", mp);
return 0.1 * (mp < 0 ? 2 : 1) // 返回的数值就是要开仓的数量,正数是 开多,负数是开空,0是全部平掉。
} else if (mp >= 0 && cross < -1) {
Log(pair, "卖, 死叉周期", cross, "mp:", mp);
return -0.1 * (mp > 0 ? 2 : 1)
}
})
}
For more source code and full class libraries, please see:https://www.fmz.com/strategy/57267