- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
Closed
Description
Code first:
import pandas as pd
import talib as ta
import numpy as np
df = pd.DataFrame(np.random.randn(11), columns=['Values'])
df["pandas-std"] = pd.rolling_std(df["Values"], window=10)
df["talib-std"] = ta.STDDEV(df["Values"].values, timeperiod=10)
print dfAbove gives:
      Values  pandas-std  talib-std
0   0.684808         NaN        NaN
1   0.613100         NaN        NaN
2  -0.016941         NaN        NaN
3  -0.519221         NaN        NaN
4   2.147814         NaN        NaN
5  -0.393357         NaN        NaN
6   0.123275         NaN        NaN
7   0.707619         NaN        NaN
8   2.157508         NaN        NaN
9  -0.138655    0.954126   0.905163
10 -0.028071    0.968347   0.918655
Using independent calculations, I come to the conclusion that TA-Lib calculates standard deviation based on population (divided by n) rather than by sample (divided by n-1).
Can an option be possibly added to STDDEV such that it's possible to switch between sample and population computations? The former is what's needed for calculating historical volatility.
Metadata
Metadata
Assignees
Labels
No labels