robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.24k stars 927 forks source link

Function to calculate stdevs from historical price or return data #566

Open wayner9 opened 8 months ago

wayner9 commented 8 months ago

PyPortfolioOpt will calculate historical return information and can generate a covariance matrix given prices or returns. It can also generate a covariance matrix given a correlation matrix and stdevs. But what about the stdevs? Is there a function to calculate stdevs from historical returns? I don't see this?

You could derive the stdevs taking the square root of the diagonal elements of the covariance matrix, but why not provide a direct function to calculate stdevs? It could be useful to generate a report for a bunch of assets showing the historical return and the stdev (aka volatility) for each asset.