Skip to content

run_experiment


function backtide.backtest.run_experiment(config=None, verbose=True, **kwargs)[source]

Run a backtest experiment with the provided configuration.

Performs the full pipeline end-to-end:

  1. Resolves and downloads the required market data (skipped if already present in the database).
  2. Computes indicators over the entire dataset.
  3. Runs every strategy in parallel. Each strategy has its own independent portfolio, order book and equity curve.
  4. Persists the results into the database.

Read more in the user guide.

Parameters

config : ExperimentConfig | None = None

The complete experiment configuration. If None, the configuration must be provided through kwargs. Missing parameters are filled with the default values.

verbose : bool, default=True
Whether to display a progress bar while running.

**kwargs
Any combination of:

  • Sub-config objects via keyword (general, data, portfolio, strategy, indicators, exchange, engine).
  • Flat keyword arguments matching any field of the sub-configs (e.g., name, symbols, interval, initial_cash).

The strategies and indicators keyword arguments additionally accept, beyond a list of stored names, any of:

  • A single string (name of a stored strategy / indicator).
  • A BaseStrategy / BaseIndicator subclass instance (the class' name is used as the display name).
  • A dict[str, instance] mapping explicit names to instances.

Keyword arguments take precedence over the corresponding fields in the config object.

Returns

ExperimentResult

The aggregated result of the run.


Example

>>> from backtide.backtest import run_experiment
>>> from backtide.strategies import BuyAndHold

>>> result = run_experiment(
...     name="Apple and Microsoft",
...     symbols=["AAPL", "MSFT"],
...     interval="1d",
...     strategies=[BuyAndHold()],
... )
>>> print(result)

ExperimentResult(id="e647e8b213b44f6e", name="Apple and Microsoft", status="Success", n_strategies=1)