@宏观经济占卜师
get_EMA这个函数直接用下面的方式写可以吗?这样可以省掉了 get_MA函数,并且不需要使用g.EMAs字典,回测的结果又一点点差别,但是差别不大。请大神帮忙鉴定一下
```
def get_EMA(security_code,days,data):
# 如果只有一天的话,前一天的收盘价就是移动平均
if days==1:
# 获得前两天的收盘价数据,一个作为上一期的移动平均值,后一个作为当期的移动平均值
t = attribute_history(security_code, 2, '1d', ('close'))
return t['close'][-2],t['close'][-1]
elif days==60:
t60_now = attribute_history(security_code, 60, '1d', ('close'))
t60_pre = attribute_history(security_code, 61, '1d', ('close'))
t60_now_mean = t5['close'].mean()
t60_pre_mean = t6['close'][:-1].mean()
return t60_pre_mean,t60_now_mean
```
2017-03-06