Quant Buffet放轻松,别过度思虑

政治不确定性与商品价格

登录后收藏

学术论文

Political Uncertainty and Commodity Prices

作者Political Uncertainty and Commodity Prices [点击查看论文]

机构
  • ?Ohio State University (OSU) - Department of Finance
  • Tsinghua University
  • ?Institute of Economics, School of Social Sciences, Tsinghua University
  • Chinese University of Hong Kong, Shenzhen
  • ?The Chinese University of Hong Kong, Shenzhen

策略概要

该策略的目标是78种商品,但也可以使用单一商品指数工具(例如ETF、期货、掉期)进行操作。在美国总统大选季度之前的6月30日做空商品,并在9月30日平仓,以利用潜在的选举驱动市场动态。

II. 策略合理性

商品价格在美国总统大选前下跌,原因是企业和家庭需求减少,导致负回报。选举后价格没有反弹,可能是由于新政策的时机和实施存在挥之不去的不确定性。这种效应在各国和商品类别中都很普遍,特别是对于全球一体化的商品以及在民意调查胶着的激烈选举中。这种效应在经济衰退期间会加剧。美国总统大选是政治不确定性的一个代表,因为美国拥有最大的经济体、商品期货市场,并且是最大的商品消费国。此外,选举时间是固定的,与经济状况无关,从而将政治不确定性与其他风险隔离开来。

回测表现

夏普比率-0.47
索提诺比率-0.174
胜率38%

完整 Python 代码

from AlgorithmImports import *
class PoliticalUncertainty(QCAlgorithm):
def Initialize(self):
 self.set_start_date(1996, 1, 1)
 self.set_cash(100_000)
 
 self.symbol: Symbol = self.add_data(QuantpediaFutures, 'CME_GI1', Resolution.DAILY).symbol
 self.securities[self.symbol].set_fee_model(CustomFeeModel())
 self.securities[self.symbol].set_leverage(2)
 
 self.schedule.on(self.date_rules.month_end(self.symbol), self.time_rules.at(0, 0), self.rebalance)
def rebalance(self) -> None:
 if self.time.date() > QuantpediaFutures.get_last_update_date()[self.symbol.value]:
     self.liquidate()
     return
 year = self.time.year
 if year % 4 == 0:   # every 4th year
     if self.time.month == 6:
         self.set_holdings(self.symbol, -1)
     elif self.time.month == 9:
         if self.portfolio.invested:
             self.liquidate()
     
# Quantpedia data
# NOTE: IMPORTANT: Data order must be ascending (datewise)
class QuantpediaFutures(PythonData):
_last_update_date: Dict[str, datetime.date] = {}
@staticmethod
def get_last_update_date() -> Dict[str, datetime.date]:
return QuantpediaFutures._last_update_date
def GetSource(self, config:SubscriptionDataConfig, date:datetime, isLiveMode:bool) -> SubscriptionDataSource:
 return SubscriptionDataSource("data.quantpedia.com/backtesting_data/futures/{0}.csv".format(config.Symbol.Value), SubscriptionTransportMedium.RemoteFile, FileFormat.Csv)
def Reader(self, config:SubscriptionDataConfig, line:str, date:datetime, isLiveMode:bool) -> BaseData:
 data = QuantpediaFutures()
 data.Symbol = config.Symbol
 
 if not line[0].isdigit(): return None
 split = line.split(';')
 
 data.Time = datetime.strptime(split[0], "%d.%m.%Y") + timedelta(days=1)
 data['back_adjusted'] = float(split[1])
 data['spliced'] = float(split[2])
 data.Value = float(split[1])
 # store last update date
 if config.Symbol.Value not in QuantpediaFutures._last_update_date:
     QuantpediaFutures._last_update_date[config.Symbol.Value] = datetime(1,1,1).date()
 if data.Time.date() > QuantpediaFutures._last_update_date[config.Symbol.Value]:
     QuantpediaFutures._last_update_date[config.Symbol.Value] = data.Time.date()
 return data
# Custom fee model
class CustomFeeModel(FeeModel):
def GetOrderFee(self, parameters):
 fee = parameters.Security.Price * parameters.Order.AbsoluteQuantity * 0.00005
 return OrderFee(CashAmount(fee, "USD"))