use crate::constants::{Interval, TimeRange};
use crate::error::Result;
use crate::models::chart::Chart;
domain_handle! {
pub struct Index { symbol, symbol }
cache: crate::models::indices::IndexQuote, chart
}
impl Index {
pub async fn quote(&self) -> Result<crate::models::indices::IndexQuote> {
fetch_via!(
self,
symbol,
INDICES,
fetch_indices_quote,
crate::models::indices::IndexQuote
)
}
pub async fn chart(&self, interval: Interval, range: TimeRange) -> Result<Chart> {
fetch_chart_via!(self, self.symbol.to_string(), interval, range)
}
pub async fn history(&self, range: TimeRange) -> Result<Chart> {
self.chart(range.default_interval(), range).await
}
}
impl_chartable_analytics!(Index, crate::risk::TradingCalendar::Exchange);