Run a strategy on the HQG backtester without leaving your editor, and see the results in a tab beside your code.
For VS Code and VS Code-based editors: Cursor, Windsurf and VSCodium.
This extension does what the HQG command line tool (hqg, from hqg-backtester) does: it sends your
strategy to the HQG backtester and waits for the result. You pick the dates and starting equity in
a side panel, press Run Backtest, and get the dashboard's results view inside your editor.
Install it in under a minute, without reading or building any code. If you want to work on the
extension itself, see Develop the extension.
Copy the Value of hqg_auth_token, paste it into the panel, and press Sign In.
The extension checks the token with the backtester before saving it, and tells you if it's wrong
or expired.
Tokens last 24 hours. The bottom of the panel shows how long you have left. When the token
expires, the panel asks you to sign in again.
Already use the HQG command line tool? If you've run hqg login, you're already signed in.
The extension reads the same token from ~/.hqg/credentials.
Sign Out at the bottom of the panel signs you out of the extension only. Your
~/.hqg/credentials file is left alone, so the HQG command line tool stays signed in.
Mark your strategy file
Add this line near the top of your strategy file, with your strategy's name after the colon:
# hqg-backtest: <strategy-name>
It's a comment, so Python ignores it. It can go on line 1, even above the module docstring.
It has to be within the first 10 lines, on a line of its own.
The name is used for the run. It shows in the panel and at the top of the results. With a
bare # hqg-backtest, the file name is used instead.
Spaces are optional:#hqg-backtest:<strategy-name> works too.
Only files with this line can be backtested. That keeps the run buttons away from your other
Python files.
Run a backtest
Open your strategy file, so it's the current tab.
Open the panel: click the line-chart icon in the Activity Bar, or the chart icon above the
file (see step 6). The panel shows your strategy's name
and the run settings:
Fill in the run. The panel remembers your values for next time.
Field
What it does
Start date / End date
The period to backtest.
Starting equity ($)
The cash the strategy starts with.
Run name
Leave empty to use the name from # hqg-backtest. Anything you type here is used for every strategy until you clear it.
Timeout (seconds)
How long to wait for the result before giving up. The run may still finish on the server.
Profile speed (slowest functions)
Times every function while your strategy runs and lists the 40 slowest in the results' Profile tab. Use it to find out why a backtest is slow. The run takes a little longer, so leave it off normally.
Press ▶ Run Backtest. While it runs, the panel shows the job's progress and a Cancel
button, and VS Code shows a progress notification at the bottom-right:
When it finishes, the results open in a tab on the right, beside your code:
The panel follows the current tab. Switch to another strategy file and the panel switches with
it. Switch to a file without the # hqg-backtest line, or close your strategy, and the panel asks
you to open one, with Run Backtest greyed out. You can click into the results tab while your
strategy is still visible beside it, and the panel keeps the strategy, so you can run again straight
away.
Want the panel on the right, next to Claude Code or Copilot? Drag the line-chart icon from the
Activity Bar into the Secondary Side Bar. VS Code remembers where you put it.
Read the results
When the backtest finishes, the results open in a tab beside your code. The tab has the HQG
candlestick icon .
Each run opens its own tab, so you can compare runs side by side.
Along the top: final equity, net profit, return, fees and volume.
Strategy metrics, on the left: Sharpe, Sortino, Calmar, alpha, beta, drawdown, VaR and more.
Strategy equity: your portfolio's value over time.
Switch between Candles and Line.
Jump to the last 1M / 6M / 1Y / 5Y, or show All.
Zoom with − / +, by scrolling over the chart, or by dragging the price axis. Fit shows
the whole run again. Drag the chart to pan.
When zoomed in, thin scrollbars appear along the bottom (time) and right side (price) of the
chart. Double-click the price scrollbar to fit prices again.
Grey bars mean the portfolio was 100% cash. You'll often see this at the start, while a
strategy collects enough price history to make its first decision.
Allocation: what share of the portfolio each asset held over time. Each step is a
rebalance.
Execution log: every order, with filters by asset and buy/sell, and 10–100 orders per page.
The Logs tab has your strategy's self.log() output. The Profile tab appears when you
ran with Profile speed on.
Hover over either chart to see that day's prices and holdings:
If a run fails, the error shows in a notification and in the panel. If the error names a line
in your file, that line gets a red squiggle, which goes away once you edit the file. Everything
from each run, including self.log() output, is also written to the HQG Backtest channel in
VS Code's Output panel (View → Output).
Updates
VS Code updates the extension by itself when a new version comes out. To check which version you
have, open the Extensions view and click HQG Backtester. Its changes are listed in the
changelog.
After an update, results tabs that were already open keep the old version until you run the
backtest again.
Troubleshooting
What you see
What to do
No line-chart icon in the Activity Bar
In the Extensions view, check that HQG Backtester is installed and enabled, then run Developer: Reload Window (⇧⌘P).
Run Backtest is greyed out
Make your strategy file the current tab, and check that # hqg-backtest: <strategy-name> is within its first 10 lines.
The chart icon above the file doesn't show
Same as above. The # hqg-backtest line must be on its own, not after code.
"The backtester turned down your sign-in"
Your token was rejected. Sign in to the dashboard again and paste the new token.
"Your sign-in expired"
Tokens last 24 hours. Copy a fresh one from the dashboard.
The equity line is flat and grey at the start
That's warm-up: your strategy was all cash while it gathered price history. The backtester sends no data from before your start date, so start the backtest earlier if you need results from a specific date.
Not sure the backtester is up
Press Check Service at the bottom of the panel.
Setting:hqg.apiUrl points the extension at a different backtester, for example one you run
locally. The default is https://platform.uconnquant.com/backtester.
Develop the extension
This section is for working on the extension itself. To just use it, install it from the
Marketplace as described in Install.
git clone https://github.com/Husky-Quantitative-Group/hqg-vscode.git
cd hqg-vscode
Step 2: Install the build tools
npm install
This downloads what the extension needs into a node_modules folder. It only has to be done once,
and again after package.json changes.
Step 3: Run your copy
Open the hqg-vscode folder in VS Code and press F5. A second VS Code window opens with your
development copy of the extension loaded. After changing code, run Developer: Reload Window in
that second window to see the change.
If you also have the Marketplace version installed, disable it in the Extensions view while you
work, so the two copies don't both show up.
Step 4: Build and install your own copy
To try your build in your normal editor before it's published:
npm run package # builds hqg-backtester-0.1.0.vsix
code --install-extension hqg-backtester-0.1.0.vsix
Then run Developer: Reload Window.
If it says code: command not found
Open VS Code.
Press ⇧⌘P (Ctrl+Shift+P on Windows) to open the Command Palette.
Type Shell Command: Install 'code' command in PATH and press Enter.
Open a new terminal, cd back into hqg-vscode, and run the command again.
On Mac, VS Code must be in your Applications folder for this to work. If you'd rather not use
the terminal: open the Extensions view, click the ⋯ menu at the top, choose
Install from VSIX…, and pick the .vsix file.
To pick up other people's changes later: git pull, npm install, then run step 4 again with
--force added to the install command.
Publish a new version
For HQG maintainers. Each release goes to both stores: the VS Code Marketplace, and Open VSX for
Cursor, Windsurf and VSCodium. Publishing a GitHub release does the Open VSX part for you. The
Marketplace takes one command.
Raise version in package.json, for example 0.1.1 → 0.1.2, describe the change at the top
of CHANGELOG.md, then commit and push.
Create a GitHub release tagged with that version, for example v0.1.2, on
Releases → Draft a new
release, or with gh release create v0.1.2 --generate-notes. The Publish release GitHub
Action then builds the extension, publishes it to Open VSX, and attaches the .vsix to the
release. It stops with an error if the tag doesn't match package.json.
Publish the same version to the VS Code Marketplace, from the hqg-vscode folder:
az login --allow-no-subscriptions --scope "499b84ac-1321-427f-aa17-267ca6975798/.default"
npm run publish
With a work or school account, add --tenant <your-organization's-tenant-id> to az login.
For UConn that's 17f1a87e-2a25-4eaa-b9df-9d439034b080.
The Marketplace step signs in through the Azure CLI, because Microsoft retires token-based
Marketplace publishing on December 1, 2026. It isn't automated because UConn accounts can't create
the Azure identity a GitHub Action would need. The Action's Open VSX token is the OVSX_PAT
repository secret; to replace it, run gh secret set OVSX_PAT and paste a new token from your
Open VSX settings.
Where things are
Path
What's there
src/extension.ts
Commands, the run flow, sign-in, and which file counts as the strategy
src/panel.ts, media/panel.*
The side panel
src/results.ts, media/results.*
The results tab
src/api.ts
The backtester API client, the same calls as cli/api.py in hqg-backtester