pub struct AltDataAggregator { /* private fields */ }Expand description
Ingests and queries alternative data across sources and symbols.
Internally keyed by (symbol, source). Only the most-recent data point per
(symbol, source) pair is retained for latest() queries; all historical
values are retained for anomaly scoring.
Implementations§
Source§impl AltDataAggregator
impl AltDataAggregator
Sourcepub fn ingest(&mut self, point: AltDataPoint)
pub fn ingest(&mut self, point: AltDataPoint)
Ingest a new data point, updating the latest observation and history.
Sourcepub fn latest(
&self,
symbol: &str,
source: &AltDataSource,
) -> Option<&AltDataPoint>
pub fn latest( &self, symbol: &str, source: &AltDataSource, ) -> Option<&AltDataPoint>
Return the most-recent data point for (symbol, source), if any.
Sourcepub fn composite_signal(
&self,
symbol: &str,
weights: &HashMap<String, f64>,
) -> f64
pub fn composite_signal( &self, symbol: &str, weights: &HashMap<String, f64>, ) -> f64
Compute a composite signal for symbol as a weighted average of all
available source values.
weights maps source debug names (e.g. "SocialSentiment") to their weight.
Sources absent from the map receive weight 1.0.
Returns 0.0 if no data is available for the symbol.
Sourcepub fn signal_correlation(&self, symbol_a: &str, symbol_b: &str) -> Option<f64>
pub fn signal_correlation(&self, symbol_a: &str, symbol_b: &str) -> Option<f64>
Compute the Pearson correlation between the composite signals of two symbols
across matching (symbol, source) time series.
Uses all historical values for each source shared by both symbols.
Returns None if there are fewer than 2 aligned observations.
Sourcepub fn anomaly_score(&self, symbol: &str, source: &AltDataSource) -> Option<f64>
pub fn anomaly_score(&self, symbol: &str, source: &AltDataSource) -> Option<f64>
Compute the z-score of the latest value for (symbol, source) relative to
the historical distribution for that source.
Returns None if fewer than 2 historical values exist.
Sourcepub fn freshness_check(
&self,
max_age_hours: u8,
now: u64,
) -> Vec<(String, AltDataSource)>
pub fn freshness_check( &self, max_age_hours: u8, now: u64, ) -> Vec<(String, AltDataSource)>
Return all (symbol, source) pairs whose latest observation is older than
max_age_hours relative to now (Unix seconds).