pub struct Market { /* private fields */ }
Expand description
Container or adaptor to market data
Implementations
sourceimpl Market
impl Market
pub async fn new(db: Arc<dyn QuoteHandler + Sync + Send>) -> Market
pub fn set_cache_policy(&mut self, cache_policy: CachePolicy)
pub fn db(&self) -> Arc<dyn QuoteHandler + Sync + Send>
sourcepub fn get_calendar(&self, name: &str) -> Result<&Calendar, MarketError>
pub fn get_calendar(&self, name: &str) -> Result<&Calendar, MarketError>
Get calendar from market
sourcepub async fn get_currency(
&mut self,
currency_string: &str
) -> Result<Currency, MarketError>
pub async fn get_currency(
&mut self,
currency_string: &str
) -> Result<Currency, MarketError>
Get currency from market
sourcepub async fn get_currency_by_id(
&self,
currency_id: i32
) -> Result<Currency, MarketError>
pub async fn get_currency_by_id(
&self,
currency_id: i32
) -> Result<Currency, MarketError>
Get currency from market
sourcepub fn add_provider(
&mut self,
name: String,
provider: Arc<dyn MarketQuoteProvider + Sync + Send>
)
pub fn add_provider(
&mut self,
name: String,
provider: Arc<dyn MarketQuoteProvider + Sync + Send>
)
Add market data provider
sourcepub async fn update_quotes(&self) -> Result<Vec<i32>, MarketError>
pub async fn update_quotes(&self) -> Result<Vec<i32>, MarketError>
Fetch latest quotes for all active ticker Returns a list of ticker for which the update failed.
sourcepub async fn update_quote_history(
&self,
ticker_id: i32,
start: DateTime<Local>,
end: DateTime<Local>
) -> Result<(), MarketError>
pub async fn update_quote_history(
&self,
ticker_id: i32,
start: DateTime<Local>,
end: DateTime<Local>
) -> Result<(), MarketError>
Fetch latest quotes for all active ticker
sourcepub async fn update_quote_history_for_asset(
&self,
asset_id: i32,
start: DateTime<Local>,
end: DateTime<Local>
) -> Result<(), MarketError>
pub async fn update_quote_history_for_asset(
&self,
asset_id: i32,
start: DateTime<Local>,
end: DateTime<Local>
) -> Result<(), MarketError>
Update quote history using all tickers of given asset
pub fn try_from_cache(
&self,
asset_id: i32,
time: DateTime<Local>
) -> Option<(f64, i32)>
pub async fn get_asset_price(
&self,
asset_id: i32,
currency: Currency,
time: DateTime<Local>
) -> Result<f64, MarketError>
Trait Implementations
sourceimpl CurrencyConverter for Market
impl CurrencyConverter for Market
sourcefn fx_rate<'life0, 'async_trait>(
&'life0 self,
base_currency: Currency,
quote_currency: Currency,
time: DateTime<Local>
) -> Pin<Box<dyn Future<Output = Result<f64, CurrencyError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn fx_rate<'life0, 'async_trait>(
&'life0 self,
base_currency: Currency,
quote_currency: Currency,
time: DateTime<Local>
) -> Pin<Box<dyn Future<Output = Result<f64, CurrencyError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
returns the price of 1 unit of base currency in terms of quote currency
Auto Trait Implementations
impl !RefUnwindSafe for Market
impl Send for Market
impl Sync for Market
impl Unpin for Market
impl !UnwindSafe for Market
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more