pub struct AssetManager { /* private fields */ }Expand description
Asset manager
Implementations§
Source§impl AssetManager
impl AssetManager
Sourcepub fn initialize(&mut self) -> Result<(), FinancialError>
pub fn initialize(&mut self) -> Result<(), FinancialError>
Initialize AssetManager; Ok when ready.
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>
Fetch data from a registered price feed for asset_id and populate the manager’s
price-history cache.
Requires non-empty cached_prices on the registered feed. If no prices are cached,
fails closed with DataError rather than silently fabricating a synthetic market feed.
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.
Sourcepub fn market_data(&self) -> &MarketData
pub fn market_data(&self) -> &MarketData
The market_data component.
Sourcepub fn market_data_mut(&mut self) -> &mut MarketData
pub fn market_data_mut(&mut self) -> &mut MarketData
The market_data component (mutable).
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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