27 Eigen::VectorXd prices(3);
36 Eigen::VectorXd fallback(1);
44 : c_market_(c_market) {}
47 events_.push_back(std::move(event));
51 return events_.size();
62double MinkowskiCovariance::raw_interval(std::size_t i,
63 std::size_t j)
const noexcept {
68 const double dt = b.
t - a.
t;
69 const double dP = b.
P - a.
P;
70 const double dV = b.
V - a.
V;
71 const double dM = b.
M - a.
M;
73 return -(c_market_ * c_market_) * (dt * dt)
81 std::size_t j)
const noexcept {
82 if (i >= events_.size() || j >= events_.size()) {
85 return raw_interval(i, j);
88std::optional<manifold::IntervalType>
90 if (i >= events_.size() || j >= events_.size()) {
93 const double ds2 = raw_interval(i, j);
101std::optional<Eigen::MatrixXd>
103 const std::size_t N = events_.size();
108 Eigen::MatrixXd cov(
static_cast<int>(N),
static_cast<int>(N));
110 for (std::size_t i = 0; i < N; ++i) {
111 for (std::size_t j = 0; j < N; ++j) {
114 cov(
static_cast<int>(i),
static_cast<int>(j)) = 1.0;
121 const double ds2 = raw_interval(i, j);
122 cov(
static_cast<int>(i),
static_cast<int>(j)) =
123 std::exp(-std::abs(ds2));
133SpacetimeCausalGraph::SpacetimeCausalGraph(Eigen::MatrixXi adjacency,
134 std::vector<std::string> ids) noexcept
135 : adj_(std::move(adjacency))
136 , asset_ids_(std::move(ids)) {}
138std::optional<SpacetimeCausalGraph>
140 const std::size_t N = mc.size();
145 const int n =
static_cast<int>(N);
146 Eigen::MatrixXi adj = Eigen::MatrixXi::Zero(n, n);
148 for (std::size_t i = 0; i < N; ++i) {
149 for (std::size_t j = 0; j < N; ++j) {
156 auto ds2_opt = mc.interval_correlation(i, j);
160 const double ds2 = *ds2_opt;
163 adj(
static_cast<int>(i),
static_cast<int>(j)) = 1;
169 std::vector<std::string> ids;
171 for (
const auto& ev : mc.events()) {
172 ids.push_back(ev.asset_id);
183 if (i >=
static_cast<std::size_t
>(adj_.rows()) ||
184 j >=
static_cast<std::size_t
>(adj_.cols())) {
187 return adj_(
static_cast<int>(i),
static_cast<int>(j)) != 0;
191 return static_cast<std::size_t
>(adj_.rows());
195 if (i >=
static_cast<std::size_t
>(adj_.rows())) {
198 return adj_.row(
static_cast<int>(i)).sum();
202 if (j >=
static_cast<std::size_t
>(adj_.cols())) {
205 return adj_.col(
static_cast<int>(j)).sum();
std::optional< Eigen::MatrixXd > compute_spacetime_covariance() const noexcept
std::size_t size() const noexcept
Return the number of asset events currently stored.
std::optional< manifold::IntervalType > classify_pair(std::size_t i, std::size_t j) const noexcept
std::optional< double > interval_correlation(std::size_t i, std::size_t j) const noexcept
const std::vector< AssetEvent > & events() const noexcept
Read-only access to the stored asset events.
void add_asset(AssetEvent event)
void clear() noexcept
Clear all stored events.
MinkowskiCovariance(double c_market=constants::SPEED_OF_INFORMATION) noexcept
std::size_t n_assets() const noexcept
Return the number of assets (graph nodes).
const Eigen::MatrixXi & adjacency_matrix() const noexcept
const std::vector< std::string > & asset_ids() const noexcept
Return asset IDs in the order they were added.
int out_degree(std::size_t i) const noexcept
Return the out-degree of node i (number of assets that i causally precedes).
static std::optional< SpacetimeCausalGraph > build(const MinkowskiCovariance &mc) noexcept
bool has_edge(std::size_t i, std::size_t j) const noexcept
int in_degree(std::size_t j) const noexcept
Return the in-degree of node j (number of assets that causally precede j).
Physical and financial constants for the SRFM system.
@ TIMELIKE
ds² < 0 (causal separation; price change < time*c_market).
@ LIGHTLIKE
|ds²| < threshold (on the light cone).
@ SPACELIKE
ds² > 0 (space-like; price change > time*c_market).
constexpr double LIGHTLIKE_THRESHOLD
|ds²| below this value is classified as LIGHTLIKE.
N-Asset Minkowski Covariance Matrix and Spacetime Causal Graph.
A spacetime event: a moment in time with N asset prices.
static std::optional< NAssetEvent > make(double t, Eigen::VectorXd prices) noexcept
Factory: validate and construct an NAssetEvent.
Eigen::Vector4d to_four_vector() const noexcept
Convert to a 4-vector [t, P, V, M] compatible with the 4D manifold.
manifold::NAssetEvent to_nasset_event() const noexcept
double M
Market-cap coordinate (spatial axis 3)
double P
Price coordinate (spatial axis 1)
double V
Volume coordinate (spatial axis 2)
double t
Market time coordinate (bar index or epoch seconds)