The Scripting Language for Quantitative Finance

JavaScript-like syntax with built-in technical analysis, DataFrame primitives, and strategy execution — combining the best of pandas, Pine Script, and MQL5.

npm install @quantscript/lang

Quick Start

Write a complete SMA crossover strategy in just a few lines.

QuantScript
const config = {
    mode: "backtest",
    symbol: "BTCUSD",
    timeframe: "1h",
    backtest: { initial_capital: 100000, commission: 0.001 }
};

let df = data.ohlcv(config.symbol, config.timeframe, 500);
df.smaFast = ta.sma(df.close, 10);
df.smaSlow = ta.sma(df.close, 30);

df.forEach((frame) => {
    if (ta.crossover(frame.smaFast, frame.smaSlow)) {
        strategy.entry("Long", { side: strategy.long, qty: 100 });
    }
    if (ta.crossunder(frame.smaFast, frame.smaSlow)) {
        strategy.close("Long");
    }
});
$ quantscript run strategy.qs --mode backtest --json

Why QuantScript?

Purpose-built for quantitative finance with familiar JavaScript syntax.

𞃎

JavaScript Syntax

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

📊

DataFrame Primitive

Named, aligned time-series columns — like pandas, but native to the language.

📈

Built-in TA

ta.sma(), ta.rsi(), ta.bbands(), ta.crossover(), and 30+ more indicators.

Strategy Execution

strategy.entry(), strategy.close() with backtest, paper trading, and live modes.

📷

Frame-by-Frame

Each expression computes one value per frame; values accumulate into full DataFrame columns.

💻

CLI + Playground

Run scripts headlessly, replay historical data, or launch a browser-based interactive playground.

Built-in Namespaces

Rich standard library for technical analysis, math, data, and trading.

ta.*

Technical analysis

ta.sma(), ta.ema(), ta.rsi(), ta.bbands(), ta.crossover(), ta.macd()
math.*

Math functions

math.abs(), math.sqrt(), math.pow(), math.round(), math.sin(), math.log()
array.*

Array operations

array.push(), array.sort(), array.sum(), array.avg(), array.slice()
str.*

String operations

str.contains(), str.split(), str.replace(), str.upper(), str.format()
data.*

Data access

data.ohlcv(), data.align(), data.fetch()
strategy.*

Trading operations

strategy.entry(), strategy.close(), strategy.exit(), strategy.equity

Operation Modes

Built-in runtime guardrails that prevent accidental real trades during testing.

data

Source, clean, and explore market data

analysis

Compute indicators and features

visualize

Render charts and dashboards

backtest

Simulate trades on historical data

forward

Paper trade on live data

live

Real execution with risk guardrails

Coming from Pine Script?

QuantScript uses familiar concepts with standard JavaScript syntax. If you know Pine Script, you'll feel right at home.

View Migration Guide