|
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
|
#include <fastmm/backtest/backtest_config.hpp>
Public Member Functions | |
| bool | publishes_params () const noexcept |
| The run publishes parameter updates of its own: [ab] or [strategy.overrides] (BacktestSession::enable_ab). | |
| FxPlan | fx_plan (const InstrumentTable &table) |
The FX plan for table under accounting (throws ConfigError when a limit reads the totals and the table is not covered; otherwise a warning goes to warnings and nothing converts). | |
| UnderlyingPlan | underlying_plan (const InstrumentTable &table) const |
The [risk.underlying] plan for table (throws ConfigError when the spec does not fit it). | |
| void | set_market_bps (double spread_bps, double mid_step_bps, double depth_bps) |
| The synthetic market in basis points of generator.start_mid, turned into ticks of generator.tick: the spread from touch to touch (base_spread_ticks, half of it a side), the size of a latent mid step (mid_step_ticks) and the mean distance of a new limit order behind the touch (depth_ticks). | |
| bool | set_setting (std::string_view key, std::string_view value) |
| Sets one of kSweepSettings from its decimal value: latency_fixed_us and latency_jitter_us the order and ack paths of the venues without a [backtest.venues. | |
| void | set_param (const std::string &key, const std::string &value) |
| "key=value" strategy parameter override (CLI --param). | |
| void | set_seed (std::uint64_t s) noexcept |
| Seeds the synthetic market and the latency model. | |
Static Public Member Functions | |
| static BacktestConfig | from_config (const Config &cfg) |
| Throws ConfigError on invalid values. | |
| static BacktestConfig | single_instrument (std::string_view symbol, Price tick, Qty lot) |
| One instrument (venue 0) with the given tick/lot; generator tick/lot follow (examples). | |
Public Attributes | |
| EngineConfig | engine |
| InstrumentTable | instruments |
| std::string | strategy |
| registry name (apps / Python); ignored by run_backtest<S>() | |
| ParamMap | params |
| sim::SimTransportConfig | transport |
| sim::MarketGeneratorParams | generator |
| std::uint64_t | seed = 1 |
| synthetic market + latency model (engine.rng_seed is separate) | |
| Timestamp | start {seconds(1'700'000'000).ns} |
| Duration | duration = seconds(60) |
| synthetic horizon | |
| Duration | equity_bar = seconds(1) |
| double | initial_capital = 0.0 |
| reporting only (drawdown %) | |
| AccountingSpec | accounting |
| [accounting] and the venue names its sources name (Config::venues order). | |
| std::vector< std::string > | venue_names |
| UnderlyingSpec | underlying |
[risk.underlying]: from_config() builds engine.underlying from it for instruments; replay builds it again for the journal's table. | |
| std::vector< std::string > | warnings |
| from_config: Config::warnings plus unknown [backtest] keys, each naming the key and its line. | |
| int | generator_seed_levels = 20 |
| std::string | source |
| "synthetic" | "journal" | "csv" | "" (caller supplies the source) | |
| std::string | path |
| std::string | output_dir |
| std::string | journal_out |
| record the run to this .fmj (empty = no journal) | |
| MsgRing * | record_ring = nullptr |
| Where the engine puts its records (core/record_stream.hpp), as fastmm-live hands them to the store: the caller's ring, drained by the caller, large enough for the run (a full ring drops records). | |
| std::string | config_toml |
| Effective configuration embedded in journal_out (Config::effective_toml(); from_config() sets it, hand-built configs leave it empty). | |
| bool | measure_wall_clock = true |
| bool | keep_orders = true |
| The result keeps a row for every order sent (BacktestResult::orders). | |
| std::vector< Duration > | markout_horizons = {seconds(1), seconds(10), seconds(60)} |
| Post-fill markout horizons in simulated time; empty turns markouts off. | |
| bool | balances_from_journal = false |
| Start each venue's account (transport.accounts) from the first balance snapshot the journal source recorded for it; a venue it has none for keeps the configured balances. | |
| std::vector< TreasuryConfig > | treasuries |
| The pool treasuries ([venues. | |
| Duration | transfer_latency {} |
| [backtest] transfer_latency_ms: a simulated transfer is carried out this long after it is sent. | |
| double | transfer_p_fail = 0.0 |
| [backtest] transfer_p_fail, transfer_p_unknown, transfer_hang_ms: the simulated venue refuses a transfer, or loses its answer and carries it out transfer_hang later (sim::SimTransferFaults). | |
| double | transfer_p_unknown = 0.0 |
| Duration | transfer_hang = milliseconds(90'000) |
| InitialState | initial_state = InitialState::StateFile |
| The strategy's starting state; Journal also starts the engine's positions where the recorded session had them (sim::SessionStart). | |
| std::vector< StartPosition > | positions |
| [backtest.positions]: the engine's positions at the start, by instrument. They replace the | |
| Timestamp | start_at {} |
| [backtest] start_at: the run reads the data from its start (the books and the strategy's view of the market warm up), but trading starts later: with initial_state = "journal" at the last checkpoint of the data journal at or before this time, whose state the strategy restores as a warm standby's take-over does, else at this time. | |
| bool | latency_from_journal = false |
| [backtest] latency_from_journal: the simulated venues take a message's latency from the data journal's own messages around the same time where that is longer than the model's draw (sim/recorded_latency.hpp); the data source must be a journal. | |
| bool | params_from_journal = false |
| The data journal's parameter updates reach the strategy at the times the session received them (sim::RecordedParams), mapped by name and type onto its schema. | |
| std::vector< std::string > | params_pinned |
| params_from_journal leaves these parameters at the configured values: a counterfactual run keeps the session's other updates ([backtest] params_pinned, comma-separated). | |
| bool | controls_from_journal = false |
| The data journal's operator commands (sim::replayable_control) reach the engine at the times the session received them. | |
| AbSection | ab |
| [ab]: an A/B test of the strategy's parameters (strategies/ab_test.hpp); no arms: none. | |
| std::map< std::string, std::vector< std::string > > | param_groups |
| [strategy.groups] and [strategy.overrides]: parameters per instrument, set at the start (strategies/param_overrides.hpp). | |
| std::map< std::string, ParamMap > | param_overrides |
| int | ab_arm = -1 |
| [ab] assignment = "branch": the arm this run is (an index into ab.arms); fastmm-backtest runs each one in turn. | |
| Duration | reorder_window = milliseconds(1000) |
| Recorded data reaches the simulated venue in venue-time order (sim/venue_order.hpp), assuming no event was received more than this after its venue time; zero keeps the recorded order. | |
|
inlinenoexcept |
The run publishes parameter updates of its own: [ab] or [strategy.overrides] (BacktestSession::enable_ab).
|
static |
Throws ConfigError on invalid values.
|
static |
One instrument (venue 0) with the given tick/lot; generator tick/lot follow (examples).
| FxPlan fastmm::bt::BacktestConfig::fx_plan | ( | const InstrumentTable & | table | ) |
The FX plan for table under accounting (throws ConfigError when a limit reads the totals and the table is not covered; otherwise a warning goes to warnings and nothing converts).
| UnderlyingPlan fastmm::bt::BacktestConfig::underlying_plan | ( | const InstrumentTable & | table | ) | const |
The [risk.underlying] plan for table (throws ConfigError when the spec does not fit it).
| void fastmm::bt::BacktestConfig::set_market_bps | ( | double | spread_bps, |
| double | mid_step_bps, | ||
| double | depth_bps | ||
| ) |
The synthetic market in basis points of generator.start_mid, turned into ticks of generator.tick: the spread from touch to touch (base_spread_ticks, half of it a side), the size of a latent mid step (mid_step_ticks) and the mean distance of a new limit order behind the touch (depth_ticks).
Each comes to at least one tick. from_config() applies the [sim] defaults below unless the tick keys are given; single_instrument() keeps the one-tick market of MarketGeneratorParams.
| bool fastmm::bt::BacktestConfig::set_setting | ( | std::string_view | key, |
| std::string_view | value | ||
| ) |
Sets one of kSweepSettings from its decimal value: latency_fixed_us and latency_jitter_us the order and ack paths of the venues without a [backtest.venues.
<name>] entry, latency_md_us and latency_md_jitter_us their market data, p_drop the share of orders lost, queue_conservatism the queue model's, maker_fee_bps and taker_fee_bps one schedule for every instrument. Returns false for any other key; throws std::invalid_argument for a value out of range.
|
inline |
"key=value" strategy parameter override (CLI --param).
|
inlinenoexcept |
Seeds the synthetic market and the latency model.
| EngineConfig fastmm::bt::BacktestConfig::engine |
| InstrumentTable fastmm::bt::BacktestConfig::instruments |
| std::string fastmm::bt::BacktestConfig::strategy |
registry name (apps / Python); ignored by run_backtest<S>()
| ParamMap fastmm::bt::BacktestConfig::params |
| sim::SimTransportConfig fastmm::bt::BacktestConfig::transport |
| sim::MarketGeneratorParams fastmm::bt::BacktestConfig::generator |
| std::uint64_t fastmm::bt::BacktestConfig::seed = 1 |
synthetic market + latency model (engine.rng_seed is separate)
| double fastmm::bt::BacktestConfig::initial_capital = 0.0 |
reporting only (drawdown %)
| AccountingSpec fastmm::bt::BacktestConfig::accounting |
[accounting] and the venue names its sources name (Config::venues order).
from_config() builds engine.fx from them for instruments; replay builds it again for the journal's table.
| std::vector<std::string> fastmm::bt::BacktestConfig::venue_names |
| UnderlyingSpec fastmm::bt::BacktestConfig::underlying |
[risk.underlying]: from_config() builds engine.underlying from it for instruments; replay builds it again for the journal's table.
| std::vector<std::string> fastmm::bt::BacktestConfig::warnings |
from_config: Config::warnings plus unknown [backtest] keys, each naming the key and its line.
| int fastmm::bt::BacktestConfig::generator_seed_levels = 20 |
| std::string fastmm::bt::BacktestConfig::source |
"synthetic" | "journal" | "csv" | "" (caller supplies the source)
| std::string fastmm::bt::BacktestConfig::path |
| std::string fastmm::bt::BacktestConfig::output_dir |
| std::string fastmm::bt::BacktestConfig::journal_out |
record the run to this .fmj (empty = no journal)
| MsgRing* fastmm::bt::BacktestConfig::record_ring = nullptr |
Where the engine puts its records (core/record_stream.hpp), as fastmm-live hands them to the store: the caller's ring, drained by the caller, large enough for the run (a full ring drops records).
Null: none.
| std::string fastmm::bt::BacktestConfig::config_toml |
Effective configuration embedded in journal_out (Config::effective_toml(); from_config() sets it, hand-built configs leave it empty).
Callers that override fields after from_config() must refresh or clear it.
| bool fastmm::bt::BacktestConfig::measure_wall_clock = true |
| bool fastmm::bt::BacktestConfig::keep_orders = true |
The result keeps a row for every order sent (BacktestResult::orders).
A sweep's points do not: their metrics count the orders as they go (OrderStats), and the outbound hash covers them.
| std::vector<Duration> fastmm::bt::BacktestConfig::markout_horizons = {seconds(1), seconds(10), seconds(60)} |
Post-fill markout horizons in simulated time; empty turns markouts off.
The run stops the simulated clock at every fill time + horizon to read the venue mid there, so the shortest horizon also bounds how often the run loop is entered.
| bool fastmm::bt::BacktestConfig::balances_from_journal = false |
Start each venue's account (transport.accounts) from the first balance snapshot the journal source recorded for it; a venue it has none for keeps the configured balances.
| std::vector<TreasuryConfig> fastmm::bt::BacktestConfig::treasuries |
The pool treasuries ([venues.
<primary>.treasury] with enabled): each runs on simulated time against its pool's simulated accounts (sim/sim_treasury.hpp), without a ledger file. Empty: none, and the run is what it was without them.
| Duration fastmm::bt::BacktestConfig::transfer_latency {} |
[backtest] transfer_latency_ms: a simulated transfer is carried out this long after it is sent.
| double fastmm::bt::BacktestConfig::transfer_p_fail = 0.0 |
[backtest] transfer_p_fail, transfer_p_unknown, transfer_hang_ms: the simulated venue refuses a transfer, or loses its answer and carries it out transfer_hang later (sim::SimTransferFaults).
| double fastmm::bt::BacktestConfig::transfer_p_unknown = 0.0 |
| Duration fastmm::bt::BacktestConfig::transfer_hang = milliseconds(90'000) |
| InitialState fastmm::bt::BacktestConfig::initial_state = InitialState::StateFile |
The strategy's starting state; Journal also starts the engine's positions where the recorded session had them (sim::SessionStart).
| std::vector<StartPosition> fastmm::bt::BacktestConfig::positions |
[backtest.positions]: the engine's positions at the start, by instrument. They replace the
journal's (initial_state = "journal") for the instruments listed: a backtest that starts at a part from the middle of a session, whose records do not repeat the positions, starts where the session was.
| Timestamp fastmm::bt::BacktestConfig::start_at {} |
[backtest] start_at: the run reads the data from its start (the books and the strategy's view of the market warm up), but trading starts later: with initial_state = "journal" at the last checkpoint of the data journal at or before this time, whose state the strategy restores as a warm standby's take-over does, else at this time.
Until then every venue an order can go to has not reconciled, so the engine refuses orders (NotReconciled); at the start each one reconciles with the start positions. Invalid: trading starts with the data.
| bool fastmm::bt::BacktestConfig::latency_from_journal = false |
[backtest] latency_from_journal: the simulated venues take a message's latency from the data journal's own messages around the same time where that is longer than the model's draw (sim/recorded_latency.hpp); the data source must be a journal.
| bool fastmm::bt::BacktestConfig::params_from_journal = false |
The data journal's parameter updates reach the strategy at the times the session received them (sim::RecordedParams), mapped by name and type onto its schema.
| std::vector<std::string> fastmm::bt::BacktestConfig::params_pinned |
params_from_journal leaves these parameters at the configured values: a counterfactual run keeps the session's other updates ([backtest] params_pinned, comma-separated).
| bool fastmm::bt::BacktestConfig::controls_from_journal = false |
The data journal's operator commands (sim::replayable_control) reach the engine at the times the session received them.
| AbSection fastmm::bt::BacktestConfig::ab |
[ab]: an A/B test of the strategy's parameters (strategies/ab_test.hpp); no arms: none.
| std::map<std::string, std::vector<std::string> > fastmm::bt::BacktestConfig::param_groups |
[strategy.groups] and [strategy.overrides]: parameters per instrument, set at the start (strategies/param_overrides.hpp).
| std::map<std::string, ParamMap> fastmm::bt::BacktestConfig::param_overrides |
| int fastmm::bt::BacktestConfig::ab_arm = -1 |
[ab] assignment = "branch": the arm this run is (an index into ab.arms); fastmm-backtest runs each one in turn.
| Duration fastmm::bt::BacktestConfig::reorder_window = milliseconds(1000) |
Recorded data reaches the simulated venue in venue-time order (sim/venue_order.hpp), assuming no event was received more than this after its venue time; zero keeps the recorded order.