Skip to main content

CoinApiDataLoader

Struct CoinApiDataLoader 

Source
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

Source

pub fn new(api_key: Option<SecretString>) -> Self

Creates an empty loader without resolving credentials or sending requests.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for CoinApiDataLoader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more