Skip to main content

HistoryProvider

Trait HistoryProvider 

Source
pub trait HistoryProvider {
    type Error: Display + Debug + 'static;

    // Required method
    fn history_bars_before<'life0, 'async_trait>(
        &'life0 self,
        symbol: String,
        timeframe: TimeFrame,
        before_time: i64,
        count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Candlestick>, DataProviderError<Self::Error>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Supplies older historical bars for incremental history extension.

Implement alongside DataProvider to enable efficient extend_history: only the bars older than the current cache are fetched, then merged with cached bars before scripts are re-executed.

Required Associated Types§

Source

type Error: Display + Debug + 'static

The error payload type; should match DataProvider::Error on the same implementing type.

Required Methods§

Source

fn history_bars_before<'life0, 'async_trait>( &'life0 self, symbol: String, timeframe: TimeFrame, before_time: i64, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Candlestick>, DataProviderError<Self::Error>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch up to count bars for symbol/timeframe where bar.time < before_time, returned in strict ascending time order (oldest first).

Returning an empty Vec signals that no older data is available (history exhausted).

Implementations on Foreign Types§

Source§

impl HistoryProvider for Vec<CandlestickItem>

Source§

type Error = Infallible

Source§

fn history_bars_before<'life0, 'async_trait>( &'life0 self, _symbol: String, _timeframe: TimeFrame, before_time: i64, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Candlestick>, DataProviderError<Self::Error>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl HistoryProvider for Vec<Candlestick>

Source§

type Error = Infallible

Source§

fn history_bars_before<'life0, 'async_trait>( &'life0 self, _symbol: String, _timeframe: TimeFrame, before_time: i64, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Candlestick>, DataProviderError<Self::Error>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<P> HistoryProvider for Rc<P>
where P: HistoryProvider + 'static,

Source§

type Error = <P as HistoryProvider>::Error

Source§

fn history_bars_before<'life0, 'async_trait>( &'life0 self, symbol: String, timeframe: TimeFrame, before_time: i64, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Candlestick>, DataProviderError<Self::Error>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§