Your first backtest experiment
Can changing a rule change the result? Give QR CLI a small set of past prices and find out. You’ll follow four steps in Ubuntu and read a chart at the end.
Before you start
Use Ubuntu with an installed, activated version of QR CLI that supports --generations. Download the practice files, unzip them and open a terminal in ubuntu2. That folder contains the data folder, the strategy’s .cs file and a matching settings file.
A terminal is a window where you type instructions. Copy one command block at a time and press Enter. Use the same Ubuntu account and workspace for all four steps.
1. Put the practice prices on the shelf
Imagine a box of price cards. Each card records a moment in time. The practice folder holds made-up quotes for a symbol called DEMO. Importing them puts the cards in a catalog so QR CLI can find them again.
qr-cli --import dataLook for importedRows and failedFiles in the final summary. The first tells you how many rows were imported. In a fresh workspace, the two practice files contain 48 rows each. Look for importedRows of 96 and failedFiles of 0.
- Folderdata/
- Compressed price files*.dbn.zst
- Saved seriesDEMO · mbp-1
2. Find DEMO in the catalog
Use the catalog like a set of labeled drawers. Move the highlight with ↑ and ↓. Press Enter or click to open a drawer. Expand down to the symbol, then press q to return to the terminal.
qr-cli dataLook at the --data name at the bottom of the screen. It tells the next command which prices to use. You can also run qr-cli data --json for a plain-text list.
Databento
└─ EQUS.MINI
└─ mbp-1
└─ DEMO3. Let different settings take turns
A strategy is a set of rules. The practice rule buys one unit of DEMO, waits, then sells. Its HoldQuotes setting changes how long it waits, from one to eight quote updates. The C# file contains the rules. The preset lists the settings to try. QR CLI replays the same prices each time and gives each candidate a score.
- --population 4
- Try up to four sets of settings in a round.
- --evaluation 8
- Spend up to eight trials in the whole search.
- --generations 3
- Allow up to three rounds. Later rounds use earlier scores.
Check the plan first
This prints the plan. Check that the symbol is DEMO and the limits match the three numbers below.
qr-cli --optimize --data databento.mbp-1.DEMO \
--optparam DemoLadder.qroptparams --source DemoLadder.cs \
--population 4 --evaluation 8 --generations 3 --previewRun the practice search
Run the command again without --preview to start the trials.
qr-cli --optimize --data databento.mbp-1.DEMO \
--optparam DemoLadder.qroptparams --source DemoLadder.cs \
--population 4 --evaluation 8 --generations 34. Open the result and read the chart
Select the saved Optimize run with ↑ or ↓. Press Enter or click to open its charts. In the table, ← and → show more columns. The Optimize chart follows the best successful candidate.
qr-cli resultsTo keep a report you can open again, use a fresh filename. Over SSH without a graphical screen, the interactive results viewer prints a file path and a command to copy the report to your computer.
qr-cli results --html demo-results.htmlUse your own GOOG data
For a larger run, import your licensed GOOG folder and find the symbol in the catalog. Run the command below from the folder that contains your preset and strategies/FlexMM.cs. These are your own files, separate from the DEMO example.
qr-cli --optimize --data databento.mbp-1.GOOG \
--optparam optimization-parameters_NASDAQ_GOOG.qroptparams \
--source strategies/FlexMM.cs \
--population 13 --evaluation 300 --generations 30This allows 300 distinct evaluations with 13 candidates per round and up to 30 rounds. A returning candidate can keep a place in the next round. A small search space, repeated candidates or the round limit can make the run finish below 300. Add --preview to check before starting.
Without explicit limits, the CLI uses 100 evaluations and 10 generations. Omitting population or using --population 0 selects it automatically.