Our Mission#

QuantScript exists to lower friction across the full lifecycle of quantitative trading — from data sourcing and exploration, through technical analysis and backtesting, to paper trading and live deployment.

Today, quant traders juggle multiple tools: Python for research, Pine Script for charting, MQL5 for live execution, and custom adapters to connect them. QuantScript consolidates these into a single, coherent language with standard JavaScript syntax, reducing context switching and improving productivity.

Try QuantScript in your browser at quantscript.com/playground — no installation required.

We believe the scripting language for quantitative finance should be:

  • Readable — clear intent, no arcane syntax
  • Portable — the same strategy runs across brokers and asset classes
  • Safe — runtime guardrails prevent accidental real trades
  • AI-collaborative — designed for both human developers and AI agents

Design Principles#

💻

JavaScript-Native Ergonomics

Standard let, const, if, for, arrow functions, destructuring, optional chaining, nullish coalescing. Only one custom keyword: mode.

🤖

AI-Friendly by Design

Explicit object arguments over positional lists. Stable, consistent naming. Predictable return shapes. Structured error messages with machine-readable metadata.

🌐

Broker-Portable

The same strategy script runs across MT5, crypto exchanges, and equities brokers via an adapter pattern. Capability discovery through trade.capabilities().

Independent Identity

Draws philosophical inspiration from Pine Script, MQL5, CCXT, and JavaScript — but intentionally avoids legacy syntax lock-in. It's its own thing.

🛡

Safe by Default

Runtime risk limits, kill switches, capability checks, and mode guardrails. The risk() declaration enforces position limits and daily loss caps.

🔄

Deterministic Execution

Reproducible at candle level. Every signal, order, fill, and position update is event-sourced for auditability.

📊

DataFrame as Primitive

Named, aligned time-series columns are native to the language. Each expression computes one value per frame; values accumulate into full columns.

Event-Driven Architecture

FrameModel serves as the Single Source of Truth. Renderers subscribe to state-change events. The event.* namespace provides callbacks for ticks, candles, orders, deals, and positions.

Architecture Overview#

Execution Pipeline

  1. Parse — Source code is tokenized by the Lexer and parsed into an AST by the Parser (built on Chevrotain).
  2. Execute — The tree-walking Interpreter traverses the AST, maintaining a scoped Environment for variable binding.
  3. Iterateevent.onCandle() drives frame-by-frame execution. Each frame computes one value per expression.
  4. Route — Trade operations are routed to the appropriate TradingEngine (SimEngine for backtest/paper, LiveEngine for live).
  5. Store — FrameModel acts as the central state container, partitioned into Input, Outputs, and State.

Canonical Trading Model

Seven core types define the universal trading primitives:

TypePurpose
QSOrderRequestObject-shaped order submission with explicit fields
QSOrderRuntime order representation with lifecycle tracking
QSFillSingle execution event with fee details
QSPositionAggregated exposure with PnL and margin
QSAccountAccount snapshot (balance, equity, buying power)
QSSymbolInfoNormalized instrument metadata
BrokerCapabilitiesRuntime feature discovery

Execution Strategy Framework

Built-in Presets
broker("sim", { execution_strategy: "bar-match-netting" });     // CFD/forex
broker("sim", { execution_strategy: "crypto-spot" });            // Spot crypto
broker("sim", { execution_strategy: "us-equities" });             // US stocks

Inspiration, Not Imitation#

InspirationWhat We TookWhat We Changed
Pine Script Concise indicator syntax, ta.* namespace, chart-first design, per-bar execution model Standard JS syntax. Explicit event.onCandle(). null instead of na. Hex colors.
MQL5 Trading execution rigor, event-driven lifecycle, strategy/indicator separation CCXT-style trade.* API. Object parameters. Capability discovery instead of compile-time broker coupling.
CCXT Broker-portable API design, camelCase naming, unified object parameters Integrated directly into the language runtime. Extended with execution strategies for backtest simulation.
pandas / numpy DataFrame as the core data primitive, named aligned columns Native to the language. Frame-by-frame execution model instead of vectorized operations.
JavaScript (ES6+) Full standard syntax: let/const, arrow functions, destructuring, optional chaining Only one addition: the mode keyword. Named arguments via key: value syntax.

Who It's For#

📈

Quantitative Traders

Build and backtest indicators and strategies in a single language. Write once, run in backtest, paper, or live mode.

🛠

Algorithmic Developers

Rapid prototyping of technical analysis pipelines and automated trading logic. Familiar JavaScript syntax means no learning curve.

🔬

Research Analysts

Explore datasets, compute features, and visualize results — all within the same environment you'll eventually deploy to.

🤖

AI Agents

Explicit object parameters, predictable shapes, stable naming conventions, and canonical examples make it ideal for AI-assisted strategy development.