Skip to main content

AltDataAggregator

Struct AltDataAggregator 

Source
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

Source

pub fn new() -> Self

Create an empty aggregator.

Source

pub fn ingest(&mut self, point: AltDataPoint)

Ingest a new data point, updating the latest observation and history.

Source

pub fn latest( &self, symbol: &str, source: &AltDataSource, ) -> Option<&AltDataPoint>

Return the most-recent data point for (symbol, source), if any.

Source

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.

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Default for AltDataAggregator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.