pub struct TradingEnvironment<'runtime> { /* private fields */ }Expand description
Device-resident trading dynamics over one Runtime and the canonical lifecycle. Observations append signed exposure, equity/capital, peak/capital, drawdown, remaining horizon, unrealized PnL/capital, position age/horizon and peak unrealized position PnL/capital.
Implementations§
Source§impl TradingEnvironment<'_>
impl TradingEnvironment<'_>
Sourcepub fn snapshot(&self) -> Result<TradingState>
pub fn snapshot(&self) -> Result<TradingState>
Explicitly synchronize and read a portable exact environment snapshot.
§Errors
Requires healthy initialized state and no open environment transaction.
Source§impl<'runtime> TradingEnvironment<'runtime>
impl<'runtime> TradingEnvironment<'runtime>
Sourcepub fn set_taker_fee(&mut self, taker_fee: f32) -> Result<()>
pub fn set_taker_fee(&mut self, taker_fee: f32) -> Result<()>
Change the actual-notional fee between episodes without resetting lane state.
Existing captured programs retain their recorded fee; discard and recapture
the TradingRolloutProgram before collecting with the new configuration.
Snapshots remain bound to the fee in effect when they were taken.
§Errors
Rejects invalid fees, active execution, unhealthy state, or any initialized lane which has advanced beyond reset or retains inventory/pending execution.
Sourcepub fn new(
runtime: &'runtime Runtime,
config: TradingConfig,
series: &[TradingSeries],
) -> Result<Self>
pub fn new( runtime: &'runtime Runtime, config: TradingConfig, series: &[TradingSeries], ) -> Result<Self>
Validate/upload immutable data and allocate analytical lane state.
Call reset, then submit/wait explicitly before observing it.
§Errors
Rejects discontinuous or invalid data, insufficient episode coverage, overflowing extents, unsupported policy, allocation or recording failure.
Sourcepub fn new_with_row_capacity(
runtime: &'runtime Runtime,
config: TradingConfig,
series: &[TradingSeries],
capacity: usize,
) -> Result<Self>
pub fn new_with_row_capacity( runtime: &'runtime Runtime, config: TradingConfig, series: &[TradingSeries], capacity: usize, ) -> Result<Self>
Allocate stable table capacity for replay across changing contiguous segments. Padding is unreachable: bounds always describe only supplied source rows.
§Errors
Returns the validation errors of new or an excessive capacity error.
Sourcepub fn replace_series(&mut self, series: &[TradingSeries]) -> Result<()>
pub fn replace_series(&mut self, series: &[TradingSeries]) -> Result<()>
Replace resident source tables without replacing captured storage. Call at a completed rollout boundary; lane state must be reset afterwards.
§Errors
Rejects invalid/discontinuous source data, changed feature width/capacity, active environment execution, or upload/completion failure.
Sourcepub fn step_terminal(
&mut self,
action: &Matrix,
) -> Result<EnvironmentTransition>
pub fn step_terminal( &mut self, action: &Matrix, ) -> Result<EnvironmentTransition>
Step and close all lanes at this collection boundary, charging exit costs in this transition. This is a task terminal, never a free reset.
§Errors
Returns the normal Environment step validation/recording failures.
Sourcepub const fn ledger(&self) -> &Matrix
pub const fn ledger(&self) -> &Matrix
Analytical rows: equity, quantity, mark, peak, fees, funding, slippage, fill count, maximum drawdown, entry price, age in source steps and peak unrealized position PnL. Peak is zero while flat or never profitable. These are never exact money values.
Sourcepub const fn metadata(&self) -> &Matrix
pub const fn metadata(&self) -> &Matrix
Cursor, episode steps, episode ordinal, failure status (zero means healthy).
Sourcepub fn check_status(&self) -> Result<()>
pub fn check_status(&self) -> Result<()>
Explicitly observe status after exact completion and reject any failed lane. No action/price readback occurs during device rollout steps.
§Errors
Returns readback/completion failure or a poisoned numerical/action lane.
Trait Implementations§
Source§impl Environment for TradingEnvironment<'_>
impl Environment for TradingEnvironment<'_>
Source§fn spec(&self) -> &EnvironmentSpec
fn spec(&self) -> &EnvironmentSpec
Source§fn environments(&self) -> u32
fn environments(&self) -> u32
Source§fn observation(&self) -> &Matrix
fn observation(&self) -> &Matrix
Source§fn execution(&self) -> &EnvironmentExecution
fn execution(&self) -> &EnvironmentExecution
Source§fn execution_mut(&mut self) -> &mut EnvironmentExecution
fn execution_mut(&mut self) -> &mut EnvironmentExecution
Source§fn record_reset(&mut self, seed: u64) -> Result<()>
fn record_reset(&mut self, seed: u64) -> Result<()>
Source§fn record_reset_completed(&mut self) -> Result<()>
fn record_reset_completed(&mut self) -> Result<()>
Source§fn commit_recorded_state(&mut self)
fn commit_recorded_state(&mut self)
Source§fn rollback_recorded_state(&mut self)
fn rollback_recorded_state(&mut self)
Source§fn record_step(&mut self, action: &Matrix) -> Result<EnvironmentTransition>
fn record_step(&mut self, action: &Matrix) -> Result<EnvironmentTransition>
Source§fn holds_committed_state(&self) -> bool
fn holds_committed_state(&self) -> bool
Source§fn begin(&mut self) -> Result<()>
fn begin(&mut self) -> Result<()>
Source§fn reset(&mut self, seed: u64) -> Result<()>
fn reset(&mut self, seed: u64) -> Result<()>
Source§fn step(&mut self, action: &Matrix) -> Result<EnvironmentTransition>
fn step(&mut self, action: &Matrix) -> Result<EnvironmentTransition>
Source§fn reset_completed(&mut self) -> Result<()>
fn reset_completed(&mut self) -> Result<()>
Source§fn submit(&mut self) -> Result<Event>
fn submit(&mut self) -> Result<Event>
Source§fn submit_timed(&mut self) -> Result<Event>
fn submit_timed(&mut self) -> Result<Event>
wait still releases this environment’s pending lifecycle state. Read more