finance_query/domains/
indices.rs1use crate::constants::{Interval, TimeRange};
6use crate::error::Result;
7use crate::models::chart::Chart;
8
9domain_handle! {
10 pub struct Index { symbol, symbol }
14 cache: crate::models::indices::IndexQuote, chart
15}
16
17impl Index {
18 pub async fn quote(&self) -> Result<crate::models::indices::IndexQuote> {
20 fetch_via!(
21 self,
22 symbol,
23 INDICES,
24 fetch_indices_quote,
25 crate::models::indices::IndexQuote
26 )
27 }
28
29 pub async fn chart(&self, interval: Interval, range: TimeRange) -> Result<Chart> {
34 fetch_chart_via!(self, self.symbol.to_string(), interval, range)
35 }
36
37 pub async fn history(&self, range: TimeRange) -> Result<Chart> {
40 self.chart(range.default_interval(), range).await
41 }
42}
43
44impl_chartable_analytics!(Index, crate::risk::TradingCalendar::Exchange);