pub struct TradingEnv { /* private fields */ }Expand description
Implementations§
Source§impl TradingEnv
impl TradingEnv
Sourcepub fn new(
data: Dataset,
window: Window,
costs: CostModel,
seed: u64,
) -> TradingEnv
pub fn new( data: Dataset, window: Window, costs: CostModel, seed: u64, ) -> TradingEnv
Build an environment that steps window over data with seeded execution
noise and the given cost model.
Sourcepub fn reset(&mut self) -> MarketObservation
pub fn reset(&mut self) -> MarketObservation
Reset to the start of the window and return the first point-in-time observation. Re-seeds the book, so it is safe to call repeatedly.
Sourcepub fn step(&mut self, decision: Decision) -> StepResult
pub fn step(&mut self, decision: Decision) -> StepResult
Apply decision at the current bar and advance one step. The returned
reward is the bar’s portfolio return; done is set once the window is
exhausted (further calls re-apply the final bar harmlessly).
Sourcepub fn clone_state(&self) -> EnvState
pub fn clone_state(&self) -> EnvState
Snapshot the mutable sim state (time cursor + book) in O(1) — no replay.
The returned EnvState is a value: clone it, stash it, restore it later
with restore_state to fork the env from this exact
point (e.g. tree search / what-if rollouts over the same frozen data). The
immutable config (data, window, costs, seed) is not snapshotted — it never
changes — so a snapshot is cheap and a restore is exact.
Sourcepub fn restore_state(&mut self, state: EnvState)
pub fn restore_state(&mut self, state: EnvState)
Restore a snapshot taken by clone_state: the env
resumes producing the exact byte-identical trajectory it would have from the
snapshot point, including seeded execution noise (the RNG cursor is part of
the snapshot).
Auto Trait Implementations§
impl Freeze for TradingEnv
impl RefUnwindSafe for TradingEnv
impl Send for TradingEnv
impl Sync for TradingEnv
impl Unpin for TradingEnv
impl UnsafeUnpin for TradingEnv
impl UnwindSafe for TradingEnv
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
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