Documentation1.0 (latest)
PagesBuilding extensions · 33 / 37

New in v1.4.0

Building your own extension

New in QuantCraft v1.4.0. This page describes functionality that ships with v1.4.0, the next major release. The current release is v1.3.0, which does not include it yet.

You can make an extension for yourself or to share, from the QuantCraft IDE, with no setup beyond turning on Developer mode. You write plain JavaScript (and HTML/CSS) in a project folder, run it live, and pack it into a single .qcext file.

New to extensions? Read Extensions first. Ready-made code is in Extension examples; every setting, permission and function is in Extension API.


What you can build

KindWhat it isNeeds
PanelA sidebar icon that opens a window of your own, plus an optional footer statusnothing (add permissions for the data you read)
Data providerSupplies price bars, live trades, symbols or prices from your vendor. Starts with a mock so it works before you write vendor codedata.provide and the vendor's domain
Fundamentals providerSupplies company fundamentals for charts, runs and the Screenerdata.provide and the vendor's domain
BrokerPlaces orders through your brokerage (see Broker extensions). Starts with a mock brokerdata.provide + place orders
AI toolsTools the AI assistant can callai.tools
WebAssembly engineA sandboxed .wasm module behind an AI tool or providerrun its own program
Python engineA Python program (with pure-Python packages) behind a tool or providerrun its own program
Native engineYour own program, one build per operating systemrun its own program, and Verified or Developer mode
ThemeColours only, no codenothing
npm packagesAdd-on for the others: use npm packages and split your code into modulesa build step

Extension development loop: turn on Developer mode, create a project, then edit, validate and run with hot reload, inspect with Mock, Debug and Logs, and Build a .qcext to share.

1. Turn on Developer mode

Extensions → Developer → Developer mode. It lets you load an extension straight from a folder. Loaded folders run unverified, which is why it is a switch you turn on yourself.

2. Create a project

In the IDE, open the Files sidebar and choose New extension project.

  1. Give it a Name; the id is made from your publisher name and the name (publisher.name, lowercase). The id is fixed once you publish, so choose it with care.
  2. Under Parts, tick one or more kinds. They share one manifest. Advanced holds the broker, engines and npm packages.
  3. Create project. The wizard lists the files it will create and the permissions it asks for.

Open the project folder in the IDE. Its manifest is qcext.json. The Manifest button in the project bar opens a form that edits it for you.

A minimal manifest (qcext.json) for a panel that reads price bars. The wizard writes one like this for you, and the Manifest button edits it:

{ "id": "acme.lastclose", "version": "0.1.0", "apiVersion": 1, "name": "Last close", "description": "Latest close and 30-day change for a symbol.", "permissions": ["data.ohlcv"], "contributes": { "sidebar": { "title": "Last close", "icon": "ui/icon.svg", "entry": "ui/index.html" } } }

The complete project, with its page and script, is in Extension examples.

3. The project bar

When the IDE's workspace is an extension project, a bar appears above the editor.

ButtonWhat it does
ValidateChecks the manifest, every file it points at, JavaScript/JSON/HTML/CSS syntax, relative imports and permission use. Problems are listed as file:line
Run / StopLoads the folder as a developer extension and opens it. Run is off while the manifest has errors
ReloadReload now (it also reloads by itself when you save)
WindowOpens the extension in a separate preview window ("Live · reloads on save") instead of the in-app modal
ManifestA form for qcext.json
MockFor data providers: fetch sample bars and watch live ticks, set latency, failures, bad data and silence, and see exactly what QuantCraft accepted or dropped and why
BuildChecks, packs and signs your project into a .qcext
DebugLive calls, provider traffic, data sources and storage (see below)
LogsEverything the extension reported
DevToolsOpens the browser developer tools. Only in builds that include them

The status chip shows Running, Reloaded N s ago, Reloading…, Stopped or Error · N problem.

Hot reload: while a project runs, saving a file reloads it in about a second. A syntax error or bad manifest pauses the reload and keeps the last working version on screen; fix it and it reloads. A reload that would add a new permission is refused until you load the folder again and approve it.

4. Write it

Every page and script loads the QuantCraft SDK and waits for it:

<script type="module" src="/_sdk/qc.js"></script> <script type="module" src="app.js"></script>
const qc = await window.qc.ready; // then use qc.* (see the Extension API page)

Rules every extension follows:

  • No inline scripts, no eval. Put code in .js files. Styles go in a .css file (or an inline <style>).
  • Network: only to the HTTPS hosts you declare as net:<host> permissions (a hostname such as api.example.com, no scheme or port, at most 20). Declare them in the manifest, and the user sees them when installing.
  • Secrets: declare a setting of type secret (and the secrets permission) and read it with qc.secrets.get. The user types the key in the extension's Settings; never ask for it in your own page.
  • Use as few permissions as you can. An update that adds one makes every user approve again.
  • Paths are relative, with /, and never ...
  • Colours: use the --qc-* CSS variables so your page follows light, dark and the user's theme.

5. Add npm packages (optional)

Tick npm packages in the wizard (or add it later). Your code lives in src/; Build (and Run / Reload) bundles it into the files the manifest loads, and package.json and src/ are left out of the package. The first time, QuantCraft asks you to allow the project's build script (Run this project's build script?). Dependencies are installed with scripts disabled. Use only packages that run in a browser.

6. Build and share

Press Build. It runs these steps and shows each result: Check the manifest → Check syntax → Check permission use → Install dependencies / Build (compile) when needed → Pack the files → Sign. The result is dist/<id>-<version>.qcext.

  • Raise version in qcext.json (semver) before building a new release.
  • The package is signed with a key on your computer. That makes it Self-signed, which is not the same as Verified: other people will see it as unverified.
  • Install this build installs the package on your machine to test it as a user would.
  • To share it, send the .qcext file. People install it with Install extension → From file (or From URL / GitHub). Verified status and the Browse catalog are managed by QuantCraft.

Limits: a package may hold up to 2000 files, 20 MB per file and 100 MB in total.


Testing a data provider with Mock

Start from the Data provider or Fundamentals provider part: it ships with a mock source and a switch (USE_MOCK) at the top of the provider file. Leave it true to try the whole flow, then set it to false and fill in the vendor calls.

In Mock: Fetch bars, Watch live ticks, then use Latency, Failure rate, Bad bars, Future bars, Bad ticks and Go quiet after to see how your extension and QuantCraft behave when the vendor misbehaves. The panel lists what was accepted, dropped and why.


Debugging

ToolWhat it gives you
LogsLevels, sources and a filter. Errors show the file and line, and a stack. In a bundled project (npm packages) the position is mapped back to your src/ file, and clicking it opens the file at that line
Debug → CallsEvery call between your extension and QuantCraft in both directions: the method, the result (or error code such as permission_denied, timeout, rate_limited), how long it took, the size, and a short summary of the arguments. Anything that looks like a key or password is hidden, and results are not recorded
Debug → ProvidersFor each provider call: count, errors, average and maximum time
Debug → Data sourcesFor the open chart: which source serves bars, ticks, symbols, prices and fundamentals, and why (your chip, your footer choice, a source that is off or removed, or a failure this session)
Debug → Storage and secretsThe names and size of what your extension stores, and which secret settings are set. Never the values
DevToolsBreakpoints and stepping in the browser developer tools: open your file under Sources and set a breakpoint, or write debugger; in your code. Available in builds that include the tools

Only your own Developer projects are traced.

Common problems:

You seeLikely cause
permission_deniedThe permission is missing from qcext.json (add it), or the user turned it off
"Extension failed to load"The page threw before it started, or a file it points at is missing. Read Logs
A blank panelawait window.qc.ready is missing, or an inline script was blocked
A request to your vendor is blockedAdd its hostname as a net: permission
"Run is off"The manifest has errors: Validate lists them
A data source is skippedSee Debug → Data sources for the reason

Command line: qc-ext

If you prefer working outside the IDE, the SDK package includes a qc-ext command:

CommandWhat it does
qc-ext init <dir> --template <parts> --id publisher.name --name "Name"Creates a project (the same parts as the wizard; combine with commas)
qc-ext validate [dir]The same check as Validate; non-zero exit on errors
qc-ext dev [dir]Re-validates on every change (load the folder in the app with Developer mode to run it)
qc-ext pack [dir]Validates and writes dist/<id>-<version>.qcext; add --build to run the build first

Let the AI assistant do it

The QuantCraft AI chat can write an extension for you. Open the project as the IDE workspace, use Agent mode, and describe what you want ("a data provider for my vendor's REST API", "a panel that lists today's movers").

  • It reads the right guide and starts from the same files as New extension project.
  • After every batch of edits QuantCraft checks the whole project and tells the assistant the exact file:line problems, so it fixes them without being asked.
  • In Agent mode it can run the project, build it (only if you already allowed the build script), pack it, and read the extension's logs and calls to find out why something fails.
  • It will ask you to do the things that are yours: turn on Developer mode, allow a build script, install dependencies, replace an installed extension with the same id. It never signs, installs a package or publishes for you.

Review what it writes, especially the permissions it asks for.

Building extensions — Documentation (1.0 (latest)) | QuantCraft