@Channelchan
2017-07-08T15:47:11.000000Z
字数 789
阅读 35957
统计套利是根据价差同时买入与卖出一样或极为相似的品种。
跨市场套利: 不同市场的相同或相似资产
期现套利: 期货与现货市场
跨期套利: 同一品种不同月份期限的合约
跨品种套利: 品种不同但高度相关
期权套利: 蝶式鹰式
价差区间超买超卖交易(买弱卖强)
在上安全边际买入弱的卖出强的
反向交易(买强卖弱)
在上穿均值后买入强的卖出弱的
在更强的位置重复加仓
在穿越安全边际后继续做空价差
def init(context):
context.s1 = '002290.XSHE'
context.s2 = '002508.XSHE'
def handle_bar(context, bar_dict):
his1 = history_bars(context.s1, 50, '1d', 'close')
his2 = history_bars(context.s2, 50, '1d', 'close')
beta, alpha = np.polyfit(his1,his2,1)
spread = his2 - (beta*his1+alpha)
z_score = (spread-spread.mean())/spread.std()
print z_score
try:
if z_score[-1]>1:
order_target_percent(context.s1, 1)
order_target_percent(context.s2, 0)
elif z_score[-1]<-1:
order_target_percent(context.s2, 1)
order_target_percent(context.s1, 0)
except KeyError:
pass
notebook链接: http://localhost:8889/tree/Class_5_Statistical_Arbitrage