Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
lorentz_transform.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file src/lorentz/lorentz_transform.hpp
4/// @brief Lorentz Transform Engine — AGT-01 public header.
5///
6/// # Module: Lorentz Transform Engine
7///
8/// ## Responsibility
9/// Implements the core special-relativistic transforms applied to financial
10/// signal processing. The Lorentz factor γ = 1/√(1−β²) scales indicator
11/// weights in fast-moving markets; time dilation stretches signal age;
12/// relativistic momentum amplifies signal magnitude for high-β regimes.
13///
14/// ## Financial Interpretation
15/// β_market = price_velocity / max_observed_velocity
16///
17/// At low β (slow, Newtonian market): γ ≈ 1 — no correction applied.
18/// At high β (fast, relativistic market): γ >> 1 — signals are amplified
19/// and time-weighted more heavily.
20///
21/// ## Guarantees
22/// - All functions are noexcept — no exceptions escape
23/// - All fallible operations return std::optional (no UB, no silent failures)
24/// - Static methods only — no mutable state
25/// - Thread-safe: all operations are pure functions of their inputs
26///
27/// ## NOT Responsible For
28/// - Computing β from raw market data (see beta_calculator.hpp)
29/// - Spacetime interval geometry (see src/manifold/)
30/// - Full tensor field operations (see src/tensor/)
31
32#include "srfm/types.hpp"
33#include "srfm/constants.hpp"
34
35#include <optional>
36
37namespace srfm::lorentz {
38
39/// Lorentz Transform Engine.
40///
41/// Static utility class providing all core special-relativistic transforms
42/// expressed in terms of the normalised velocity parameter β.
44public:
45 LorentzTransform() = delete; // pure static — not instantiable
46
47 // ── Validation ────────────────────────────────────────────────────────────
48
49 /// Return true if β is finite and strictly within the safe range.
50 ///
51 /// Valid range: |β| < BETA_MAX_SAFE (= 0.9999).
52 /// NaN, ±infinity, and |β| ≥ 1 are all invalid.
53 [[nodiscard]] static bool isValidBeta(double beta) noexcept;
54
55 // ── Core Transforms ───────────────────────────────────────────────────────
56
57 /// Compute the Lorentz factor γ = 1 / √(1 − β²).
58 ///
59 /// At β = 0: γ = 1 (Newtonian limit — no relativistic correction).
60 /// At β → 1: γ → ∞ (signals infinitely amplified in the market frame).
61 ///
62 /// # Returns
63 /// - `Some(γ)` with γ ≥ 1.0 for valid β
64 /// - `None` if β is invalid (|β| ≥ 1, NaN, or ±∞)
65 [[nodiscard]] static std::optional<LorentzFactor>
66 gamma(BetaVelocity beta) noexcept;
67
68 /// Apply time dilation: t_dilated = γ · τ_proper.
69 ///
70 /// In the financial context: a signal's effective age is stretched by γ
71 /// in a fast-moving market, making it appear more recent and more relevant.
72 ///
73 /// # Arguments
74 /// * `proper_time` — Signal age in the market's rest frame (must be ≥ 0)
75 /// * `beta` — Normalised market velocity
76 ///
77 /// # Returns
78 /// - `Some(t)` where t ≥ proper_time (dilation never compresses time)
79 /// - `None` if proper_time < 0 or β is invalid
80 [[nodiscard]] static std::optional<double>
81 dilateTime(double proper_time, BetaVelocity beta) noexcept;
82
83 /// Apply relativistic momentum correction: p = γ · m_eff · raw_signal.
84 ///
85 /// The relativistic momentum analog amplifies signals proportionally to γ.
86 /// In the Newtonian limit (β → 0) this reduces to classical momentum
87 /// p = m_eff · raw_signal.
88 ///
89 /// # Arguments
90 /// * `raw_signal` — Unscaled signal value (any finite double)
91 /// * `beta` — Normalised market velocity
92 /// * `effective_mass` — Liquidity-proxy mass parameter (must be > 0)
93 ///
94 /// # Returns
95 /// - `Some(signal)` with adjusted_value = γ · m_eff · raw_signal
96 /// - `None` if effective_mass ≤ 0 or β is invalid
97 [[nodiscard]] static std::optional<RelativisticSignal>
98 applyMomentumCorrection(double raw_signal,
99 BetaVelocity beta,
100 double effective_mass) noexcept;
101
102 /// Relativistic velocity addition: β_total = (β₁ + β₂) / (1 + β₁β₂).
103 ///
104 /// Composes two market velocities according to the relativistic addition
105 /// law. Guarantees |β_total| < 1 when |β₁|, |β₂| < 1, preserving the
106 /// sub-luminal constraint even for large individual velocities.
107 ///
108 /// This is not approximate: it is the exact special-relativistic formula.
109 ///
110 /// # Arguments
111 /// * `beta1`, `beta2` — Two market velocities to compose
112 ///
113 /// # Returns
114 /// The composed velocity. Always sub-luminal if inputs are sub-luminal.
115 [[nodiscard]] static BetaVelocity
116 composeVelocities(BetaVelocity beta1, BetaVelocity beta2) noexcept;
117
118 /// Recover the proper value from a dilated value: τ = t / γ.
119 ///
120 /// Inverse of `dilateTime`. Useful for converting a gamma-weighted
121 /// indicator back to its raw frame value.
122 ///
123 /// # Returns
124 /// - `Some(τ)` = dilated_value / γ
125 /// - `None` if β is invalid
126 [[nodiscard]] static std::optional<double>
127 inverseTransform(double dilated_value, BetaVelocity beta) noexcept;
128
129 /// Apply length contraction: L = L₀ / γ.
130 ///
131 /// In the financial analogy: the "length" of a price move (e.g. a spread
132 /// or range) contracts in the observer frame when the market is moving.
133 ///
134 /// # Arguments
135 /// * `proper_length` — Rest-frame length (must be > 0)
136 /// * `beta` — Normalised market velocity
137 ///
138 /// # Returns
139 /// - `Some(L)` with 0 < L ≤ proper_length
140 /// - `None` if proper_length ≤ 0 or β is invalid
141 [[nodiscard]] static std::optional<double>
142 contractLength(double proper_length, BetaVelocity beta) noexcept;
143
144 /// Compute rapidity: φ = atanh(β).
145 ///
146 /// Rapidity is additive under velocity composition:
147 /// φ(β₁ ⊕ β₂) = φ(β₁) + φ(β₂)
148 ///
149 /// This makes rapidity the natural coordinate for combining market
150 /// velocity signals from multiple assets.
151 ///
152 /// # Returns
153 /// - `Some(φ)` ∈ (−∞, +∞)
154 /// - `None` if β is invalid (|β| ≥ 1 makes atanh undefined)
155 [[nodiscard]] static std::optional<double>
156 rapidity(BetaVelocity beta) noexcept;
157
158 /// Compute relativistic energy: E = γ · m_eff · c²_market.
159 ///
160 /// Total relativistic energy (rest + kinetic) in the financial frame.
161 /// Rest energy E₀ = m_eff · c²_market (baseline liquidity × volatility).
162 ///
163 /// # Arguments
164 /// * `beta` — Normalised market velocity
165 /// * `effective_mass` — Liquidity-proxy mass (must be > 0)
166 /// * `c_market` — Speed of information (default = SPEED_OF_INFORMATION)
167 ///
168 /// # Returns
169 /// - `Some(E)` ≥ E₀
170 /// - `None` if effective_mass ≤ 0 or β is invalid
171 [[nodiscard]] static std::optional<double>
173 double effective_mass,
174 double c_market = constants::SPEED_OF_INFORMATION) noexcept;
175};
176
177} // namespace srfm::lorentz
static std::optional< LorentzFactor > gamma(BetaVelocity beta) noexcept
static std::optional< double > inverseTransform(double dilated_value, BetaVelocity beta) noexcept
static std::optional< RelativisticSignal > applyMomentumCorrection(double raw_signal, BetaVelocity beta, double effective_mass) noexcept
static std::optional< double > dilateTime(double proper_time, BetaVelocity beta) noexcept
static std::optional< double > contractLength(double proper_length, BetaVelocity beta) noexcept
static std::optional< double > totalEnergy(BetaVelocity beta, double effective_mass, double c_market=constants::SPEED_OF_INFORMATION) noexcept
static BetaVelocity composeVelocities(BetaVelocity beta1, BetaVelocity beta2) noexcept
static bool isValidBeta(double beta) noexcept
static std::optional< double > rapidity(BetaVelocity beta) noexcept
Physical and financial constants for the SRFM system.
static constexpr double SPEED_OF_INFORMATION
Definition constants.hpp:37
Shared primitive types for the Special Relativity in Financial Modeling (SRFM) system.