Skip to content

Equity Plot legend shows original 100% investment which may cause confusion #178

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
eervin123 opened this issue Nov 11, 2020 · 10 comments
Closed
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@eervin123
Copy link
Contributor

Expected Behavior

Note this is nitpicky but I noticed a few people misunderstanding the legend when I showed it to them so only a focus group of a few, take the following with a grain of salt.

The plot legend shows the peak and final equity value as a % but it doesn't subtract the original 100% from the result. This gives the impression that the peak and final "Return" of the strategy was 100% higher than it actually was. I fully recognize that the use of the word "return" was inferred by my brain, not by the chart, but I don't think I'm alone in keying in on the % sign as an indicator of returns.

This would be fine if it were a "growth of $100" type of chart and used a $ instead of a % However because it is labeled in % (which would be my preference) then perhaps consider subtracting 100% from the legend Peak % and Final %. I think it is perfectly reasonable to show the y-axis starting at 100% but if you wanted to get technical, you could change it to a 0% starting point so everything lined up.

Actual Behavior

The chart shows the percent of the original investment, for example in the image below, the "Peak (690%)" and "Final (689%)" imply 690% and 689% of the original invested amount, not a 690% /689% return. The actual returns would have only been 590%/589% over that time period.

image

Again, this was just something someone else pointed out to me as a bother and I think tend to agree. It is certainly not a priority or even consensus.

@kernc
Copy link
Owner

kernc commented Nov 11, 2020

Yeah, the plot section is called Equity. It's the same in backtrader, bt, and PyAlgoTrade, albeit they show it in absolute currency units. In backtesting.py, dollar amount is available via .plot(relative_equity=False).

I've been annoyed with discrepancy in the legend label vs. value in stats for a while now. I don't oppose to renaming the plot to Return (and subtracting 100%), but, then, its argument is called .plot(plot_equity=), so that would prompt renaming it too (along with a full deprecation cycle) ...

@kernc kernc added enhancement New feature or request good first issue Good for newcomers labels Nov 11, 2020
@eervin123
Copy link
Contributor Author

:) I hesitated even mentioning it because I knew you had bigger more important things to work on. If you did need a vote, I'd say change it to return but ONLY if and when it was convenient. As a half measure, for readability, you could change the plot section to "Equity Return" and then .plot(plot_equity=) would at least make sense for old and new developers, or just change both, so .plot(plot_equity_return=)

@kernc
Copy link
Owner

kernc commented Nov 13, 2020

I found a backwards compatible way I like.

You can achieve the plot you want with:

bt.plot(plot_equity=False, plot_return=True)

Somewhat explicit, but it works. I haven't flipped the default because we refer to equity curve in several tutorials, and I didn't feel like diving into all that now. 😄

@kernc kernc closed this as completed in 17e9489 Nov 13, 2020
@eervin123
Copy link
Contributor Author

This is excellent. Thanks for that. Speaking of tutorials and documentation, I was thinking that may be a good way for me to help out. As an example, when you roll out 3.0 the new stats table will need to be updated in various areas throughout the documentation and the website, etc. Some I can fix through PRs, others I can just flag and inventory for you.

I was also thinking about doing some writing and possibly some YouTube videos for the project, but to be honest, I am a bit self conscious about my crude code so perhaps I could run things by you privately so you can help make sure that I am not teaching people bad python.

My thinking was to do a few articles and videos on how an investment manager thinks about and "battle tests" a trading strategy. Focusing more the areas I am comfortable teaching, like the fundamentals of critical thinking and building portfolios of strategies rather than relying on a single strategy to achieve better outcomes. As part of the series, I will use backtesting.py as the core tool to demonstrate and share the code for people to follow along. If you are open to something like this, let me know. I may not start it right away, but then again, I might jump right into it and start creating videos privately until I feel they are ready for public consumption.

If you are up for it, you let me know the best contact info for collaboration, you can use my email [email protected]

If not, that is perfectly fine as well.

@kernc
Copy link
Owner

kernc commented Nov 14, 2020

when you roll out 0.3.0, the new stats table will need to be updated

That should actually be as easy as running:

jupyter nbconver --to notebook --execute *.ipynb

But, sure, you can do that!

Honestly, been meaning to ask you already in #150 (comment) to contrib that notebook comparing strategy to a benchmark strategy, with pyfolio and all! 😃

I'm totally open to any new tutorials that would fit here. Rest assured, any code that lands in this repo would first get to pass a thorough and strict code review, leaving you, if anything, eventually quite satisfied with your coding work. 😛

My thinking was to do a few articles and videos on how an investment manager thinks about and "battle tests" a trading strategy.

This, too, would be appreciated, and I think I'd learn a thing or two myself! I—FWIW—am open to any kind of materials you feel like making. If they're good, I have absolutely no reservations about linking to where they're hosted. This might provide some additional exposure to your fund, but it would definitely add to the credibility of this project! 😊

@eervin123
Copy link
Contributor Author

Just wanted to let you know I didn't disappear. Just been busy. I'll be circling back to this soon, hopefully in the next few weeks.

@kernc
Copy link
Owner

kernc commented Nov 25, 2020

Thanks, I'm definitely looking forward to it! 😊 Do check out the new model-based backtest optimization — might not be wholly your cuppa, but it opens up a world of new opportunities: A previously infeasible optimization of ten parameters with three values each is now almost a breeze.

@eervin123
Copy link
Contributor Author

eervin123 commented Dec 2, 2020

Do check out the new model-based backtest optimization

Oooh! I'm getting excited. You really are killing it here with this project. I'm very glad to help wherever I can.

So, in the interest of keeping the project organized and free of clutter, how should I share things that aren't really issues, but maybe dumb questions about my low-level python/pandas/ etc.? I was thinking, the best way would be for me to

  1. to fork this project,
  2. create a new branch called "possible_examples" or something, and
  3. post my code and comments to the docs/examples folder then
  4. I could post all of my dumb questions as issues in that fork tagging you rather than posting them in your main project.

Am I on the right track with this sequence?

@kernc
Copy link
Owner

kernc commented Dec 2, 2020

Sure, that works. I'll be watching your fork and get notified of any issues you raise. You also have my email. If some questions are too noobish, you might as well go gather some karma on StackOverflow. I wouldn't mind obtaining some backlinks from there. 😛

When the questions are on-topic and relevant potentially to a wider audience, like some we have already, those are welcome here, of course.

@eervin123
Copy link
Contributor Author

Perfect, and great point about the backlinks. I'll write some things on Medium blog as well as publish an article or two on Forbes mentioning the project.

Goblincomet pushed a commit to Goblincomet/forex-trading-backtest that referenced this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants