“该策略投资于24种美国期货合约,包括4种货币、5种金融产品、8种农产品和7种大宗商品。使用周三至周三的时间框架,通常选择最近的期货合约,交割月时滚动至次近月合约。合约被定义为高(低)交易量,取决于其交易量变化是否高于(低于)所有合约交易量变化的中位数。合约根据未平仓合约变化分为高未平仓合约组和低未平仓合约组,投资者在高交易量、低未平仓合约组中选择上周回报最低的期货做多,并在上周回报最高的期货做空,合约权重与其过去一周的回报差异成正比。”
资产类别:差价合约、期货 | 地区:美国 | 频率:每周 | 市场:债券、大宗商品、货币、股票 | 关键词:反转
策略概述
该策略的投资范围包括24种美国期货合约(4种货币、5种金融产品、8种农产品、7种大宗商品)。使用周三至周三的时间框架。通常选择离到期日最近的期货合约,除非该合约已经进入交割月,此时选择次近月合约。在交割月开始时,滚动至次近月合约。
合约被定义为高(低)交易量合约,如果该合约的交易量从t-1到t期间的变化高于(低于)所有合约交易量变化的中位数(通过将每周交易量除以其样本均值进行趋势调整,使交易量在不同市场中具有可比性)。
所有合约根据未平仓合约变化分为高未平仓合约组(未平仓合约变化排名前50%)和低未平仓合约组(未平仓合约变化排名后50%)。根据t-1到t和t-2到t-1期间的未平仓合约变化进行分组。投资者在高交易量、低未平仓合约组中选择上周回报最低的期货做多,而在上周回报最高的期货做空。每个合约的权重与该合约过去一周的回报与该期间N个合约(每组的合约数量)的等权重平均回报之间的差异成正比。
策略合理性
短期回报可预测性的证据与“过度反应假说”一致,即交易者对新闻的反应超过了基本面所支持的程度。过度自信和过度反应通常伴随着大量交易,并与价格反转的幅度正相关。因此,由于市场中的非理性引发了市场效率低下,导致交易量与预期回报之间存在负相关关系。未平仓合约代表了套期保值者或对冲活动的非信息性交易,因此也是市场状态的重要决定因素。
论文来源
A Comparison of Short-Term Mean-Reversion Indicators for Global Equities [点击浏览原文]
- Raymond Micaletti, Relative Sentiment Technologies, LLC
<摘要>
我们研究了全球股票市场中的一系列短期均值回归指标。这些指标包括技术分析领域最广为人知的价格振荡指标,以及作者在2009-2010年首次开发的若干改进版本。通过从广泛的指标参数、触发阈值和持有期构建简单的交易策略,我们发现改进的振荡指标在市场的多头和空头两侧的表现排名中占据主导地位。因此,本研究可以作为日内交易者、波段交易者甚至资产管理者在再平衡时更好把握时机的参考。


回测表现
| 年化收益率 | 29.64% |
| 波动率 | 31.4% |
| Beta | -0.02 |
| 夏普比率 | -0.088 |
| 索提诺比率 | -0.107 |
| 最大回撤 | 54.2% |
| 胜率 | 47% |
完整python代码
from AlgoLib import *
from collections import deque
import numpy as np
import data_tools
#endregion
class ShortTermReversalwithFutures(XXX):
def Initialize(self):
self.SetStartDate(2010, 1, 1)
self.SetCash(100000)
symbols:Dict[str, str] = {
'CME_S1': Futures.Grains.Soybeans,
'CME_W1': Futures.Grains.Wheat,
'CME_BO1': Futures.Grains.SoybeanOil,
'CME_C1': Futures.Grains.Corn,
'CME_LC1': Futures.Meats.LiveCattle,
'CME_FC1': Futures.Meats.FeederCattle,
'CME_KW2': Futures.Grains.Wheat,
'ICE_CC1': Futures.Softs.Cocoa,
'ICE_SB1': Futures.Softs.Sugar11CME,
'CME_GC1': Futures.Metals.Gold,
'CME_SI1': Futures.Metals.Silver,
'CME_PL1': Futures.Metals.Platinum,
'CME_RB1': Futures.Energies.Gasoline,
'ICE_WT1': Futures.Energies.CrudeOilWTI,
'ICE_O1': Futures.Energies.HeatingOil,
'CME_BP1': Futures.Currencies.GBP,
'CME_EC1': Futures.Currencies.EUR,
'CME_JY1': Futures.Currencies.JPY,
'CME_SF1': Futures.Currencies.CHF,
'CME_ES1': Futures.Indices.SP500EMini,
'CME_TY1': Futures.Financials.Y10TreasuryNote,
'CME_FV1': Futures.Financials.Y5TreasuryNote,
}
self.period:int = 14
self.futures_info:Dict = {}
min_expiration_days:int = 2
max_expiration_days:int = 360
# daily close, volume and open interest data
self.data:Dict = {}
self.quantile:int = 2
for qp_symbol, qc_future in symbols.items():
# QP futures
data:Security = self.AddData(data_tools.QuantpediaFutures, qp_symbol, Resolution.Daily)
data.SetFeeModel(data_tools.CustomFeeModel())
data.SetLeverage(5)
self.data[data.Symbol] = deque(maxlen=self.period)
# QC futures
future:Future = self.AddFuture(qc_future, Resolution.Daily)
future.SetFilter(timedelta(days=min_expiration_days), timedelta(days=max_expiration_days))
self.futures_info[future.Symbol.Value] = data_tools.FuturesInfo(data.Symbol)
self.recent_month:int = -1
self.Settings.MinimumOrderMarginPortfolioPercentage = 0.
def find_and_update_contracts(self, futures_chain, symbol) -> None:
near_contract:FuturesContract = None
if symbol in futures_chain:
contracts:List = [contract for contract in futures_chain[symbol] if contract.Expiry.date() > self.Time.date()]
if len(contracts) >= 2:
contracts:List = sorted(contracts, key=lambda x: x.Expiry, reverse=False)
near_contract = contracts[0]
self.futures_info[symbol].update_contracts(near_contract)
def OnData(self, data: Slice) -> None:
if data.FutureChains.Count > 0:
for symbol, futures_info in self.futures_info.items():
# check if near contract is expired or is not initialized
if not futures_info.is_initialized() or \
(futures_info.is_initialized() and futures_info.near_contract.Expiry.date() <= self.Time.date()):
self.find_and_update_contracts(data.FutureChains, symbol)
rebalance_flag:bool = False
ret_volume_oi_data:Dict[Symbol, Tuple[float]] = {}
# roll return calculation
for symbol, futures_info in self.futures_info.items():
# futures data is present in the algorithm
if futures_info.quantpedia_future in data and data[futures_info.quantpedia_future]:
# new month rebalance
if self.Time.month != self.recent_month and not self.IsWarmingUp:
self.recent_month = self.Time.month
rebalance_flag = True
if futures_info.is_initialized():
near_c:FuturesContract = futures_info.near_contract
if self.Securities.ContainsKey(near_c.Symbol):
# store daily data
price:float = data[futures_info.quantpedia_future].Value
vol:int = self.Securities[near_c.Symbol].Volume
oi:int = self.Securities[near_c.Symbol].OpenInterest
if price != 0 and vol != 0 and oi != 0:
self.data[futures_info.quantpedia_future].append((price, vol, oi))
if rebalance_flag:
if len(self.data[futures_info.quantpedia_future]) == self.data[futures_info.quantpedia_future].maxlen:
# performance
prices:List[float] = [x[0] for x in self.data[futures_info.quantpedia_future]]
half:List[float] = int(len(prices)/2)
prices:List[float] = prices[-half:]
ret:float = prices[-1] / prices[0] - 1
# volume change
volumes:List[int] = [x[1] for x in self.data[futures_info.quantpedia_future]]
volumes_t1:List[int] = volumes[-half:]
t1_vol_mean:float = np.mean(volumes_t1)
t1_vol_total:float = sum(volumes_t1) / t1_vol_mean
volumes_t2:List[int] = volumes[:half]
t2_vol_mean:float = np.mean(volumes_t2)
t2_vol_total:float = sum(volumes_t2) / t2_vol_mean
volume_weekly_diff:float = t1_vol_total - t2_vol_total
# open interest change
interests:List[int] = [x[2] for x in self.data[futures_info.quantpedia_future]]
t1_oi:List[int] = interests[-half:]
t1_oi_total:float = sum(t1_oi)
t2_oi:List[int] = interests[:half]
t2_oi_total:float = sum(t2_oi)
oi_weekly_diff:float = t1_oi_total - t2_oi_total
# store weekly diff data
ret_volume_oi_data[futures_info.quantpedia_future] = (ret, volume_weekly_diff, oi_weekly_diff)
if rebalance_flag:
weight:Dict[Symbol, float] = {}
if len(ret_volume_oi_data) > self.quantile * 2:
volume_sorted:List = sorted(ret_volume_oi_data.items(), key = lambda x: x[1][1], reverse = True)
quantile:int = int(len(volume_sorted) / self.quantile)
high_volume:List = [x for x in volume_sorted[:quantile]]
open_interest_sorted:List = sorted(ret_volume_oi_data.items(), key = lambda x: x[1][2], reverse = True)
quantile = int(len(open_interest_sorted) / self.quantile)
low_oi:List = [x for x in open_interest_sorted[-quantile:]]
filtered:List = [x for x in high_volume if x in low_oi]
filtered_by_return:List = sorted(filtered, key = lambda x : x[0], reverse = True)
quantile = int(len(filtered_by_return) / self.quantile)
long:List[Symbol] = filtered_by_return[-quantile:]
short:List[Symbol] = filtered_by_return[:quantile]
if len(long + short) >= 2:
# return weighting
diff:Dict[Symbol, float] = {}
avg_ret:float = np.average([x[1][0] for x in long + short])
for symbol, ret_volume_oi in long + short:
diff[symbol] = ret_volume_oi[0] - avg_ret
total_diff:float = sum([abs(x[1]) for x in diff.items()])
long_symbols:List[Symbol] = [x[0] for x in long]
if total_diff != 0:
for symbol, data in long + short:
if symbol in long_symbols:
weight[symbol] = diff[symbol] / total_diff
else:
weight[symbol] = - diff[symbol] / total_diff
# trade execution
invested:List[Symbol] = [x.Key for x in self.Portfolio if x.Value.Invested]
for symbol in invested:
if symbol not in weight:
self.Liquidate(symbol)
for symbol, w in weight.items():
self.SetHoldings(symbol, w)
