-
bourse.step_sim.run(env: StepEnv | StepEnvNumpy, agents: Iterable, n_steps: int, seed: int, show_progress: bool =
True
, use_numpy: bool =False
) dict[str, ndarray] Run a discrete event simulation for fixed number of steps
Runs a discrete event simulation. Each step of the simulation agents submit transactions to the simulation environment. At the end of the transactions are randomly shuffled and process, updating the state of the market.
Examples
market_data = bourse.step_sim.run( env, # Simulation environment agents, # List of agents 50, # Number of steps 101 # Random seed )
- Parameters:¶
- env: StepEnv | StepEnvNumpy¶
Step updating simulation environment
- agents: Iterable¶
Iterable containing initialised agents. Agents should have an
update
method that interacts with the simulation environment, or ifuse_numpy
isTrue
then agents should return a tuple of Numpy array instructions. Seebourse.step_sim.agents.base_agent.BaseAgent
andbourse.step_sim.agents.base_agent.BaseNumpyAgent
for more details.- n_steps: int¶
Number of simulation steps to run.
- seed: int¶
Random seed.
- show_progress: bool =
True
¶ If
True
a progress bar will be displayed, defaultTrue
- use_numpy: bool =
False
¶ If
True
use numpy api to for market state and to submit market instructions. DefaultFalse
- Returns:¶
dict
– Dictionary containing level 2 market data with keys:bid_price
: Bid price at each stepask_price
: Ask price at each stepbid_vol
: Total bid volume at each stepask_vol
: Total ask volume at each steptrade_vol
: Trade volume each stepbid_vol_<N>
: Bid volume at top 10 levels at each stepask_vol_<N>
: Ask volume at top 10 levels at each stepn_bid_<N>
: Number of bid orders at top 10 levels at each stepn_ask_<N>
: Number of ask orders at top 10 levels at each step