Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Public Member Functions | List of all members
srfm::event_bt::BacktestEngine Class Reference

#include <event_backtester.hpp>

Public Member Functions

 BacktestEngine (double initial_cash=100 '000.0, double commission=0.001) noexcept
 
void set_strategy (std::unique_ptr< Strategy > strat) noexcept
 Set the strategy to drive order generation.
 
void add_event (BacktestEvent event)
 Insert a market event into the priority queue.
 
BacktestResult run ()
 
const std::vector< Fill > & fills () const noexcept
 Const accessor for the fill history.
 
const Portfolio & portfolio () const noexcept
 Const accessor for the portfolio state after run().
 

Detailed Description

Event-driven backtesting engine.

Events are inserted via add_event() and processed in strict timestamp order by run(). The engine simulates market fills, tracks a Portfolio, and returns a BacktestResult.

Usage:

BacktestEngine engine(10'000.0, 0.001);
engine.set_strategy(std::make_unique<MyStrategy>());
for (auto& ev : raw_events) engine.add_event(ev);
auto result = engine.run();
void add_event(BacktestEvent event)
Insert a market event into the priority queue.

Definition at line 179 of file event_backtester.hpp.

Constructor & Destructor Documentation

◆ BacktestEngine()

srfm::event_bt::BacktestEngine::BacktestEngine ( double  initial_cash = 100'000.0,
double  commission = 0.001 
)
inlineexplicitnoexcept
Parameters
initial_cashStarting cash in quote currency.
commissionCommission fraction per trade notional.

Definition at line 183 of file event_backtester.hpp.

Member Function Documentation

◆ add_event()

void srfm::event_bt::BacktestEngine::add_event ( BacktestEvent  event)
inline

Insert a market event into the priority queue.

Definition at line 197 of file event_backtester.hpp.

◆ fills()

const std::vector< Fill > & srfm::event_bt::BacktestEngine::fills ( ) const
inlinenoexcept

Const accessor for the fill history.

Definition at line 207 of file event_backtester.hpp.

◆ portfolio()

const Portfolio & srfm::event_bt::BacktestEngine::portfolio ( ) const
inlinenoexcept

Const accessor for the portfolio state after run().

Definition at line 210 of file event_backtester.hpp.

◆ run()

BacktestResult srfm::event_bt::BacktestEngine::run ( )

Process all queued events and return aggregate performance.

Returns
BacktestResult populated after all events are consumed.

Definition at line 94 of file event_backtester.cpp.

◆ set_strategy()

void srfm::event_bt::BacktestEngine::set_strategy ( std::unique_ptr< Strategy >  strat)
inlinenoexcept

Set the strategy to drive order generation.

Definition at line 192 of file event_backtester.hpp.


The documentation for this class was generated from the following files: