pub struct BacktestClient { /* private fields */ }Expand description
Backtest WebSocket client configured with a base URL and API key.
Build with BacktestClient::builder, which supports optional timeouts and
raw message logging.
This is the low-level layer: every session it opens is one raw WebSocket
with no reconnect and no reattach, so a dropped connection ends the run
unless the caller reattaches with BacktestClient::attach_session. Most
callers want crate::ManagedBacktestSession, which does that for them —
see the crate docs on session handoff.
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 create_session(
&self,
create: CreateSession,
) -> BacktestClientResult<BacktestSession>
pub async fn create_session( &self, create: CreateSession, ) -> BacktestClientResult<BacktestSession>
Create a backtest session by connecting and sending a CreateBacktestSession request.
Sourcepub async fn create_sessions(
&self,
create: CreateSession,
) -> BacktestClientResult<Vec<SessionId>>
pub async fn create_sessions( &self, create: CreateSession, ) -> BacktestClientResult<Vec<SessionId>>
Create one or many sessions and return the resulting session IDs.
When CreateSession.parallel is true, this may return many IDs.
Sourcepub async fn create_sessions_with_progress(
&self,
create: CreateSession,
on_session_created: impl FnMut(SessionId) + Send,
) -> BacktestClientResult<Vec<SessionId>>
pub async fn create_sessions_with_progress( &self, create: CreateSession, on_session_created: impl FnMut(SessionId) + Send, ) -> BacktestClientResult<Vec<SessionId>>
Create one or many sessions and stream each successfully created session ID.
on_session_created is called for each streamed SessionCreated response.
Sourcepub async fn create_sessions_with_task_ids(
&self,
create: CreateSession,
) -> BacktestClientResult<Vec<(SessionId, Option<String>)>>
pub async fn create_sessions_with_task_ids( &self, create: CreateSession, ) -> BacktestClientResult<Vec<(SessionId, Option<String>)>>
Like Self::create_sessions, but additionally returns the opaque
per-session task_id reported by the server (if any).
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.
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.
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.
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.
Sourcepub async fn get_latest_snapshot_slot(
&self,
) -> BacktestClientResult<SnapshotSlotResponse>
pub async fn get_latest_snapshot_slot( &self, ) -> BacktestClientResult<SnapshotSlotResponse>
Most-recent available snapshot slot (GET /snapshot-slot).
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.
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.
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 request_id of a
build whose submit response was lost.
Sourcepub async fn get_bundle_status(
&self,
request_id: &str,
) -> BacktestClientResult<BundleBuildStatusResponse>
pub async fn get_bundle_status( &self, request_id: &str, ) -> BacktestClientResult<BundleBuildStatusResponse>
Fetch a build’s status (GET /build-bundle/{request_id}).
Sourcepub async fn generate_depth(
&self,
request: &DepthRequest,
) -> BacktestClientResult<DepthStatusResponse>
pub async fn generate_depth( &self, request: &DepthRequest, ) -> BacktestClientResult<DepthStatusResponse>
Request a venue-depth dataset for a slot range (POST /generate-depth);
the run is async, so poll Self::get_depth_status for completion.
Sourcepub async fn get_depth_status(
&self,
request_id: &str,
) -> BacktestClientResult<DepthStatusResponse>
pub async fn get_depth_status( &self, request_id: &str, ) -> BacktestClientResult<DepthStatusResponse>
Fetch a depth run’s status (GET /generate-depth/{request_id}).
Sourcepub async fn get_depth_coverage(
&self,
) -> BacktestClientResult<DepthCoverageResponse>
pub async fn get_depth_coverage( &self, ) -> BacktestClientResult<DepthCoverageResponse>
What a depth request would sample (GET /generate-depth/coverage):
the markets, venues and sizes of each arm, and the dates this key has
already published.
Sourcepub async fn attach_session(
&self,
session_id: SessionId,
last_sequence: Option<u64>,
) -> BacktestClientResult<BacktestSession>
pub async fn attach_session( &self, session_id: SessionId, last_sequence: Option<u64>, ) -> BacktestClientResult<BacktestSession>
Attach to an existing backtest session over the control websocket.
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 Send for BacktestClient
impl Sync for BacktestClient
impl Unpin for BacktestClient
impl UnsafeUnpin for BacktestClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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.