pyfolio icon indicating copy to clipboard operation
pyfolio copied to clipboard

Export Tear Sheet/Save Values to variables

Open ElliotP123 opened this issue 6 years ago • 1 comments

Afternoon,

This is an amazing package, thank you so much for it. I am trying to export the values calculated for the full tear sheet. I have tried to save the result to a variable but it doesn't seem to work. When I had a look at the code it seems to print calculated values, but I couldn't see the code which calculates things like "annual return", "cumulative return" and presents a figure.

Would somebody be able to point me in the right direction to access those calculated values? Or would it be easier to calculate my own tear sheet from the positions, transactions, etc?

Kind Regards

ElliotP123 avatar Oct 28 '18 21:10 ElliotP123

Hi,

After inspecting the docs a bit, I might have found a solution useful for you: from pyfolio import timeseries perf_func = timeseries.perf_stats perf_stats_all = perf_func( returns=your_portfolio_returns_as_a_pdSeries, factor_returns=your_benchmark_returns_as_a_pdSeries, positions=None, transactions=None, turnover_denom="AGB")

"perf_stats_all" is a pd.Series that reports the values for: ['Annual return', 'Cumulative returns', 'Annual volatility', 'Sharpe ratio', 'Calmar ratio', 'Stability', 'Max drawdown', 'Omega ratio', 'Sortino ratio', 'Skew', 'Kurtosis', 'Tail ratio', 'Common sense ratio', 'Daily value at risk', 'Alpha', 'Beta']

abk11 avatar Dec 03 '18 12:12 abk11