pub struct DatabentoDataLoader { /* private fields */ }Expand description
A Nautilus data loader for Databento Binary Encoding (DBN) format data.
§Supported Schemas
MBO->OrderBookDeltaMBP_1->(QuoteTick, Option<TradeTick>)MBP_10->OrderBookDepth10BBO_1S->QuoteTickBBO_1M->QuoteTickCMBP_1->(QuoteTick, Option<TradeTick>)CBBO_1S->QuoteTickCBBO_1M->QuoteTickTCBBO->(QuoteTick, TradeTick)TBBO->(QuoteTick, TradeTick)TRADES->TradeTickOHLCV_1S->BarOHLCV_1M->BarOHLCV_1H->BarOHLCV_1D->BarOHLCV_EOD->BarDEFINITION->InstrumentIMBALANCE->DatabentoImbalanceSTATISTICS->DatabentoStatisticsSTATUS->InstrumentStatus
§References
Implementations§
Source§impl DatabentoDataLoader
impl DatabentoDataLoader
Sourcepub fn new(publishers_filepath: Option<PathBuf>) -> Result<Self>
pub fn new(publishers_filepath: Option<PathBuf>) -> Result<Self>
Creates a new DatabentoDataLoader instance.
§Errors
Returns an error if locating or loading publishers data fails.
Sourcepub fn load_publishers(&mut self, filepath: PathBuf) -> Result<()>
pub fn load_publishers(&mut self, filepath: PathBuf) -> Result<()>
Load the publishers data from the file at the given filepath.
§Errors
Returns an error if the file cannot be read or parsed as JSON.
Sourcepub const fn get_publishers(&self) -> &IndexMap<u16, DatabentoPublisher>
pub const fn get_publishers(&self) -> &IndexMap<u16, DatabentoPublisher>
Returns the internal Databento publishers currently held by the loader.
Sourcepub fn set_dataset_for_venue(&mut self, dataset: Dataset, venue: Venue)
pub fn set_dataset_for_venue(&mut self, dataset: Dataset, venue: Venue)
Sets the venue to map to the given dataset.
Sourcepub fn get_dataset_for_venue(&self, venue: &Venue) -> Option<&Dataset>
pub fn get_dataset_for_venue(&self, venue: &Venue) -> Option<&Dataset>
Returns the dataset which matches the given venue (if found).
Sourcepub fn get_venue_for_publisher(
&self,
publisher_id: PublisherId,
) -> Option<&Venue>
pub fn get_venue_for_publisher( &self, publisher_id: PublisherId, ) -> Option<&Venue>
Returns the venue which matches the given publisher_id (if found).
Sourcepub fn set_price_precision(&mut self, symbol: Symbol, price_precision: u8)
pub fn set_price_precision(&mut self, symbol: Symbol, price_precision: u8)
Caches a price_precision for the given symbol.
When market data is read without an explicit price_precision argument,
the loader resolves precision per record from this cache. Definitions
loaded via Self::load_instruments are inserted automatically.
Sourcepub const fn get_price_precisions(&self) -> &AHashMap<Symbol, u8>
pub const fn get_price_precisions(&self) -> &AHashMap<Symbol, u8>
Returns the cached price precisions keyed by symbol.
Sourcepub fn schema_from_file(&self, filepath: &Path) -> Result<Option<String>>
pub fn schema_from_file(&self, filepath: &Path) -> Result<Option<String>>
Returns the schema for the given filepath.
§Errors
Returns an error if the file cannot be decoded or metadata retrieval fails.
Sourcepub fn read_definition_records<'a>(
&'a mut self,
filepath: &Path,
use_exchange_as_venue: bool,
decode_config: Option<&'a DatabentoDecodeConfig>,
) -> Result<impl Iterator<Item = Result<InstrumentAny>> + 'a>
pub fn read_definition_records<'a>( &'a mut self, filepath: &Path, use_exchange_as_venue: bool, decode_config: Option<&'a DatabentoDecodeConfig>, ) -> Result<impl Iterator<Item = Result<InstrumentAny>> + 'a>
Reads instrument definition records from a DBN file.
§Errors
Returns an error if decoding the definition records fails.
Sourcepub fn read_records<T>(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
include_trades: bool,
bars_timestamp_on_close: Option<bool>,
) -> Result<impl Iterator<Item = Result<(Option<Data>, Option<Data>)>> + '_>
pub fn read_records<T>( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, include_trades: bool, bars_timestamp_on_close: Option<bool>, ) -> Result<impl Iterator<Item = Result<(Option<Data>, Option<Data>)>> + '_>
Reads and decodes market data records from a DBN file.
§Errors
Returns an error if reading records fails.
Sourcepub fn load_instruments(
&mut self,
filepath: &Path,
use_exchange_as_venue: bool,
skip_on_error: bool,
decode_config: Option<&DatabentoDecodeConfig>,
) -> Result<Vec<InstrumentAny>>
pub fn load_instruments( &mut self, filepath: &Path, use_exchange_as_venue: bool, skip_on_error: bool, decode_config: Option<&DatabentoDecodeConfig>, ) -> Result<Vec<InstrumentAny>>
Loads all instrument definitions from a DBN file.
When skip_on_error is true, instruments that fail to decode are logged
as warnings and skipped. When false (default), any decode error is propagated.
§Errors
Returns an error if loading instruments fails.
Sourcepub fn load_order_book_deltas(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<OrderBookDelta>>
pub fn load_order_book_deltas( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<OrderBookDelta>>
Loads order book delta messages from a DBN MBO schema file.
Cannot include trades.
§Errors
Returns an error if loading order book deltas fails.
Sourcepub fn read_order_book_deltas(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<impl Iterator<Item = Result<OrderBookDelta>> + '_>
pub fn read_order_book_deltas( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<impl Iterator<Item = Result<OrderBookDelta>> + '_>
Reads order book delta messages from a DBN MBO schema file without collecting them.
Cannot include trades.
§Errors
Returns an error if opening or decoding order book deltas fails.
Sourcepub fn load_order_book_depth10(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<OrderBookDepth10>>
pub fn load_order_book_depth10( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<OrderBookDepth10>>
Loads order book depth10 snapshots from a DBN MBP-10 schema file.
§Errors
Returns an error if loading order book depth10 fails.
Sourcepub fn load_quotes(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<QuoteTick>>
pub fn load_quotes( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<QuoteTick>>
Loads quote tick messages from a DBN MBP-1 or TBBO schema file.
§Errors
Returns an error if loading quotes fails.
Sourcepub fn load_bbo_quotes(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<QuoteTick>>
pub fn load_bbo_quotes( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<QuoteTick>>
Loads best bid/offer quote messages from a DBN BBO schema file.
§Errors
Returns an error if loading BBO quotes fails.
Sourcepub fn load_cmbp_quotes(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<QuoteTick>>
pub fn load_cmbp_quotes( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<QuoteTick>>
Loads consolidated MBP-1 quote messages from a DBN CMBP-1 schema file.
§Errors
Returns an error if loading consolidated MBP-1 quotes fails.
Sourcepub fn load_cbbo_quotes(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<QuoteTick>>
pub fn load_cbbo_quotes( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<QuoteTick>>
Loads consolidated best bid/offer quote messages from a DBN CBBO schema file.
§Errors
Returns an error if loading consolidated BBO quotes fails.
Sourcepub fn load_tbbo_trades(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<TradeTick>>
pub fn load_tbbo_trades( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<TradeTick>>
Loads trade messages from a DBN TBBO schema file.
§Errors
Returns an error if loading TBBO trades fails.
Sourcepub fn load_tcbbo_trades(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<TradeTick>>
pub fn load_tcbbo_trades( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<TradeTick>>
Loads trade messages from a DBN TCBBO schema file.
§Errors
Returns an error if loading TCBBO trades fails.
Sourcepub fn load_trades(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<Vec<TradeTick>>
pub fn load_trades( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<Vec<TradeTick>>
Loads trade messages from a DBN TRADES schema file.
§Errors
Returns an error if loading trades fails.
Sourcepub fn load_bars(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
timestamp_on_close: Option<bool>,
) -> Result<Vec<Bar>>
pub fn load_bars( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, timestamp_on_close: Option<bool>, ) -> Result<Vec<Bar>>
Loads OHLCV bar messages from a DBN OHLCV schema file.
§Errors
Returns an error if loading bars fails.
Sourcepub fn load_status_records<T>(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
) -> Result<impl Iterator<Item = Result<InstrumentStatus>> + '_>
pub fn load_status_records<T>( &self, filepath: &Path, instrument_id: Option<InstrumentId>, ) -> Result<impl Iterator<Item = Result<InstrumentStatus>> + '_>
Loads instrument status messages from a DBN STATUS schema file.
§Errors
Returns an error if loading status records fails.
Sourcepub fn read_imbalance_records<T>(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<impl Iterator<Item = Result<DatabentoImbalance>> + '_>
pub fn read_imbalance_records<T>( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<impl Iterator<Item = Result<DatabentoImbalance>> + '_>
Reads imbalance messages from a DBN IMBALANCE schema file.
§Errors
Returns an error if reading imbalance records fails.
Sourcepub fn read_statistics_records<T>(
&self,
filepath: &Path,
instrument_id: Option<InstrumentId>,
price_precision: Option<u8>,
) -> Result<impl Iterator<Item = Result<DatabentoStatistics>> + '_>
pub fn read_statistics_records<T>( &self, filepath: &Path, instrument_id: Option<InstrumentId>, price_precision: Option<u8>, ) -> Result<impl Iterator<Item = Result<DatabentoStatistics>> + '_>
Reads statistics messages from a DBN STATISTICS schema file.
§Errors
Returns an error if reading statistics records fails.