Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Classes | Functions
backtest_runner.cpp File Reference

Empirical Validation Binary — Three-Strategy Backtest Runner. More...

#include "srfm/geodesic_strategy.hpp"
#include "srfm/backtest.hpp"
#include "srfm/constants.hpp"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <optional>
#include <sstream>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  RegimeRow
 
struct  Args
 

Functions

static std::vector< std::string > split_csv (const std::string &line)
 
static std::optional< double > safe_double (const std::string &s)
 
static int find_col (const std::vector< std::string > &hdr, const std::string &name)
 
static std::optional< std::vector< RegimeRow > > load_regime_csv (const std::string &path, std::string &err)
 
static std::pair< std::vector< srfm::backtest::GeodesicBarData >, std::vector< double > > build_bars (const std::vector< RegimeRow > &rows)
 
static bool write_backtest_csv (const std::string &ticker, const srfm::backtest::ExtendedBacktester::TripleComparison &result, const std::string &output_dir, std::string &err)
 
static std::optional< Args > parse_args (int argc, char *argv[])
 
int main (int argc, char *argv[])
 

Detailed Description

Empirical Validation Binary — Three-Strategy Backtest Runner.

Binary: backtest_runner

Purpose

Reads a regime CSV (output from regime_validator) and runs all three SRFM strategies (RAW, RELATIVISTIC, GEODESIC_DEVIATION) via ExtendedBacktester. Writes one output row per strategy per ticker:

ticker, strategy, sharpe, sortino, max_drawdown

Also prints a formatted comparison table to stdout.

Usage

backtest_runner –input <regime_csv> –output-dir <dir> [–ticker <name>]

Input Format (regime CSV)

ticker, bar_index, interval_type, next_bar_abs_return, beta, geodesic_deviation

Exit Codes

0 — success 1 — fatal error

Definition in file backtest_runner.cpp.

Function Documentation

◆ build_bars()

static std::pair< std::vector< srfm::backtest::GeodesicBarData >, std::vector< double > > build_bars ( const std::vector< RegimeRow > &  rows)
static

Convert regime rows to GeodesicBarData.

Signal convention: +1 for TIMELIKE (trust causal momentum), −1 for SPACELIKE. Asset return = next_bar_abs_return with sign derived from interval type.

Definition at line 161 of file backtest_runner.cpp.

◆ find_col()

static int find_col ( const std::vector< std::string > &  hdr,
const std::string &  name 
)
static

Definition at line 73 of file backtest_runner.cpp.

◆ load_regime_csv()

static std::optional< std::vector< RegimeRow > > load_regime_csv ( const std::string &  path,
std::string &  err 
)
static

Definition at line 93 of file backtest_runner.cpp.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 263 of file backtest_runner.cpp.

◆ parse_args()

static std::optional< Args > parse_args ( int  argc,
char *  argv[] 
)
static

Definition at line 243 of file backtest_runner.cpp.

◆ safe_double()

static std::optional< double > safe_double ( const std::string &  s)
static

Definition at line 60 of file backtest_runner.cpp.

◆ split_csv()

static std::vector< std::string > split_csv ( const std::string &  line)
static

Definition at line 44 of file backtest_runner.cpp.

◆ write_backtest_csv()

static bool write_backtest_csv ( const std::string &  ticker,
const srfm::backtest::ExtendedBacktester::TripleComparison &  result,
const std::string &  output_dir,
std::string &  err 
)
static

Definition at line 199 of file backtest_runner.cpp.