pub struct BacktestClient { /* private fields */ }Expand description
Client for the server’s HTTP endpoints, authenticated with an API key.
Build with BacktestClient::builder; only url is required. The API key, when set, goes
out as the X-API-Key header on every request.
Drive sessions through crate::ManagedBacktestSession, or
crate::managed::ManagedParallelSession for a parallel run.
§HTTP errors
The methods that call the server’s HTTP endpoints fail with:
BacktestClientError::HttpStatuswhen the server answers with a non-2xx status. 401 or 403 means it rejected the API key.BacktestClientError::Httpwhen the request fails or the body does not decode.
Implementations§
Source§impl BacktestClient
impl BacktestClient
Sourcepub fn builder() -> BacktestClientBuilder
pub fn builder() -> BacktestClientBuilder
Create an instance of BacktestClient using the builder syntax
Source§impl BacktestClient
impl BacktestClient
Sourcepub async fn available_ranges(
&self,
) -> BacktestClientResult<Vec<AvailableRange>>
pub async fn available_ranges( &self, ) -> BacktestClientResult<Vec<AvailableRange>>
Fetch the slot ranges that can be run, from the server’s
/available-ranges endpoint. Narrow the list with crate::filter_ranges.
The list is sorted by bundle_start_slot, oldest first. Take the newest with
ranges.iter().max_by_key(|r| r.bundle_start_slot).
§Errors
See HTTP errors.
Sourcepub async fn available_ranges_with_account_state(
&self,
) -> BacktestClientResult<Vec<AvailableRange>>
pub async fn available_ranges_with_account_state( &self, ) -> BacktestClientResult<Vec<AvailableRange>>
Like Self::available_ranges, plus the caller’s own ranges available
to replay recorded account state. The two are not interchangeable, so
callers planning a run ask for the smaller list.
§Errors
Sourcepub async fn usage(
&self,
since: Option<DateTime<Utc>>,
until: Option<DateTime<Utc>>,
) -> BacktestClientResult<UsageReport>
pub async fn usage( &self, since: Option<DateTime<Utc>>, until: Option<DateTime<Utc>>, ) -> BacktestClientResult<UsageReport>
Fetch per-API-key usage metrics from the server’s /usage endpoint.
since and until set the reporting window; both default to the
server’s configured window when omitted. The report is bucketed by UTC
day, so the window served — and the totals over it — starts at the
midnight at or before since.
§Errors
See HTTP errors.
Sourcepub async fn usage_sessions(
&self,
since: Option<DateTime<Utc>>,
until: Option<DateTime<Utc>>,
) -> BacktestClientResult<Vec<SessionUsage>>
pub async fn usage_sessions( &self, since: Option<DateTime<Utc>>, until: Option<DateTime<Utc>>, ) -> BacktestClientResult<Vec<SessionUsage>>
Every session that ended in the window (GET /usage/sessions).
since and until set the window as Self::usage does. Reads every
page. Completeness is the guarantee, not order: sort by ended_at for
chronological.
§Errors
See HTTP errors.
Sourcepub async fn get_latest_snapshot_slot(
&self,
) -> BacktestClientResult<SnapshotSlotResponse>
pub async fn get_latest_snapshot_slot( &self, ) -> BacktestClientResult<SnapshotSlotResponse>
Sourcepub async fn build_bundle(
&self,
request: &BundleBuildRequest,
) -> BacktestClientResult<BundleBuildStatusResponse>
pub async fn build_bundle( &self, request: &BundleBuildRequest, ) -> BacktestClientResult<BundleBuildStatusResponse>
Issue a bundle build (POST /build-bundle); the build runs async, so
poll Self::get_bundle_status for completion.
§Errors
See HTTP errors.
Sourcepub async fn delete_bundle(
&self,
request: &BundleDeleteRequest,
) -> BacktestClientResult<BundleDeleteResponse>
pub async fn delete_bundle( &self, request: &BundleDeleteRequest, ) -> BacktestClientResult<BundleDeleteResponse>
Delete one of this key’s own bundles (DELETE /bundles), by kind and
exact range. A range this key does not own reads as not found.
§Errors
See HTTP errors.
Sourcepub async fn list_bundle_builds(
&self,
limit: Option<u32>,
) -> BacktestClientResult<BundleBuildListResponse>
pub async fn list_bundle_builds( &self, limit: Option<u32>, ) -> BacktestClientResult<BundleBuildListResponse>
List this key’s own bundle builds, newest first, together with the
bundles it owns (GET /build-bundle). Recovers the job ID (request_id) of a
build whose submit response was lost.
§Errors
See HTTP errors.
Sourcepub async fn get_bundle_status(
&self,
request_id: &str,
) -> BacktestClientResult<BundleBuildStatusResponse>
pub async fn get_bundle_status( &self, request_id: &str, ) -> BacktestClientResult<BundleBuildStatusResponse>
Sourcepub async fn depth_universe(
&self,
) -> BacktestClientResult<DepthUniverseResponse>
pub async fn depth_universe( &self, ) -> BacktestClientResult<DepthUniverseResponse>
Sourcepub async fn dataset_credentials(
&self,
) -> BacktestClientResult<DatasetCredentialsResponse>
pub async fn dataset_credentials( &self, ) -> BacktestClientResult<DatasetCredentialsResponse>
Temporary, read-only S3 credentials for the shared datasets and this
key’s own (POST /datasets/credentials).
§Errors
See HTTP errors.
Sourcepub async fn list_datasets(
&self,
query: &DatasetListQuery,
) -> BacktestClientResult<DatasetListResponse>
pub async fn list_datasets( &self, query: &DatasetListQuery, ) -> BacktestClientResult<DatasetListResponse>
This key’s own datasets, plus the shared one of a named dataset.
Sourcepub async fn delete_dataset_range(
&self,
request: &DatasetDeleteRequest,
) -> BacktestClientResult<DatasetDeleteResponse>
pub async fn delete_dataset_range( &self, request: &DatasetDeleteRequest, ) -> BacktestClientResult<DatasetDeleteResponse>
Remove a slot range of this key’s own dataset; refused while one of its jobs replays any of it.
Sourcepub async fn create_dataset_job(
&self,
request: &DatasetJobRequest,
) -> BacktestClientResult<DatasetJobStatusResponse>
pub async fn create_dataset_job( &self, request: &DatasetJobRequest, ) -> BacktestClientResult<DatasetJobStatusResponse>
Start a dataset job; resubmitting the same request returns the same job.
Sourcepub async fn list_dataset_jobs(
&self,
) -> BacktestClientResult<DatasetJobListResponse>
pub async fn list_dataset_jobs( &self, ) -> BacktestClientResult<DatasetJobListResponse>
This key’s dataset jobs, newest first.
Sourcepub async fn get_dataset_job(
&self,
job_id: &str,
) -> BacktestClientResult<DatasetJobStatusResponse>
pub async fn get_dataset_job( &self, job_id: &str, ) -> BacktestClientResult<DatasetJobStatusResponse>
A dataset job of this key.
Sourcepub async fn cancel_dataset_job(
&self,
job_id: &str,
) -> BacktestClientResult<DatasetJobStatusResponse>
pub async fn cancel_dataset_job( &self, job_id: &str, ) -> BacktestClientResult<DatasetJobStatusResponse>
Cancel a dataset job; rows it already wrote stay, and an ended job is returned unchanged.
Trait Implementations§
Source§impl Clone for BacktestClient
impl Clone for BacktestClient
Auto Trait Implementations§
impl !Freeze for BacktestClient
impl !RefUnwindSafe for BacktestClient
impl !UnwindSafe for BacktestClient
impl Forget for BacktestClient
impl Move for BacktestClient
impl Send for BacktestClient
impl Sync for BacktestClient
impl Unpin for BacktestClient
impl UnsafeUnpin for BacktestClientwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static str: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
*const ArcInner<ClientRef> is !null: UnsafeUnpin,
PhantomData<ArcInner<ClientRef>>: UnsafeUnpin,
PhantomData<Client>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.