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 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 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
Source§fn clone(&self) -> BacktestClient
fn clone(&self) -> BacktestClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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> 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::Request