pub struct TradingEnv { /* private fields */ }Expand description
Implementations§
Source§impl TradingEnv
impl TradingEnv
Sourcepub fn new(data: Dataset, window: Window, costs: CostModel, seed: u64) -> Self
pub fn new(data: Dataset, window: Window, costs: CostModel, seed: u64) -> Self
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).