kernc / kernc/backtesting.py

Can formulas for 'stats' be provided

Open
#1,238 3 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
Python
Stars
9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Enhancement description

I was wondering whether the formulas and algorithms used in calculation of `stats` could be documented. It would not only add transparency, but also aid in understanding what the assumptions are, and what you are actually calculating.

For example, I was confused why running the tests with different parameters on the same data, would result in different "Buy & Hold Return [%]" returns...? If I buy at the beginning of the period, and hold until the end, my differing indicator parameters should not affect this result for the same time period.

I presume the "Buy & Hold Return [%]" assumes buying when our algorithm makes the first purchase and then holding until the end of the period? Or perhaps the buy is executed when the lookback period of the most laggy indicator ends?

I see there is a disclaimer in the docs for [bt.run()](https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.Backtest.run), that the trading simulation begins at different points in the time period, based on the provided indicator parameters, which seems appropriate for some values, but not logical for others (e.g. Buy & Hold)?

### Code sample

```python

```

### Additional info, images

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the bt.run() documentation linked in the issue and trace the implementation that produces the stats results. Document the formulas and assumptions used for each relevant statistic, especially Buy & Hold Return [%], and clarify how indicator parameters affect its starting point.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.