use crate::constants::{Interval, TimeRange};
use crate::error::Result;
use crate::models::chart::Chart;
domain_handle! {
pub struct FuturesContract { symbol, symbol }
cache: crate::models::futures::FuturesQuote, chart
}
impl FuturesContract {
pub async fn quote(&self) -> Result<crate::models::futures::FuturesQuote> {
fetch_via!(
self,
symbol,
FUTURES,
fetch_futures_quote,
crate::models::futures::FuturesQuote
)
}
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!(FuturesContract, crate::risk::TradingCalendar::Exchange);