Backtesting

For backtesting, you do not need(and should not) provide private keys of your agents. When using backtest_run dojo can auto-impersonate any address.

We strongly recommend that you keep your private keys private for backtesting. You do not need them.

Dojo can only backtest environments with backend_type='local' or backend_type='forked'.

You can start the backtest by importing the appropriate runner function from dojo and calling it with the compatible environment.

run.py
backtest_run(
  env,
  dashboard_server_port=dashboard_server_port,
  auto_close=auto_close,
  simulation_status_bar=simulation_status_bar,
  output_file="example_backtest.db",
  simulation_title="Example backtest",
  simulation_description="Example backtest. One LP agent, one trader agent.",
)

Calling backtest_run will.

  • Deploy and instantiate all protocols and agents for the backtest
  • Launch a local instance of anvil
  • Download all relevant market data for the backtest from the server(If you are using one of our market agents.)
  • Create a local database file that all data is written to
  • If so requested, it launches a server that serves the data file over http. Our App can connect to this.
  • Loop through all blocks
  • At each block, it asks all agents to make decisions on what actions they want to execute
  • Executes all actins on anvil
  • Tracked metrics of all agents and protocol and writes them to the database file for analysis