contango.runners.static.static_runner
contango.runners.static.static_runner
StaticRunner
Bases: Generic[TConfig]
Runner for fetching data and executing a singular, unchanging Strategy implementation.
fetch_data
staticmethod
fetch_data(provider: HistoricalDataProvider[TConfig], config: TConfig, database_path: str | Path | None = None) -> list[MarketDataEvent]
Fetches and stores data into the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
HistoricalDataProvider[TConfig]
|
The historical data provider (i.e. Yfinance) implementation. |
required |
config
|
TConfig
|
The configuration that matches the data provider (i.e. YfinanceConfig). |
required |
database_path
|
str | Path | None
|
The optional database path; if not provided, defaults to the OS-standard user data directory. |
None
|
Returns:
| Type | Description |
|---|---|
list[MarketDataEvent]
|
list[MarketDataEvent]: The OHLCV data from the database and/or historical data provider. |
Source code in src\contango\runners\static\static_runner.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
fetch_data_multi
staticmethod
fetch_data_multi(provider: HistoricalDataProvider[TConfig], configs: Mapping[str, TConfig], database_path: str | Path | None = None) -> dict[str, list[MarketDataEvent]]
Fetches and stores data for multiple symbols, keyed by the same symbol strings intend to use in param_grid["symbol"].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
HistoricalDataProvider[TConfig]
|
The historical data provider (i.e. Yfinance) implementation. |
required |
configs
|
Mapping[str, TConfig]
|
A mapping of symbol -> config for the symbol (e.g. {"AAPL": YfinanceConfig(ticker="AAPL", ...)}). |
required |
database_path
|
str | Path | None
|
The optional database path. if not provided, defaults to the OS-standard user data directory. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[MarketDataEvent]]
|
dict[str, list[MarketDataEvent]]: OHLCV data per symbol. |
Source code in src\contango\runners\static\static_runner.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
run
staticmethod
run(ohlcv_data: list[MarketDataEvent], strategy: Strategy, backtester_config: BacktesterConfig) -> Metrics
Runs a backtest for a static, singular strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ohlcv_data
|
list[MarketDataEvent]
|
A list of historical market data events to use for the backtest. |
required |
strategy
|
Strategy
|
The singular strategy implementation to backtest. |
required |
backtester_config
|
BacktesterConfig
|
The configuration for the backtester. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Metrics |
Metrics
|
The metrics for the backtest. |
Source code in src\contango\runners\static\static_runner.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |