pub struct CoinApiDataLoader { /* private fields */ }Expand description
Loads Nautilus data using retained instruments and CoinAPI symbol mappings.
Local file operations require no credentials. The first network request resolves credentials and creates a shared HTTP client with the configured credit allowance. Register definitions for file loading, or request instrument selections before REST market-data requests. Tick and book values must fit the registered instrument precision without rounding. Consolidated bar volumes retain observed precision after bounded export normalization. REST history rejects truncated responses and invalid records rather than returning a partial result. Flat Files downloads require credentials but no instrument definitions.
Implementations§
Source§impl CoinApiDataLoader
impl CoinApiDataLoader
Sourcepub fn new(api_key: Option<SecretString>) -> Self
pub fn new(api_key: Option<SecretString>) -> Self
Creates an empty loader without resolving credentials or sending requests.
Sourcepub fn with_http_config(
api_key: Option<SecretString>,
http_config: CoinApiHttpConfig,
) -> Self
pub fn with_http_config( api_key: Option<SecretString>, http_config: CoinApiHttpConfig, ) -> Self
Creates a loader with explicit HTTP controls, without resolving credentials or sending requests.
Sourcepub fn add_instrument(
&self,
instrument: InstrumentAny,
symbol_id: Option<Ustr>,
symbol_id_int: Option<u64>,
) -> Result<()>
pub fn add_instrument( &self, instrument: InstrumentAny, symbol_id: Option<Ustr>, symbol_id_int: Option<u64>, ) -> Result<()>
Registers a definition and optional REST and consolidated-file symbol IDs.
Updating an existing instrument replaces its provider mappings as well as its definition.
§Errors
Returns an error if a symbol ID is empty or belongs to another registered instrument.
Sourcepub fn instrument(&self, instrument_id: InstrumentId) -> Result<InstrumentAny>
pub fn instrument(&self, instrument_id: InstrumentId) -> Result<InstrumentAny>
Returns a retained definition.
§Errors
Returns an error if the definition has not been loaded or registered.
Sourcepub async fn request_instruments(
&self,
instruments: &[CoinApiInstrumentSelection],
price_precisions: &HashMap<InstrumentId, u8>,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments( &self, instruments: &[CoinApiInstrumentSelection], price_precisions: &HashMap<InstrumentId, u8>, ) -> Result<Vec<InstrumentAny>>
Fetches the supplied selections and retains their metadata atomically.
§Errors
Returns an error if selections are invalid, a selected definition is unavailable, or retrieval or mapping validation fails. Failures preserve the existing registry.
Sourcepub async fn download_flat_file(
&self,
bucket: &str,
object_key: &str,
filepath: impl AsRef<Path>,
) -> Result<()>
pub async fn download_flat_file( &self, bucket: &str, object_key: &str, filepath: impl AsRef<Path>, ) -> Result<()>
Downloads one Flat Files object to disk using this loader’s credentials and HTTP controls.
Instrument definitions are not required. Existing files are replaced only after a complete download; callers can check for a cached file before invoking this method. Flat Files usage is billed separately and does not consume the local REST credit allowance.
§Errors
Returns an error if credentials are unavailable, a selector is invalid, the download fails, or a file operation fails.
Sourcepub fn load_book_deltas(
&self,
path: impl AsRef<Path>,
instrument_id: InstrumentId,
date: Option<Date>,
limit: Option<usize>,
) -> Result<Vec<OrderBookDelta>>
pub fn load_book_deltas( &self, path: impl AsRef<Path>, instrument_id: InstrumentId, date: Option<Date>, limit: Option<usize>, ) -> Result<Vec<OrderBookDelta>>
Loads deltas from a local file using the retained instrument precision.
Supply date or use a path with a D- partition.
§Errors
Returns an error if metadata or the date is missing, the file cannot be read, or a value cannot be converted exactly.
Sourcepub fn stream_book_deltas<P: AsRef<Path>>(
&self,
path: P,
instrument_id: InstrumentId,
date: Option<Date>,
chunk_size: usize,
limit: Option<usize>,
) -> Result<impl Iterator<Item = Result<Vec<OrderBookDelta>>> + use<P>>
pub fn stream_book_deltas<P: AsRef<Path>>( &self, path: P, instrument_id: InstrumentId, date: Option<Date>, chunk_size: usize, limit: Option<usize>, ) -> Result<impl Iterator<Item = Result<Vec<OrderBookDelta>>> + use<P>>
Streams deltas from a local file using the retained instrument precision.
Supply date or use a path with a D- partition. Chunks end at event boundaries and can
exceed chunk_size, which must be in [1, 1_000_000].
§Errors
Returns an error if metadata, date, file access, or chunk bounds are invalid. Iteration fails if any file value cannot be converted exactly. Stream state belongs to the iterator.
Sourcepub fn load_quotes(
&self,
path: impl AsRef<Path>,
instrument_id: InstrumentId,
limit: Option<usize>,
) -> Result<Vec<QuoteTick>>
pub fn load_quotes( &self, path: impl AsRef<Path>, instrument_id: InstrumentId, limit: Option<usize>, ) -> Result<Vec<QuoteTick>>
Loads quotes from a local file using the retained instrument precision.
§Errors
Returns an error if metadata is missing or any file value cannot be converted exactly.
Sourcepub fn stream_quotes<P: AsRef<Path>>(
&self,
path: P,
instrument_id: InstrumentId,
chunk_size: usize,
limit: Option<usize>,
) -> Result<impl Iterator<Item = Result<Vec<QuoteTick>>> + use<P>>
pub fn stream_quotes<P: AsRef<Path>>( &self, path: P, instrument_id: InstrumentId, chunk_size: usize, limit: Option<usize>, ) -> Result<impl Iterator<Item = Result<Vec<QuoteTick>>> + use<P>>
Streams quotes from a local file using the retained instrument precision.
§Errors
Returns an error if metadata, file access, or chunk bounds are invalid. Iteration fails if any file value cannot be converted exactly. Stream state belongs to the iterator.
Sourcepub fn load_trades(
&self,
path: impl AsRef<Path>,
instrument_id: InstrumentId,
limit: Option<usize>,
) -> Result<Vec<TradeTick>>
pub fn load_trades( &self, path: impl AsRef<Path>, instrument_id: InstrumentId, limit: Option<usize>, ) -> Result<Vec<TradeTick>>
Loads trades from a local file using the retained instrument precision.
§Errors
Returns an error if metadata is missing or any file value cannot be converted exactly.
Sourcepub fn stream_trades<P: AsRef<Path>>(
&self,
path: P,
instrument_id: InstrumentId,
chunk_size: usize,
limit: Option<usize>,
) -> Result<impl Iterator<Item = Result<Vec<TradeTick>>> + use<P>>
pub fn stream_trades<P: AsRef<Path>>( &self, path: P, instrument_id: InstrumentId, chunk_size: usize, limit: Option<usize>, ) -> Result<impl Iterator<Item = Result<Vec<TradeTick>>> + use<P>>
Streams trades from a local file using the retained instrument precision.
§Errors
Returns an error if metadata, file access, or chunk bounds are invalid. Iteration fails if any file value cannot be converted exactly. Stream state belongs to the iterator.
Sourcepub fn load_bars(
&self,
path: impl AsRef<Path>,
period_id: Option<&str>,
limit: Option<usize>,
) -> Result<Vec<Bar>>
pub fn load_bars( &self, path: impl AsRef<Path>, period_id: Option<&str>, limit: Option<usize>, ) -> Result<Vec<Bar>>
Loads consolidated OHLCV bars for registered numeric symbol IDs.
Reads the period from period_id or the TP- file name. Rows for unmapped symbols are skipped.
§Errors
Returns an error if no numeric mappings exist, the file is invalid, or values exceed their registered price precision. Volumes may be finer than the trading lot increment.
Sourcepub async fn request_book_snapshot(
&self,
instrument_id: InstrumentId,
depth: Option<u32>,
) -> Result<OrderBook>
pub async fn request_book_snapshot( &self, instrument_id: InstrumentId, depth: Option<u32>, ) -> Result<OrderBook>
Retrieves and converts a current L2 book for a registered REST symbol.
§Errors
Returns an error if metadata is missing or retrieval or conversion fails.
Sourcepub async fn request_quotes(
&self,
instrument_id: InstrumentId,
start: UnixNanos,
end: UnixNanos,
limit: Option<NonZeroUsize>,
) -> Result<Vec<QuoteTick>>
pub async fn request_quotes( &self, instrument_id: InstrumentId, start: UnixNanos, end: UnixNanos, limit: Option<NonZeroUsize>, ) -> Result<Vec<QuoteTick>>
Retrieves historical quotes using retained metadata, rejecting partial results.
The requested window is [start, end).
§Errors
Returns an error if metadata or bounds are invalid, credits truncate retrieval, or any request or record conversion fails.
Sourcepub async fn request_trades(
&self,
instrument_id: InstrumentId,
start: UnixNanos,
end: UnixNanos,
limit: Option<NonZeroUsize>,
) -> Result<Vec<TradeTick>>
pub async fn request_trades( &self, instrument_id: InstrumentId, start: UnixNanos, end: UnixNanos, limit: Option<NonZeroUsize>, ) -> Result<Vec<TradeTick>>
Retrieves historical trades using retained metadata, rejecting partial results.
The requested window is [start, end).
§Errors
Returns an error if metadata or bounds are invalid, credits truncate retrieval, or any request or record conversion fails.
Sourcepub async fn request_bars(
&self,
bar_type: BarType,
start: UnixNanos,
end: UnixNanos,
limit: Option<NonZeroUsize>,
) -> Result<Vec<Bar>>
pub async fn request_bars( &self, bar_type: BarType, start: UnixNanos, end: UnixNanos, limit: Option<NonZeroUsize>, ) -> Result<Vec<Bar>>
Retrieves historical bars using retained metadata, rejecting partial results.
The requested window is [start, end). Bars must close within the window and by now.
§Errors
Returns an error if metadata or bounds are invalid, credits truncate retrieval, or any request or record conversion fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CoinApiDataLoader
impl !RefUnwindSafe for CoinApiDataLoader
impl !UnwindSafe for CoinApiDataLoader
impl Send for CoinApiDataLoader
impl Sync for CoinApiDataLoader
impl Unpin for CoinApiDataLoader
impl UnsafeUnpin for CoinApiDataLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more