FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::bt::BacktestConfig Struct Reference

#include <fastmm/backtest/backtest_config.hpp>

Public Member Functions

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_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)
 
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
 
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.
 
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).
 
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.
 
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.
 

Member Function Documentation

◆ from_config()

static BacktestConfig fastmm::bt::BacktestConfig::from_config ( const Config &  cfg)
static

Throws ConfigError on invalid values.

◆ single_instrument()

static BacktestConfig fastmm::bt::BacktestConfig::single_instrument ( std::string_view  symbol,
Price  tick,
Qty  lot 
)
static

One instrument (venue 0) with the given tick/lot; generator tick/lot follow (examples).

◆ fx_plan()

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).

◆ underlying_plan()

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).

◆ set_param()

void fastmm::bt::BacktestConfig::set_param ( const std::string &  key,
const std::string &  value 
)
inline

"key=value" strategy parameter override (CLI --param).

◆ set_seed()

void fastmm::bt::BacktestConfig::set_seed ( std::uint64_t  s)
inlinenoexcept

Seeds the synthetic market and the latency model.

Member Data Documentation

◆ engine

EngineConfig fastmm::bt::BacktestConfig::engine

◆ instruments

InstrumentTable fastmm::bt::BacktestConfig::instruments

◆ strategy

std::string fastmm::bt::BacktestConfig::strategy

registry name (apps / Python); ignored by run_backtest<S>()

◆ params

ParamMap fastmm::bt::BacktestConfig::params

◆ transport

sim::SimTransportConfig fastmm::bt::BacktestConfig::transport

◆ generator

sim::MarketGeneratorParams fastmm::bt::BacktestConfig::generator

◆ seed

std::uint64_t fastmm::bt::BacktestConfig::seed = 1

synthetic market + latency model (engine.rng_seed is separate)

◆ start

Timestamp fastmm::bt::BacktestConfig::start {seconds(1'700'000'000).ns}

◆ duration

Duration fastmm::bt::BacktestConfig::duration = seconds(60)

synthetic horizon

◆ equity_bar

Duration fastmm::bt::BacktestConfig::equity_bar = seconds(1)

◆ initial_capital

double fastmm::bt::BacktestConfig::initial_capital = 0.0

reporting only (drawdown %)

◆ accounting

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.

◆ venue_names

std::vector<std::string> fastmm::bt::BacktestConfig::venue_names

◆ underlying

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.

◆ warnings

std::vector<std::string> fastmm::bt::BacktestConfig::warnings

from_config: Config::warnings plus unknown [backtest] keys, each naming the key and its line.

◆ generator_seed_levels

int fastmm::bt::BacktestConfig::generator_seed_levels = 20

◆ source

std::string fastmm::bt::BacktestConfig::source

"synthetic" | "journal" | "csv" | "" (caller supplies the source)

◆ path

std::string fastmm::bt::BacktestConfig::path

◆ output_dir

std::string fastmm::bt::BacktestConfig::output_dir

◆ journal_out

std::string fastmm::bt::BacktestConfig::journal_out

record the run to this .fmj (empty = no journal)

◆ config_toml

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.

◆ measure_wall_clock

bool fastmm::bt::BacktestConfig::measure_wall_clock = true

◆ markout_horizons

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.

◆ balances_from_journal

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.

◆ treasuries

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.

◆ transfer_latency

Duration fastmm::bt::BacktestConfig::transfer_latency {}

[backtest] transfer_latency_ms: a simulated transfer is carried out this long after it is sent.

◆ initial_state

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).

◆ params_from_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.

◆ reorder_window

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.