Building Trading Strategies Backtesting

Backtesting

Backtesting on the Deno Runtime

Botmain allows you to backtest and forward-test your strategy on historical and live-streaming data. Your strategy code executes in the Deno Runtime, a next-generation Javascript runtime that is secure by default and runs Typescript natively. A strategy run with Deno has no file, network, or environment access unless explicitly enabled. This is a major difference from NodeJS, where dependencies are automatically granting full access to everything, introducing hidden vulnerabilities in your project.

Botmain strategies run in a sandbox with no I/O access by default, allowing you to safely use thousands of modules from the NodeJS ecosystem without worrying about malicious code accessing your filesystem. External modules are categorically unable to access your secret keys, which are kept encrypted on your computer and nowhere else.

Running a backtest

  1. Select your module folder:
    • Click the "Select a module" button and select the folder containing your strategy classes

Botmain will load up your classes and you will see them in the dropdown

  1. Open Run Settings:
    • Click the "Run Settings" button to open the run settings modal where you can specify various parameters for your strategy run.
  1. Set general run parameters
    • Select your strategy class, date range for the backtest, and initial run speed. (You can adjust the run speed while the strategy is running.)
  1. Set markets to trade and accounts to trade with

    • Each market can trade on a different account. For simulation accounts, this is normally not needed since you can use the same simulator account across all exchanges. In that case, we just use the same account for both markets:

    • This example assumes a funded simulator account. To fund your simulator account see Accounts

  1. Set Module Inputs

    • Botmain identifies any @Parameter() decorated properties on your strategy class and allows you to provide values for them through the GUI. This includes @Parameter() decorated properties on all @Inject() decorated Indicators recurisvely.

    • See Parameters for more information

  1. Run your backtest and monitor your portfolio analytics in real-time