Forked from lamres/TrendBreakerPL_plotting_pyfolio.py
Created
November 4, 2021 00:34
-
-
Save santatic/f4d766b4f5f6c74a7f6bb7ccc681ae73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_worst_drawdown_periods(returns, top=5): | |
""" | |
Prints information about the worst drawdown periods. | |
Prints peak dates, valley dates, recovery dates, and net | |
drawdowns. | |
Parameters | |
---------- | |
returns : pd.Series | |
Daily returns of the strategy, noncumulative. | |
- See full explanation in tears.create_full_tear_sheet. | |
top : int, optional | |
Amount of top drawdowns periods to plot (default 5). | |
""" | |
drawdown_df = timeseries.gen_drawdown_table(returns, top=top) | |
return drawdown_df.sort_values('Net drawdown in %', ascending=False) | |
''' | |
utils.print_table( | |
drawdown_df.sort_values('Net drawdown in %', ascending=False), | |
name='Worst drawdown periods', | |
float_format='{0:.2f}'.format, | |
) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment