17#include "fastmm/core/engine_runner.hpp"
18#include "fastmm/sim/sim_backend.hpp"
26class BacktestSession {
33 std::string_view strategy_meta = {});
39 [[nodiscard]] sim::SimBackend&
backend() noexcept {
return *backend_; }
47 IEngineRunner* runner,
48 std::string_view strategy_name);
54 std::unique_ptr<SyntheticSource> synthetic_;
55 std::unique_ptr<sim::MarketGenerator> generator_;
56 std::unique_ptr<sim::SimBackend> backend_;
59 std::vector<ReconcileMsg> start_positions_;
60 std::string start_note_;
63 std::vector<ParamUpdateMsg> journal_params_;
64 std::unique_ptr<sim::ParamSchedule> own_params_;
65 std::unique_ptr<Impl> impl_;
68 sim::SlowHooks slow_{};
71template <StrategyLike S>
72BacktestResult
run_backtest(
const BacktestConfig& cfg, MdSource* source =
nullptr) {
73 BacktestSession session(cfg, source, &S::schema());
74 std::unique_ptr<IEngineRunner> runner = session.backend().template make_runner<S>(session.deps());
75 return session.run(session.backend().hooks, runner.get(), S::name());
81 std::string_view strategy,
82 MdSource* source =
nullptr);
85template <StrategyLike S>
104[[nodiscard]] std::unique_ptr<MdSource>
open_data(std::string_view spec,
BacktestResult (8.4): structure-of-arrays rows (numpy-friendly: each column is one contiguous vector)...
BacktestConfig: everything a run needs, assembled from the TOML sections [engine] [[instruments]] [st...
Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue,...
Definition instrument.hpp:141
Definition params.hpp:102
Convenience wrapper that owns the config.
Definition backtest_runner.hpp:88
BacktestResult run(MdSource *source=nullptr)
Definition backtest_runner.hpp:93
BacktestConfig & config() noexcept
Definition backtest_runner.hpp:91
Definition backtest_runner.hpp:28
void set_slow_hooks(const sim::SlowHooks &hooks) noexcept
Code run at simulated times during run() (sim::SimDriver::set_slow_hooks).
Definition backtest_runner.hpp:45
RunnerDeps & deps() noexcept
Definition backtest_runner.hpp:40
BacktestResult run(const sim::EngineHooks &hooks, IEngineRunner *runner, std::string_view strategy_name)
Runs to the end of the data / horizon.
BacktestSession & operator=(const BacktestSession &)=delete
sim::SimBackend & backend() noexcept
Definition backtest_runner.hpp:41
void set_param_schedule(sim::ParamSchedule *schedule) noexcept
Parameter updates delivered at simulated times during run() (not owned; may be null).
Definition backtest_runner.hpp:43
Definition param_schedule.hpp:33
DataSource (8.4): a timestamp-ordered stream of normalized market-data events consumed by the simulat...
Definition backtest_config.hpp:39
std::unique_ptr< MdSource > open_data(std::string_view spec, const InstrumentTable *instruments=nullptr)
Resolves --data through the data-source registry (data_registry.hpp): "<name>:<args>",...
SyntheticSourceConfig synthetic_source_config(const BacktestConfig &cfg)
The SyntheticSource a run with source == nullptr replays under the L2 queue fill model.
BacktestResult run_backtest(const BacktestConfig &cfg, MdSource *source=nullptr)
Definition backtest_runner.hpp:74
std::unique_ptr< MdSource > open_source(const BacktestConfig &cfg)
Source for [backtest] source / path.
Strategy registry (8.6, ADR-0012): name -> parameter schema + one factory per transport kind,...
Everything a factory needs that is backend-independent.
Definition registry.hpp:51
Definition backtest_config.hpp:48
Definition result.hpp:113
Definition synthetic_source.hpp:20
SyntheticSource: a MarketGenerator run against its own MatchingEngine, published through MdAggregator...