Created
March 17, 2020 17:40
-
-
Save lamres/69006be9794d9e359643e2a28538a95f 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