pub struct AssetManager { /* private fields */ }Expand description
Asset manager
Implementations§
Source§impl AssetManager
impl AssetManager
pub fn new() -> Self
pub fn initialize(&mut self) -> Result<(), FinancialError>
Sourcepub fn register_price_feed(&mut self, feed: PriceFeed)
pub fn register_price_feed(&mut self, feed: PriceFeed)
Register a price feed. The feed is keyed by its asset_id so that
ingest_from_feed(asset_id) can locate it. Re-registering a feed for the
same asset replaces the prior one.
Sourcepub fn update_price_history(&mut self, asset_id: &str, prices: Vec<f64>)
pub fn update_price_history(&mut self, asset_id: &str, prices: Vec<f64>)
Directly set the cached price history (oldest first) for asset_id. This
is the manual entry point; ingest_from_feed is the feed-driven one. The
history is held in the manager’s cache until apply_to_asset copies it
onto an Asset.
Sourcepub fn get_price_history(&self, asset_id: &str) -> Option<&Vec<f64>>
pub fn get_price_history(&self, asset_id: &str) -> Option<&Vec<f64>>
Look up the cached price history for asset_id, if any.
Sourcepub fn ingest_from_feed(&mut self, asset_id: &str) -> Result<(), FinancialError>
pub fn ingest_from_feed(&mut self, asset_id: &str) -> Result<(), FinancialError>
Simulate fetching data from a registered price feed for asset_id and
populate the manager’s price-history cache. If the feed carries
cached_prices, those are used directly; otherwise a deterministic series
(seeded from feed_id, so the same feed always yields the same history)
is generated — there is no real network in this scaffold. Returns
DataError when no feed is registered for the asset.
Sourcepub fn apply_to_asset(&self, asset: &mut Asset)
pub fn apply_to_asset(&self, asset: &mut Asset)
Copy the manager’s cached price history for asset.asset_id onto the
asset’s price_history, and refresh current_price/market_value from
the last price. No-op when no history is cached for the asset.
pub fn market_data(&self) -> &MarketData
pub fn market_data_mut(&mut self) -> &mut MarketData
Auto Trait Implementations§
impl Freeze for AssetManager
impl RefUnwindSafe for AssetManager
impl Send for AssetManager
impl Sync for AssetManager
impl Unpin for AssetManager
impl UnsafeUnpin for AssetManager
impl UnwindSafe for AssetManager
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more