Getting Started
You can watch a video tutorial if you prefer a visual guide on how to create a project and start writing your first automation.
Otherwise, follow the steps below to get started with ZapCLI.
-
Install the CLI
Start by installing the CLI globally using your preferred package manager.
-
Create a project
Generate a new project using zapcli. This action will set up a sample project and install all necessary dependencies.
After running the command, you will see a new directory named
MyProject
with the following structure:Directorydata/
- …
Directoryreport/
- data.json
- report.html
Directorysrc/
- hello.zp
- hello.js
- package.json
- zp.config.js
Open your project in VSCode or any other editor.
-
Run automation
ZapCLI can execute an automation once on a specific day and showcase the orders in the terminal or store them in a file (e.g.,
orders.json
). To run an automation just open it in VSCode (src/hello.zp
) and pressCtrl+Shift+B
. Or you can use the terminal: -
Run your first backtest
This command will execute
hello.zp
for a duration of 20 days. It will display the result in the terminal and save the backtest data inbacktests/data.json
. You can change the directory where the backtest data is saved by changing thebacktestsDir
property in thezp.config.js
file. -
Generate a report
This command will generate a visual report file
reports/report.html
based on the backtest data saved inbacktests/
directory. You can generate multiple reports by providing thename
parameter. -
Write your own automation
To write your own strategy you need to create an automation file that will be run on every bar. Currently we have been using the
hello.(zp|js)
fileTo see more automation examples check out the Examples page.
-
Configuration
ZapCLI is using a configuration file to run a backtest or execute an automation file. Your project started with the default config file:
As you can see here you can configure your backtest with a start, end date or add analyzers to run with your backtest. To learn more about Analyzers and Data Providers please read the documentaion.