# 1、过去m_days=25天的动量
df = attribute_history(etf, m_days, '1d', ['close'])
y = df['log'] = np.log(df.close)
x = df['num'] = np.arange(df.log.size)
slope, intercept = np.polyfit(x, y, 1)
annualized_returns = math.pow(math.exp(slope), 250) - 1
r_squared = 1 - (sum((y - (slope * x + intercept))**2) / ((len(y) - 1) * np.var(y, ddof=1)))
score = annualized_returns * r_squared
---annualized_returns是年化收益的意思吗?有些不理解,似乎缺少exp(b),我的计算为:
annualized_returns =math.exp(intercept)*(math.pow(math.exp(slope), 250) - 1)
2023-11-11