def getVol(ret):
'''
calculate volatility value of log return ratio
:param DataFrame ret: return value
:param int interval: interval over which volatility is calculated
:return: DataFrame standard_error: volatility value
'''
print '''*************************************************************************************
a kind WARNING from the programmer(not the evil interpreter) function getVol:
we have different values for interval in test code and real code,because the sample file
may not have sufficient rows for real interval,leading to empty matrix.So be careful of
the value you choose
**************************************************************************************
'''
# real value
# interval = 26
# test value
interval = 4
standard_error = pd.rolling_std(ret, interval)
standard_error.dropna(inplace=True)
standard_error.index = range(standard_error.shape[0])
return standard_error
评论列表
文章目录