19 const double b = beta.value();
21 const double phi = std::atanh(b);
22 if (!std::isfinite(phi))
return std::nullopt;
30 const double b = beta.value();
31 const double numerator = 1.0 + b;
32 const double denominator = 1.0 - b;
34 if (denominator <= 0.0 || !std::isfinite(denominator))
return std::nullopt;
35 const double ratio = numerator / denominator;
36 if (ratio < 0.0 || !std::isfinite(ratio))
return std::nullopt;
37 const double d = std::sqrt(ratio);
38 if (!std::isfinite(d) || d <= 0.0)
return std::nullopt;
44std::optional<BetaVelocityResult>
47 if (!bv_opt)
return std::nullopt;
52 if (!gamma_opt)
return std::nullopt;
56 if (!phi_opt)
return std::nullopt;
60 if (!d_opt)
return std::nullopt;
72std::optional<BetaVelocityResult>
74 const std::vector<double>& prices,
75 double c_market)
const noexcept {
78 if (!std::isfinite(c_market) || c_market <= 0.0)
return std::nullopt;
81 if (prices.size() < 2)
return std::nullopt;
84 for (
const double p : prices) {
85 if (!std::isfinite(p) || p <= 0.0)
return std::nullopt;
89 const std::size_t n = prices.size() - 1u;
91 for (std::size_t i = 0; i < n; ++i) {
92 const double ratio = prices[i + 1u] / prices[i];
93 if (ratio <= 0.0 || !std::isfinite(ratio))
return std::nullopt;
94 const double log_ret = std::log(ratio);
95 if (!std::isfinite(log_ret))
return std::nullopt;
100 const double mean_velocity = sum /
static_cast<double>(n);
101 if (!std::isfinite(mean_velocity))
return std::nullopt;
104 double beta_raw = mean_velocity / c_market;
105 if (!std::isfinite(beta_raw))
return std::nullopt;
109 if (beta_raw > CLAMP) beta_raw = CLAMP;
110 if (beta_raw < -CLAMP) beta_raw = -CLAMP;
std::optional< BetaVelocityResult > fromPriceVelocityOnline(const std::vector< double > &prices, double c_market=1.0) const noexcept
Compute BetaVelocityResult from a streaming price series.
Normalised market velocity β = price_velocity / c_market.
double value() const noexcept
Returns the raw β value.
static std::optional< BetaVelocity > make(double value) noexcept
Validate and construct a BetaVelocity.
std::optional< BetaVelocityResult > full_beta_result(double beta_value) noexcept
Compute full BetaVelocityResult for a given β value.
std::optional< double > doppler_factor(BetaVelocity beta) noexcept
Compute relativistic Doppler factor D(β) = √((1+β)/(1−β)).
std::optional< double > rapidity(BetaVelocity beta) noexcept
Compute rapidity φ = atanh(β).
std::optional< LorentzFactor > lorentz_gamma(BetaVelocity beta) noexcept
Compute Lorentz factor γ = 1/√(1−β²).
constexpr double BETA_MAX_SAFE
BetaCalculator — financial-to-physics velocity mapping (AGT-01).
Computed relativistic quantities for a given β.