Skip to content

fix multibacktest example strategy import - #1419

Open
Geochelone666 wants to merge 2 commits into
kernc:masterfrom
Geochelone666:fix-multibacktest-docstring-1415
Open

Geochelone666 wants to merge 2 commits into
kernc:masterfrom
Geochelone666:fix-multibacktest-docstring-1415

Conversation

@Geochelone666

Copy link
Copy Markdown

move the existing SmaCross strategy from the test suite to backtesting.test so the documented import works. keep its fast/slow parameters and reuse it in the tests.

replace the optimization placeholder with a small parameter grid and add a regression test that runs the complete example.

Closes #1415

checks: 82 tests passed with MPLBACKEND=Agg, including the offline example and lib/utils tests; flake8 passed. mypy reports the same two _plotting.py errors on unchanged master.

AI assistance: used Codex to prepare and test this change.

@arhancanli

Copy link
Copy Markdown

Same kind of problem a few lines down, in MultiBacktest.optimize's docstring: it imports from backtesting.plot import plot_heatmaps, but there's no backtesting.plot module (on 0.6.6 that line raises ModuleNotFoundError); plot_heatmaps lives in backtesting.lib. The example also assigns heamap and then uses heatmap. With both fixed it works as written: optimize returns one column per dataset indexed by the parameter combination, so plot_heatmaps(heatmap.mean(axis=1)) plots the cross-instrument average. Might be worth folding into this PR, with the same exec-the-docstring test.

- from backtesting.lib import plot_heatmaps (was backtesting.plot)
- heamap -> heatmap typo fix
@Geochelone666

Geochelone666 commented Oct 5, 2026 via email

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backtesting.lib.MultiBacktest doc string example assumes SmaCross exist(s) in backtesting.test, either add SmaCross or fix example

2 participants