I have minute by minute a panda dataframe df. I'm looking to apply weighting to Return and compute a rolling weighted standard deviation, with window = 10. I can calculate non-weighted std, annualized with:
df_spy['10mVol'] = df_spy['Return'].rolling(center=False,window=10).std()*(1440*252)**(0.5)*100
There is another question asking for weighted std in Numpy, but i'm curious on the rolling weighted stdev. (Weighted standard deviation in NumPy?)
The formula for calculating weighted standard deviation is: https://math.stackexchange.com/questions/320441/standard-deviation-of-the-weighted-mean
weighting Midpoint Return 10mVol Weighted
0.2 215.6700 NaN NaN NaN
0.8 215.8400 -0.000788 NaN -0.000630
0.8 216.0600 -0.001019 NaN -0.000815
Thanks for helping