|
Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
|
#include <beta_calculator.hpp>
Public Member Functions | |
| BetaCalculator ()=delete | |
Static Public Member Functions | |
| static std::optional< BetaVelocity > | fromPriceVelocity (double price_velocity, double max_velocity) noexcept |
| static std::optional< BetaVelocity > | fromReturn (double period_return, double max_return) noexcept |
| static std::optional< BetaVelocity > | fromRollingWindow (std::span< const double > prices, std::size_t window, double max_velocity, double time_delta) noexcept |
| static std::optional< std::vector< BetaVelocity > > | fromPriceVelocityOnline (std::span< const double > prices, double time_delta) noexcept |
| static std::optional< double > | meanAbsVelocity (std::span< const double > prices, double time_delta) noexcept |
| static bool | isNewtonian (BetaVelocity beta) noexcept |
| static bool | isRelativistic (BetaVelocity beta) noexcept |
| static bool | isValid (BetaVelocity beta) noexcept |
| Return true if β is in the valid safe range (|β| < BETA_MAX_SAFE). | |
| static BetaVelocity | clamp (double raw_beta) noexcept |
| static std::optional< double > | kineticEnergy (BetaVelocity beta, double effective_mass, double c_market=constants::SPEED_OF_INFORMATION) noexcept |
| static std::optional< double > | dopplerFactor (BetaVelocity beta) noexcept |
Maps financial market observables to the β velocity parameter.
All methods are static. BetaCalculator holds no state — it is a transformation namespace in class form.
Definition at line 50 of file beta_calculator.hpp.
|
delete |
|
staticnoexcept |
Clamp an arbitrary raw_beta to the safe range (−BETA_MAX_SAFE, BETA_MAX_SAFE).
Use this as a safety net when β is computed from noisy data that might occasionally exceed 1. Does not return nullopt — always produces a valid β.
Definition at line 217 of file beta_calculator.cpp.
|
staticnoexcept |
Relativistic Doppler factor: D = √((1 + β) / (1 − β)).
Models the frequency shift of a signal emitted by a moving market. D > 1: observer sees higher frequency (market approaching — momentum). D < 1: observer sees lower frequency (market receding — mean-reversion).
Some(D) > 0None if β is invalid or |β| ≥ 1 (D would be undefined) Definition at line 258 of file beta_calculator.cpp.
|
staticnoexcept |
Compute β = |price_velocity| / max_velocity.
The primary factory: given a computed price velocity (dP/dt) and the maximum reference velocity, returns the normalised β.
price_velocity — dP/dt (any finite double, sign preserved for direction)max_velocity — Reference maximum velocity (must be > 0)Some(β) clamped to [0, BETA_MAX_SAFE) if max_velocity > 0None if max_velocity ≤ 0 or price_velocity is non-finiteIf max_velocity was computed over the full price series (e.g. the global maximum velocity), then bar 1's β is normalised by a quantity that includes information from bar N — a form of look-ahead bias. This is acceptable for offline research / backtesting where the full series is known. For streaming or walk-forward applications, use fromPriceVelocityOnline instead.
Definition at line 32 of file beta_calculator.cpp.
|
staticnoexcept |
Compute a β series online — no look-ahead bias.
For bar i, β_i is normalised by the maximum instantaneous velocity observed from bar 0 to bar i only. This means future bars have no influence on earlier β values — causal, streaming-safe.
Contrast with fromPriceVelocity which uses a caller-supplied max_velocity that may have been computed over the full series (look-ahead bias).
For each bar i:
prices — Full price series (at least 2 elements)time_delta — Constant time step between observations (must be > 0)Some(vector<BetaVelocity>) of length prices.size() — one β per barNone if prices.size() < 2, time_delta ≤ 0, or any price is non-finiteDefinition at line 137 of file beta_calculator.cpp.
|
staticnoexcept |
Compute β from a single-period percent return and a maximum reference.
β = |return| / max_return
Suitable for daily/intraday return data. Negative returns become positive β (speed is always non-negative; direction is separate).
Some(β) ∈ [0, BETA_MAX_SAFE)None if max_return ≤ 0 or return is non-finite Definition at line 49 of file beta_calculator.cpp.
|
staticnoexcept |
Compute β from a contiguous price window using central differencing.
Estimates dP/dt over window prices with constant time_delta between samples, then normalises by max_velocity to get β.
Uses the mean absolute velocity over the window to smooth noise.
prices — Price time series (must have at least 2 elements)window — Number of most-recent prices to include (≤ prices.size())max_velocity — Reference maximum velocity (must be > 0)time_delta — Time between successive prices (must be > 0)Some(β) normalised mean rolling velocityNone if inputs are invalid (empty, window < 2, non-finite data) Definition at line 108 of file beta_calculator.cpp.
|
staticnoexcept |
Return true if β is in the Newtonian regime (|β| < BETA_NEWTONIAN_THRESHOLD).
In the Newtonian regime γ ≈ 1 + β²/2 — relativistic corrections are negligible (less than 0.5%). Classical indicators apply directly.
Definition at line 203 of file beta_calculator.cpp.
|
staticnoexcept |
Return true if β is in the relativistic regime (|β| ≥ BETA_NEWTONIAN_THRESHOLD).
Relativistic corrections are significant; γ departs from 1 by more than ~0.5%. Lorentz-corrected indicators must be used.
Definition at line 207 of file beta_calculator.cpp.
|
staticnoexcept |
Return true if β is in the valid safe range (|β| < BETA_MAX_SAFE).
Definition at line 211 of file beta_calculator.cpp.
|
staticnoexcept |
Relativistic kinetic energy analog: E_k = (γ − 1) · m_eff · c²_market.
The "excess energy" above the rest-frame baseline, representing the additional energy a market agent would need to sustain a velocity β.
beta — Market velocityeffective_mass — Liquidity proxy (must be > 0)c_market — Speed of information (default = SPEED_OF_INFORMATION)Some(E_k) ≥ 0None if effective_mass ≤ 0 or β is invalid Definition at line 236 of file beta_calculator.cpp.
|
staticnoexcept |
Estimate price velocity dP/dt using central finite differences.
For a series p₀…pₙ₋₁ with constant step time_delta: v_i = (p_{i+1} − p_{i-1}) / (2·time_delta) for interior points v_0 = (p_1 − p_0) / time_delta for the left boundary v_n = (pₙ − pₙ₋₁) / time_delta for the right boundary
Returns the mean absolute velocity over the series.
Some(v) ≥ 0None if prices has < 2 elements or time_delta ≤ 0 Definition at line 66 of file beta_calculator.cpp.