Backtrader_Bokeh
You can visit our wiki homepage for more information: EN | 中文
Backtrader_Bokeh to add extended plotting capabilities to Backtrader using Bokeh based on the awesome backtrader_plotting and btplotting. Besides this, a lot of issues are fixed and new functionality is added. See the list below for differences.
What is different:
Basic:
- No need for custom backtrader
- Different naming / structure
- Different data generation which allows to generate data for different data sources. This is useful when replaying or resampling data, for example to remove gaps.
- Different filtering of plot objects
- Support for replay data
- Every figure has its own ColumnDataSource, so the live client can patch without having issues with nan values, every figure is updated individually
- Display of plots looks more like backtrader plotting (order, heights, etc.)
- Allows to generate custom columns, which don't have to be hardcoded. This is being used to generate color for candles, varea values, etc.
- Possibility to fill gaps of higher timeframes with data
Plotting:
- Datas, Indicators, Observer and Volume have own aspect ratios, which can be configured in live client or scheme
- Different datafeed's plot sytle can be customize separately
- Only one axis for volume will be added when using multiple data sources on one figure
- Volume axis position is configureable in scheme, by default it is being plotted on the right side
- Linked Crosshair across all figures
- fill_gt, fill_lt, fill support
- Plot objects can be filtered by one or more datanames or by plot group
- Custom plot group, which can be configured in app or in live client by providing all plotids in a comma-seperated list or by selecting the parts of the plot to display
Tabs:
- Default tabs can be completely removed
- New log panel to also include logging information
- Can be extended with custom tabs (for example order execution with live client, custom analysis, etc.)
Live plotting:
- Navigation in live client (Pause, Backward, Forward)
- Live plotting is done using an analyzer, so there is no need to use custom backtrader
- Live plotting data update works in a single thread and is done by a DataHandler
- Data update is being done every n seconds, which is configureable
Features
- Interactive plots
- Support keyboard operation
- Interactive
backtraderoptimization result browser (only supported for single-strategy runs) - Highly configurable
- Different skinnable themes
- In addition to OHLC, additional datafeed line can be ploted
- Easy to use
Bug fixed
Some examples, more detail in CHANGELOG.md
- Many bugs in Backtrader that have not been still fixed, Backtrader_Bokeh fixed those through Monkey Patch
- Because of optbrowser address and port assignment problem, if port 80 is occupied, the web page will not be opened in the optimization mode. * live mode is the same way
- Very imortant, fixed the legend can't be displayed in the observer or indicators's figuer
- And more...
Python >= 3.6 is required.
How to use
Just give Live Mode example, about Normal Mode and Optstrategy Mode pls refer to wiki-en | wiki-中文
- Add to cerebro as an analyzer (Live Mode):
from backtrader_bokeh import bt
...
...
cerebro = bt.Cerebro()
cerebro.addstrategy(MyStrategy)
cerebro.adddata(LiveDataStream()) # Note! Data is must Live Data
cerebro.addanalyzer(bt.analyzers.Live, force_plot_legend=True, autostart=True)
cerebro.run()
# cerebro.plot() # do not run this line unless your data is not real-time
- If you need to change the default port or share the plotting to public:
cerebro.addanalyzer(bt.analyzers.Live, address="localhost", port=8889)
Jupyter
In Jupyter you can plut to a single browser tab with iplot=False:
from backtrader_bokeh import bt
plot = bt.Bokeh()
cerebro.plot(plot, iplot=False)
You may encounters TypeError: <class '__main__.YourStrategyClass'> is a built-in class error.
To remove the source code tab use:
from backtrader_bokeh import bt
plot = bt.Bokeh()
plot.tabs.remove(bt.tabs.SourceTab)
cerebro.plot(plot, iplot=False)
Demos
https://iniself.github.io/backtrader_bokeh/
Contact us
Telegram Channel: Aui_Say Discord Server: Aui and Friends
Installation
pip install backtrader_bokeh
or
pip install git+https://github.com/iniself/backtrader_bokeh
Sponsoring
If you want to support the development of backtrader_bokeh, consider to support this project.
- ETH: 0x0275779f70179748C6fCe1Fe5D7638DfA7e3F986
Metadata
Release files for backtrader-bokeh 0.8.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| backtrader_bokeh-0.8.9.tar.gz | 217.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| backtrader_bokeh-0.8.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 468.0 kB
Release files / backtrader_bokeh-0.8.9.tar.gz
| Download URL | backtrader_bokeh-0.8.9.tar.gz |
|---|---|
| Size | 217.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af294faaf193bbd67d3ef5382af26f6b1790f5e126ac0b4690f140bb39bfbe20
|
|
BLAKE2b-256 checksum How to use checksums |
cbc56fb1ababdb4ac9c5076c5e425b36627f5bd76ea296dd11532eb6cf338631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Release files / backtrader_bokeh-0.8.9-py3-none-any.whl
| Download URL | backtrader_bokeh-0.8.9-py3-none-any.whl |
|---|---|
| Size | 250.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c9e61ac71a2b4537a1b4674c4c82c0d7e4ac5342343c2a7a38c8fff1d8dbcee
|
|
BLAKE2b-256 checksum How to use checksums |
93fd79a331c6b8ca94c1adb491109fc1cc9bbd2953ab70514e3927fcdc4947e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Security for backtrader-bokeh 0.8.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.