Getting started
Installation
Install backtide's newest release easily via pip:
pip install -U backtide
or via conda:
conda install -c conda-forge backtide
Latest source
Sometimes, new features and bug fixes are already implemented in the
development branch, but waiting for the next release to be made
available. If you can't wait for that, it's possible to install the
package directly from git.
pip install git+https://github.com/tvdboom/backtide.git@development#egg=backtide
Don't forget to include #egg=backtide to explicitly name the project,
this way pip can track metadata for it without having to have run the
setup.py script.
Optional dependencies
Some specific functionalities or configuration options require the installation of additional libraries. Install all optional dependencies with:
pip install -U backtide[full]
Contributing
If you are planning to contribute to the project, you'll need the development dependencies. Install them with:
pip install -U backtide[dev]
Click here for a complete list of package files for all versions published on PyPI.
Usage
There are three ways to use backtide:
Via the application
Backtide ships with an interactive Vue application bundled into the Python wheel. Launch it from the terminal with:
backtide launch
The app provides a graphical interface for configuring experiments, visualizing results, managing stored data, and running live sessions. No Node.js installation is required. Read more in the user guide.
Via the CLI
The backtide command-line interface lets you download data, run backtests and
manage storage directly from the terminal.
backtide download AAPL MSFT --interval 1d
backtide run experiment.toml
Run backtide --help to see all available commands.
Via Python
Import backtide in any Python script or notebook for full programmatic control.
>>> from backtide import DataExpConfig, Experiment, ExperimentConfig, GeneralExpConfig
>>> from backtide.data import resolve_profiles, download_bars
>>> from backtide.storage import query_bars
>>> from backtide.strategies import MultiBollingerRotation
>>> profiles = resolve_profiles(["AAPL", "MSFT"], "stocks", ["1h", "1d"])
>>> result = download_bars(profiles)
>>> data = query_bars("AAPL")
>>> print(data.head())
symbol interval provider ... adj_close volume n_trades
0 AAPL 1d yahoo ... 0.098122 469033600.0 None
1 AAPL 1d yahoo ... 0.093003 175884800.0 None
2 AAPL 1d yahoo ... 0.086177 105728000.0 None
3 AAPL 1d yahoo ... 0.088310 86441600.0 None
4 AAPL 1d yahoo ... 0.090870 73449600.0 None
[5 rows x 13 columns]
>>> config = ExperimentConfig(
... general=GeneralExpConfig(name="test experiment"),
... data=DataExpConfig(symbols=["AAPL", "MSFT"], interval="1d"),
... )
>>> results = Experiment(config, strategies=[MultiBollingerRotation()]).run()
>>> print(results)
ExperimentResult(id="4decc2558b7e43cd", name="test experiment", status="success", n_strategies=1)