Vectorized Environment

VecEnv runs many independent simulation episodes in parallel for reinforcement learning.

Configuration

VecEnvConfig specifies the full environment:

FieldDescription
mu, kappa, theta, sigma_v, rhoHeston parameters
initial_price, initial_varianceStarting conditions
spread, dt, max_stepsSimulation mechanics
impact_factorPrice impact per unit filled
k, aPoisson matcher parameters
hawkes_alpha, hawkes_betaHawkes intensity parameters
initial_cash, transaction_costAgent capital
reward_typePnL or DiffSharpe
inventory_penaltyPenalty for holding non-zero position
matcher_dtSub-step resolution for the stochastic matcher

State space

Each environment step produces a state vector of typically 6-8 elements:

  • Mid-price.
  • Current position (inventory).
  • Time remaining.
  • Spread.
  • Volatility.
  • Intensity (if Hawkes enabled).

Usage

#![allow(unused)]
fn main() {
use engine::vec_env::{VecEnv, VecEnvConfig, RewardType};

let config = VecEnvConfig {
    reward_type: RewardType::DiffSharpe,
    max_steps: 1000,
    ..Default::default()
};

let mut env = VecEnv::new(config, 64); // 64 parallel environments

// Reset to start new episodes.
let states = env.reset();

// Step with actions.
let actions = vec![0.5; 64]; // symmetric spread for all envs
let (next_states, rewards, dones) = env.step(&actions);
}