Skip to content

Commit 20a0371

Browse files
authored
Merge branch 'master' into feature/fix_auto_close
2 parents fa7507a + 44fcb02 commit 20a0371

24 files changed

+989
-576
lines changed

.github/ISSUE_TEMPLATE/1-bug.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Bug report
2+
description: File a new bug report. Please use the search
3+
title: "Short title loaded with keywords"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for putting in the effort to submit this bug report! Note, the
9+
best bug reports are accompanied with fixing patches / pull-requests.
10+
11+
- type: checkboxes
12+
attributes:
13+
label: Contributing guidelines
14+
description: |
15+
I have read and will follow
16+
[Contributing Guidelines](https://github.com/kernc/backtesting.py/blob/master/CONTRIBUTING.md).
17+
options:
18+
- label: I agree to follow this project's Contributing Guidelines
19+
required: true
20+
21+
- type: textarea
22+
id: expected
23+
validations:
24+
required: true
25+
attributes:
26+
label: Expected behavior
27+
description: You run the code below and expect what to happen?
28+
placeholder: When I run this code ... the program should ...
29+
30+
- type: textarea
31+
id: code
32+
validations:
33+
required: false
34+
attributes:
35+
label: Code sample
36+
description: Code snippet that clearly reproduces the issue
37+
render: python
38+
placeholder: |
39+
from backtesting import Backtest, Strategy
40+
from backtesting.test import GOOG
41+
42+
class Example(Strategy):
43+
...
44+
45+
bt = Backtest(GOOG, Example)
46+
...
47+
48+
- type: textarea
49+
id: actual
50+
validations:
51+
required: true
52+
attributes:
53+
label: Actual behavior
54+
description: What happened unexpectedly when you ran the code above?
55+
placeholder: When I ran the code above ... the program did ...
56+
57+
- type: textarea
58+
id: steps
59+
validations:
60+
required: false
61+
attributes:
62+
label: Additional info, steps to reproduce, full crash traceback, screenshots
63+
description: |
64+
Attach any additional info you think might be helpful and
65+
result in quicker resolution of your bug.
66+
placeholder: |
67+
1. Do ...
68+
2. ...
69+
3. Boom.
70+
71+
- type: textarea
72+
id: versions
73+
validations:
74+
required: false
75+
attributes:
76+
label: Software versions
77+
description: |
78+
Versions of the relevant software / packages.
79+
value: |
80+
<!-- From `backtesting.__version__`. If git, use commit hash -->
81+
- Backtesting version: 0.?.?
82+
- `bokeh.__version__`:
83+
- OS:

.github/ISSUE_TEMPLATE/2-enh.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Enhancement proposal
2+
description: Describe the enhancement you'd like to see
3+
title: "Short title loaded with keywords"
4+
labels: ["enhancement"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to give feedback on this software!
10+
11+
- type: checkboxes
12+
attributes:
13+
label: Contributing guidelines
14+
description: |
15+
I have read and will follow
16+
[Contributing Guidelines](https://github.com/kernc/backtesting.py/blob/master/CONTRIBUTING.md).
17+
options:
18+
- label: I agree to follow this project's Contributing Guidelines
19+
required: true
20+
21+
- type: textarea
22+
id: expected
23+
validations:
24+
required: true
25+
attributes:
26+
label: Enhancement description
27+
description: What would you want to see in the software that doesn't appear to be presently included?
28+
placeholder: I absolutely love your software, but I'm missing a way to ...
29+
30+
- type: textarea
31+
id: code
32+
validations:
33+
required: false
34+
attributes:
35+
label: Code sample
36+
description: Code snippet relevant to the new feature
37+
render: python
38+
39+
- type: textarea
40+
id: steps
41+
validations:
42+
required: false
43+
attributes:
44+
label: Additional info, images
45+
description: |
46+
Extra information you think might be helpful or interesting.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Reference documentation
4+
url: https://kernc.github.io/backtesting.py/doc/backtesting/
5+
about: Please confirm you've checked here first.
6+
- name: FAQ
7+
url: https://github.com/kernc/backtesting.py/issues?q=label%3Aquestion%20
8+
about: Frequently asked questions. Use search with potential keywords.
9+
- name: Discussion forum
10+
url: https://github.com/kernc/backtesting.py/discussions
11+
about: Other discussions. Make sure you've seen this too.

.github/issue_template.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
### Expected Behavior
22

3+
...
34

45
### Actual Behavior
56

6-
<!-- In case of a bug, attach full exception traceback. Please
7-
wrap verbatim code/output in Markdown fenced code blocks:
8-
https://bit.ly/3nEvlHP -->
7+
<!--
8+
In case of a bug, attach full exception traceback.
9+
Please wrap verbatim code/output in Markdown fenced code blocks.
10+
-->
911

1012

1113
### Steps to Reproduce
@@ -25,8 +27,4 @@ python code goes here
2527

2628
### Additional info
2729

28-
<!-- screenshots, code snippets, ... -->
29-
30-
- Backtesting version: 0.?.? <!-- From backtesting.__version__ -->
31-
- `bokeh.__version__`:
32-
- OS:
30+
<!-- screenshots, code snippets, versions ... -->

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,50 @@ on:
77
jobs:
88
build:
99
name: Build
10-
runs-on: ubuntu-18.04
10+
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.7, '3.10']
13+
python-version: ['3.10', 3.13]
1414
include:
15-
- python-version: 3.9
15+
- python-version: 3.11
1616
test-type: lint
17-
- python-version: 3.9
17+
- python-version: 3.11
1818
test-type: docs
1919

2020
steps:
21-
- uses: actions/setup-python@v4
21+
- uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- uses: actions/cache@v3
24+
- uses: actions/cache@v4
2525
with:
2626
path: ~/.cache/pip
2727
key: ${{ runner.os }}-py${{ matrix.python-version }}
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929
with:
3030
fetch-depth: 3
3131
- name: Fetch tags
3232
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
3333

3434
- run: pip install -U pip setuptools wheel
3535
- if: matrix.test-type == 'lint'
36-
run: pip install -U --pre bokeh pandas 'numpy<1.24' && pip install -U .[dev]
36+
run: pip install -U --pre bokeh pandas numpy && pip install -U .[dev]
3737
- if: matrix.test-type == 'docs'
3838
run: pip install -e .[doc] # -e provides _version.py for pdoc
3939
- run: pip install -U .[test]
4040

4141
- if: matrix.test-type == 'lint'
42-
run: ruff backtesting
42+
run: flake8 backtesting setup.py
4343
- if: matrix.test-type == 'lint'
4444
run: mypy backtesting
4545
- if: matrix.test-type == 'lint'
4646
env: { BOKEH_BROWSER: none }
47-
run: time catchsegv coverage run -m backtesting.test
47+
run: time coverage run -m backtesting.test
4848
- if: matrix.test-type == 'lint'
49-
run: bash <(curl -s https://codecov.io/bash)
49+
run: coverage combine && coverage report
5050

5151
- if: '! matrix.test-type'
5252
env: { BOKEH_BROWSER: none }
53-
run: time catchsegv python -m backtesting.test
53+
run: time python -m backtesting.test
5454

5555
- if: matrix.test-type == 'docs'
56-
run: time catchsegv doc/build.sh
56+
run: time doc/build.sh

.github/workflows/deploy-docs.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,26 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- name: Set up Python
13-
uses: actions/setup-python@v2
12+
- uses: actions/setup-python@v5
1413
with:
15-
python-version: 3.8
14+
python-version: 3.11
1615

17-
- uses: actions/cache@v2
18-
name: Set up caches
16+
- uses: actions/cache@v4
1917
with:
2018
path: ~/.cache/pip
2119
key: ${{ runner.os }}
2220

23-
- name: Checkout repo
24-
uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2522
with:
2623
fetch-depth: 3
2724
- name: Fetch tags
2825
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
2926

30-
- name: Install dependencies
31-
run: |
32-
pip install -U pip setuptools wheel
33-
pip install -U -e .[doc,test]
27+
- run: pip install -U pip setuptools wheel
28+
- run: pip install -U -e .[doc,test]
3429

35-
- name: Build docs
36-
run: time catchsegv doc/build.sh
30+
- run: time doc/build.sh
3731

38-
- name: Deploy docs
32+
- run: .github/deploy-gh-pages.sh
3933
env:
4034
GH_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
41-
run: .github/deploy-gh-pages.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dist/*
1313
htmlcov/*
1414

1515
doc/build/*
16+
build/*
1617

1718
.idea/*
1819
.vscode/

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,30 @@ These were the major changes contributing to each release:
55

66
### 0.x.x
77

8-
* new param on "run()" to manage if trades should be close at end, or not. (#273)
8+
9+
### 0.5.0
10+
(2025-01-21)
11+
12+
* Enhancements:
13+
* New `Backtest.optimize(method="sambo")`;
14+
uses [SAMBO](https://sambo-optimization.github.io):
15+
to replace `method="skopt"`.
16+
* New 'CAGR [%]' (compound annual growth rate) statistic.
17+
* Bug fixes:
18+
* "stop-loss executed at a higher than market price".
19+
* Bug with buy/sell size=0.
20+
* `Order.__repr__` issue with non-numeric `Order.tag`.
21+
* Other small fixes, deprecations and docs updates.
22+
23+
24+
### 0.4.0
25+
(2025-01-21)
26+
27+
* Enhancements:
28+
* 'Kelly Criterion' statistic (#640)
29+
* `Backtest.plot(plot_trades=)` parameter
30+
* Order.tag for tracking orders and trades (#200)
31+
* Small bug fixes, deprecation removals and documentation updates.
932

1033

1134
### 0.3.3

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ have been fixed already.
99

1010
To have your issue dealt with promptly, it's best to construct a
1111
[minimal working example] that exposes the issue in a clear and
12-
reproducible manner. Make sure to understand
13-
[how to report bugs effectively][bugs] and how to
12+
reproducible manner. Review [how to report bugs effectively][bugs]
13+
and, particularly, how to
1414
[craft useful bug reports][bugs2] in Python.
1515

1616
In case of bugs, please submit full tracebacks
@@ -23,7 +23,7 @@ Many thanks from the maintainers!
2323
[minimal working example]: https://en.wikipedia.org/wiki/Minimal_working_example
2424
[bugs]: https://www.chiark.greenend.org.uk/~sgtatham/bugs.html
2525
[bugs2]: https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
26-
[fenced code blocks]: https://www.markdownguide.org/extended-syntax/#fenced-code-blocks
26+
[fenced code blocks]: https://www.markdownguide.org/extended-syntax/#syntax-highlighting
2727

2828

2929
Installation
@@ -33,7 +33,7 @@ first [fork the project]. Then:
3333

3434
git clone git@github.com:YOUR_USERNAME/backtesting.py
3535
cd backtesting.py
36-
pip3 install -e '.[doc,test,dev]'
36+
pip install -e '.[doc,test,dev]'
3737

3838
[fork the project]: https://help.github.com/articles/fork-a-repo/
3939

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Return [%] 589.35
6262
Buy & Hold Return [%] 703.46
6363
Return (Ann.) [%] 25.42
6464
Volatility (Ann.) [%] 38.43
65+
CAGR [%] 16.80
6566
Sharpe Ratio 0.66
6667
Sortino Ratio 1.30
6768
Calmar Ratio 0.77

backtesting/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
3-
![xkcd.com/1570](https://imgs.xkcd.com/comics/engineer_syllogism.png)
3+
![xkcd.com/1570](https://imgs.xkcd.com/comics/engineer_syllogism.png){: height=263}
44
55
## Manuals
66

0 commit comments

Comments
 (0)