Skip to content
| Marketplace
Sign in
Visual Studio Code>Data Science>HQG BacktesterNew to Visual Studio Code? Get it now.
HQG Backtester

HQG Backtester

Husky Quantitative Group

|
10 installs
| (0) | Free
Run HQG backtests from your editor and see the results beside your strategy.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

HQG

HQG Backtester

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.

  • Install
  • Sign in
  • Mark your strategy file
  • Run a backtest
  • Local backtests
  • Read the results
  • Updates
  • Troubleshooting
  • Develop the extension

Install

What you need

  • VS Code 1.90 or newer, or a recent Cursor, Windsurf or VSCodium.
  • An HQG dashboard account with backtester access, for backtests on the HQG server and in the sandbox. You can sign in at dashboard.uconnquant.com; if you can't, ask an HQG admin. Without an account you can still run local backtests.

Step 1: Install the extension

The extension is the same everywhere, but VS Code and the other editors get extensions from different stores. Follow the steps for your editor.

VS Code, from the VS Code Marketplace

  1. Open the Extensions view: ⇧⌘X on Mac, Ctrl+Shift+X on Windows.
  2. Search for HQG Backtester, and check that the publisher is Husky Quantitative Group.
  3. Click Install.

Or click Install on its Marketplace page, or run this in a terminal:

code --install-extension hqg.hqg-backtester

Cursor, Windsurf or VSCodium, from Open VSX

These editors can't use the VS Code Marketplace. They install from Open VSX instead.

  1. Open the editor's Extensions view: ⇧⌘X on Mac, Ctrl+Shift+X on Windows.
  2. Search for HQG Backtester, and check that it's by hqg.
  3. Click Install.

In VSCodium you can also run this in a terminal:

codium --install-extension hqg.hqg-backtester

The rest of this guide works the same in every editor. The screenshots show VS Code.

Step 2: Find the extension's icons

Open any Python file that has the # hqg-backtest line (see Mark your strategy file). The extension adds two chart icons:

VS Code with a strategy file open. Circled: 1, the line-chart icon in the Activity Bar; 2, the chart icon above the file

  1. The line-chart icon in the Activity Bar, on the far left. It opens the HQG Backtester panel, and it's always there, even with no strategy open.
  2. The chart icon above the file, at the top-right of the editor. It shows only while a strategy file is the current tab, and opens the same panel.

You run backtests from inside the panel, with its Run Backtest button.

The extension is installed. Next, sign in.

Sign in

You can run backtests without signing in: they run on your computer, without the sandbox (see Local backtests). To use the HQG server and the sandbox, click the line-chart icon in the Activity Bar, then Log In at the bottom of the panel. The panel asks for your dashboard token:

VS Code with the HQG Backtester panel open on the left, showing the token box and the steps for finding the token, beside the strategy file

  1. Sign in at dashboard.uconnquant.com.
  2. Open your browser's DevTools: ⌥⌘I on Mac, F12 on Windows.
  3. Go to Application → Cookies → https://dashboard.uconnquant.com. In Firefox it's the Storage tab.
  4. 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 goes back to local backtests and offers Log 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

  1. Open your strategy file, so it's the current tab.

  2. Open the panel: click the line-chart icon in the Activity Bar, or the chart icon above the file (see step 2). The panel shows your strategy's name and the run settings:

    Ready to run: the panel shows the strategy name, dates, starting equity and an enabled Run Backtest button

  3. 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.
    Local backtest Run on your own computer instead of the HQG server, in a Docker container like the server's. Faster; see Local backtests.
    No sandbox Shown when Local backtest is on. Runs the strategy without Docker. Only for code you trust.
  4. 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:

    Running: the panel shows "submitting" and a Cancel button, with a Backtesting main.py notification

  5. When it finishes, the results open in a tab on the right, beside your code:

    The results tab open on the right of the strategy file, with final equity, net profit, return, the equity chart and the allocation chart

    See Read the results for what everything in it means.

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.

Local backtests

Turn on Local backtest, just above Run Backtest, to run backtests on your own computer instead of the HQG server. It uses the same backtest engine, the same code checks and the same sandbox as the server, and gives the same results, without the upload and the wait for the server.

Not signed in? Then this is the only mode: every run is local and without the sandbox (see No sandbox below), and the switches and Profile speed are hidden. Log In at the bottom of the panel turns on the server, the sandbox and profiling.

  • Your strategy runs in a sandbox, a Docker container with the server's limits: no network, a read-only disk, 512 MB of memory and 1 CPU. A strategy that goes over its memory is stopped with a message saying so, as on the server. The next container starts while the current run goes, so a run doesn't wait for one; the sandbox adds about 0.3 seconds.
  • After an hour unused (no runs, and no editing of a strategy), the local engine and its waiting container stop to free memory. The next run starts them again, which takes a second or two longer. If the extension started Docker, it quits Docker too, unless other containers are running in it.
  • You need Docker installed: Docker Desktop, or on a Mac Colima (brew install colima docker), OrbStack or Rancher Desktop. If it isn't running, the extension starts it when a sandboxed run needs it (up to a minute). On Linux without Docker Desktop, start the Docker service yourself.
  • No sandbox (under the Local backtest switch) runs the strategy as ordinary Python on your computer instead, without Docker. Use it only for code you trust, such as your own.
  • The first time you turn local backtests on (or, signed out, the first time you run), the extension sets up a private Python environment with pandas, yfinance and a few other libraries (about a minute), then builds the sandbox image (about another minute, 835 MB). It runs in the background while you keep working. Your own Python and packages aren't touched.
  • You need Python 3.11 or newer installed. The extension finds it by itself; to choose a specific one, set hqg.localPython in Settings to its command or path.
  • Prices download once per ticker from Yahoo Finance, the same source the server uses, and are kept on your computer. The first run with new tickers waits a second or two for that; after that, runs read them from disk. With local mode on, the extension also downloads them while you edit, as soon as you open a strategy or change its universe.
  • Alt data from FRED needs a free FRED API key in a FRED_API_KEY environment variable when you start VS Code. Price data needs nothing.

The Python environment and prices are stored in VS Code's storage for the extension, so uninstalling the extension removes them. The sandbox image stays in Docker as hqg-local-sandbox; remove it with docker image rm if you no longer need 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.

The results tab: headline numbers, strategy metrics, the equity chart, the allocation chart and the execution log

  • 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.
    • Tick Compare with S&P 500 to add a white line (black in light themes): what your starting equity would be worth if you had put it all in the S&P 500 index on the first day. The metrics table then shows the S&P 500's Sharpe, drawdown and other numbers beside your strategy's, worked out the same way as the engine's. It's off on every new results tab.
    • Jump to the last 1M / 6M / 1Y / 5Y, or show All.
    • The expand button (two outward arrows) in the card's top-right corner shows the equity and allocation charts large in the middle of the window (the strategy file hides for the moment). The same button, now with inward arrows, or Esc puts them back.
    • 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:

Hovering the equity chart shows the day's open, high, low and close, and the largest 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.
"Local backtests need Python 3.11 or newer" Install Python from python.org, then turn Local backtest off and on again. Or set hqg.localPython to a Python you already have.
"Docker isn't running" Start Docker Desktop (or run colima start), then run again. Or turn on No sandbox for a strategy you trust.
"Sandboxed local backtests need Docker" Install Docker Desktop or Colima (see Local backtests), or turn on No sandbox.
"The sandbox stopped the strategy: it used more than its 512 MB of memory" The same limit as the server. Use less data at once, for example shorter histories in deques or arrays.
The first local run is slow It's downloading the strategy's prices once. Later runs with the same tickers read them from disk.
A local run fails on FRED alt data Set a FRED_API_KEY environment variable and restart VS Code. See Local backtests.

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.

What you need

How to check Where to get it
VS Code 1.90 or newer Code → About Visual Studio Code code.visualstudio.com
Git git --version in a terminal git-scm.com
Node.js 18 or newer, which includes npm node --version nodejs.org, the LTS version

Step 1: Get the code

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
  1. Open VS Code.
  2. Press ⇧⌘P (Ctrl+Shift+P on Windows) to open the Command Palette.
  3. Type Shell Command: Install 'code' command in PATH and press Enter.
  4. 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.

You need membership in the hqg publisher on the Marketplace management page, and the Azure CLI (brew install azure-cli).

  1. 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.
  2. 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.
  3. 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.

Update the local engine

Local backtests run a copy of the HQG backtest engine bundled in python/vendor/, so their results match the server. When hqg-backtester, hqg-datafeed or hqg-algorithms change, refresh the copy before releasing:

./scripts/sync-engine.sh

It copies the current main branch of each repo from GitHub, without touching your own clones, and records the commits in python/vendor/VERSIONS.txt. It expects the three repos cloned next to hqg-vscode; set HQG_REPOS to their folder otherwise. Commit the result. If you change python/requirements.txt, members' private environments update themselves on their next local run. The sandbox image is named after a hash of everything copied into it (python/sandbox/, python/vendor/ and the runner), so a release that changes any of them rebuilds it on members' next sandboxed run, and the old image is removed.

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
src/auth.ts Token storage, and reading ~/.hqg/credentials
src/local.ts Local backtests: the private Python environment, the sandbox image and the background worker
python/hqg_local/worker.py The worker that runs local backtests with the bundled engine, and starts the sandbox containers
python/hqg_local/sandbox_runner.py, python/sandbox/ What runs inside a sandbox container, and its image
python/vendor/ The bundled engine, from hqg-backtester, hqg-datafeed and hqg-algorithms
scripts/sync-engine.sh Refreshes python/vendor/ from GitHub
media/icon.png The extension's icon on the Marketplace
docs/images/ The screenshots in this README
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft