Skip to content

'Buy & Hold Return [%]' never seem to return negative values #36

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

Closed
a-holm opened this issue Jan 4, 2020 · 3 comments
Closed

'Buy & Hold Return [%]' never seem to return negative values #36

a-holm opened this issue Jan 4, 2020 · 3 comments
Labels
wontfix This will not be worked on

Comments

@a-holm
Copy link

a-holm commented Jan 4, 2020

Expected Behavior

bt.run() should produce statistics where 'Buy & Hold Return [%]' returns a negative value.

Actual Behavior

'Buy & Hold Return [%]' always returns a positive value

Steps to Reproduce

  1. Get data where you know 'Buy & Hold Return [%]' returns a negative value. Put it into a pandas dataframe like normal (called df).
  2. run something like this:
bt = Backtest(df, EmaCross, cash=10, commission=.002)
bt.run()
  1. 'Buy & Hold Return [%]' is positive.

Additional info

The reason for this bug is in line 906 of backtesting/backtesting.py

s.loc['Buy & Hold Return [%]'] = abs(c[-1] - c[0]) / c[0] * 100 # long OR short

returns the absolute value. It loses very important information. Anyone who needs the absolute value can always take the absolute value of the returned value. But now the information is lost if 'Buy & Hold Return [%]' is positive or negative. This makes it useless to compare in both long and short strategies.

@kernc
Copy link
Owner

kernc commented Jan 4, 2020

Mind the comment. In this case, Buy&Hold is a hypernym for Buy&Hold and Sell&Hold, namely any long-term position, taken along the assumed foreseen general direction of the underlying market.

Otherwise, even a blank strategy that does no trading whatsoever would fare better than B&H with negative return.

This makes it useless to compare in both long and short strategies.

I'm not sure I understand. Can you elaborate?

@kernc
Copy link
Owner

kernc commented Jul 15, 2020

Lacking further discussion on this issue, I find the current adversarial behavior preferred.

@kernc
Copy link
Owner

kernc commented Oct 4, 2020

This was changed as of 3045b64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants