run
forge.runner.run(strategy: str | os.PathLike[str] | type[Strategy] | Mapping[str, Any],*,custom_indicators: Mapping[str, str | os.PathLike[str]] | None = None,bars: pd.DataFrame,symbol: str,broker_facts: Mapping[str, Any],timeframe: str | None = None,settings: Mapping[str, Any] | None = None,extras: Mapping[str, pd.DataFrame | SeriesColumns] | None = None,calendar: CalendarDocument | None = None,seed: int | None = None,capital: float | None = None,execution_model: Mapping[str, Any] | None = None,quotes: pd.DataFrame | None = None) -> RunResultRun a strategy file over a data frame, the way a hosted run does.
Parameters
| Name | Type | Default |
|---|---|---|
| strategy | str | os.PathLike[str] | type[Strategy] | Mapping[str, Any] | |
| custom_indicators | Mapping[str, str | os.PathLike[str]] | None | None |
| bars | pd.DataFrame | |
| symbol | str | |
| broker_facts | Mapping[str, Any] | |
| timeframe | str | None | None |
| settings | Mapping[str, Any] | None | None |
| extras | Mapping[str, pd.DataFrame | SeriesColumns] | None | None |
| calendar | CalendarDocument | None | None |
| seed | int | None | None |
| capital | float | None | None |
| execution_model | Mapping[str, Any] | None | None |
| quotes | pd.DataFrame | None | None |
strategy is the path of the file, or a strategy class already defined, such as one in a
test.
A class is checked as its file is, except for the checks that read the whole file. A Strategy
Spec
(the JSON mapping the Studio saves) runs too, built with compile_spec.
custom_indicators gives the developer indicators a Strategy Spec names, each key
"<id>:<version>" (the spec's custom and version) and each value the indicator's
file.
A spec that names one that is not given is refused before it runs.
bars holds open, high, low, close and volume, indexed by each bar's
close time on the broker's server clock, without a time zone. The prices are the bid. The ask
is the bid plus the broker's stated spread, and volume is tick volume. broker_facts is the
oathra.broker_facts/1 payload of the account, and symbol a symbol it holds.
timeframe names the bars, like "H1". A strategy that declares its bars gives it, and a
different one passed here is refused. settings gives setting values, and the defaults fill
the rest. A strategy that reads other series needs them in extras, each under the text a
refusal prints for it, like 'd.tf("H4")' or 'd["GBPUSD"]'. Each is a data frame like
bars or ready-made columns. calendar is an economic calendar for a strategy that reads
d.calendar. seed fixes the run's random generator, and the same inputs give the same
seed when it is left out. The strategy's own use of random and numpy.random starts from
that seed too, so a run repeats. capital is the starting balance in the account's currency,
and
25,000 when left out. execution_model is the run's execution settings in the form the
Tester stores them, like {"orders": {"require_stop": True}}. What the strategy declares
(stops, targets, sizes, caps, exits) wins over the same setting there, and the result's
flags["declarations"] lists each declaration, how it ran and every setting it replaced.
The account hedges or nets as the broker facts say, unless the model sets
{"account": {"margin_mode": "hedging"}} or "netting".
quotes gives the bid and ask prices a strategy that declares a price side decides on.
Every entry fills after its decision time, at the first real price after the bar it was
decided on. Returns the engine's RunResult.