How to get started

  1. Fork the Github repo

  1. read the
  2. set up your dev environment
    1. create a new environment: python3.9 -m venv venv
    2. activate the environment: source venv/bin/activate
    3. install the required dependencies: pip install -r requirements.txt
    4. run the initial setup: bash
  3. checkout the sim_eval.ipynb notebook

Simulation Components

There are three main components in the simulation framework:

Simulation Components: State

The state of the simulation is described in two places:

For example, below is the market object which includes multiple variables

class Market: 
    amm: AMM 
    market_index: int = 0
    base_asset_amount_long: int = 0
    base_asset_amount_short: int = 0 

    base_asset_amount: int = 0
    total_base_asset_amount: int = 0

    open_interest: int = 0
    total_exchange_fees: int = 0 
    total_mm_fees: int = 0 

    margin_ratio_initial: int = 1000
    margin_ratio_maintenance: int = 625 
    margin_ratio_partial: int = 500

At each timestep of the simulation, the full state can also be serialized for post-simulation analysis. The code below shows how a list of clearing houses (simulation_results['clearing_houses']) is serialized into a pandas dataframe.

# serialize the clearing house state to a df 
result_df = pd.DataFrame([clearing_house.to_json()])