Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_drawdown incorrect if drawdown begins on first day of returns time series #179

Closed
a-campbell opened this issue Oct 22, 2015 · 2 comments

Comments

@a-campbell
Copy link
Contributor

Because we take cum_returns(returns, starting_value=1) to form the NAV time series off of which we calculate max drawdown, the first value of the NAV used in the max drawdown calculation is the portfolio value at the end of the first trading day. This means that when the first trading day is the first day of the max drawdown, we are not counting that day's loss in that max drawdown stat.

For example:

If the first trading day results in a 10% loss and subsequent trading days lead to a total 25% loss, we will be calculating max drawdown as:
(.90 - 0.75) / 0.90 = 0.16666666

when we should be calculating it as:
(1.0 - 0.75) / 1.0 = 0.25

I think the fix might be to append a dummy day with a value of 1 to the beginning of the df_cum time series in cum_returns in the case where there is no NaN in the first iloc.

@a-campbell a-campbell added the bug label Oct 22, 2015
@a-campbell a-campbell changed the title max_drawdown incorrect if drawdown begins on first day of backtest max_drawdown incorrect if drawdown begins on first day of returns time series Oct 22, 2015
@brdsio
Copy link
Contributor

brdsio commented May 11, 2016

I think this issue can be closed.

@twiecki
Copy link
Contributor

twiecki commented May 11, 2016

👍

@twiecki twiecki closed this as completed May 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants