basecomponents/src/lib/QueryBuilder/language.ts by pnpm --filter docsite gen:reference; a test fails when it drifts.VectarisQL grammar
Version 3.0. Rows are self-describing: the row type is derived from the text, never from a hidden flag. Slots are zero-indexed and whitespace-separated; keywords, units, and option keys are upper-cased on parse (quoted strings and ISO dates keep their casing). For the guided tour see VectarisQL.
Row shapes
| Row type | Syntax |
|---|---|
| Data series | SYMBOL[@ROUTE][:ADAPTER] INTERVAL RANGE [OPTIONS:{KEY:VALUE, ...}] |
| Indicator | NAME(PARAM[, PARAM ...]) [OPTIONS:{KEY:VALUE, ...}] |
| Collection | COLLECTION[:PARAM][:ADAPTER] [[COL, COL, ...]] [WHERE ...] [ORDER BY ...] [LIMIT:N] |
| Symbol only | SYMBOL[@ROUTE][:ADAPTER] |
Symbol expression
Slot 0 of any row that accepts a symbol; inline qualifiers attach to the symbol.
Syntax: SYMBOL[@ROUTE][:ADAPTER]
| Part | Delimiter | Required | Description | Examples |
|---|---|---|---|---|
symbol |
yes | Ticker or instrument identifier (letters, digits, "-", "."). | AAPL, SPY, BTC-USD, BRK.B, ES |
|
route |
@ |
no | Force exchange or ECN routing. | @ISLAND, @NASDAQ, @CME |
adapter |
: |
no | Force a specific adapter / credential. Quote if the label has spaces. | :Schwab, :Tradier, :"Schwab Test" |
Examples: SPY, SPY@ISLAND, SPY:Schwab, SPY@ISLAND:"Schwab Test", BTC-USD, BRK.B
Data series
Three positional slots: SYMBOL, INTERVAL, RANGE. Optional OPTIONS tail.
Syntax: SYMBOL[@ROUTE][:ADAPTER] INTERVAL RANGE [OPTIONS:{KEY:VALUE, ...}]
| Slot | Name | Description | Examples |
|---|---|---|---|
| 0 | symbol |
Symbol expression (see symbolExpression). | |
| 1 | interval |
NUMBER + UNIT. Adapter-validated. | 1S, 5S, 1M, 5M, 15M, 1H, 4H, 1D, 1W, 1MO |
| 2 | range |
Shorthand, ISO date range, or single ISO date (from-date to now). | 1D, 5D, 30D, 1MO, 3MO, 1Y, YTD, MAX, 2024-01-01/2024-12-31, 2024-01-01 |
Interval units
| Unit | Meaning | Example |
|---|---|---|
S |
second | 1S |
M |
minute | 5M |
H |
hour | 1H |
D |
day | 1D |
W |
week | 1W |
MO |
month | 1MO |
Range forms
| Form | Examples | Meaning |
|---|---|---|
shorthand |
1D, 30D, 1MO, 3MO, 1Y, YTD, MAX |
|
iso-range |
2024-01-01/2024-12-31 |
|
iso-from |
2024-01-01 |
from that date through now |
Examples
AAPL 1D 30D
AAPL 5M 5D
SPY@ISLAND:Schwab 1H 30D
BTC-USD 1D 2024-01-01
ES 15M 2024-01-01/2024-06-30
AAPL 1D 1Y OPTIONS:{STYLE:LINE, AXIS:RIGHT}
Indicators
Indicator calls always carry parens — even with no params. Parens are inserted by the autocomplete; the user never types them.
Syntax: NAME(PARAM[, PARAM ...]) [OPTIONS:{KEY:VALUE, ...}]
| Part | Delimiter | Required | Description | Examples |
|---|---|---|---|---|
name |
yes | Indicator name from the registry. | SMA, EMA, RSI, MACD, VWAP, BB |
|
params |
() |
yes | Comma-separated numeric parameters. Defaults pulled from IndicatorParamDef. | (14), (20), (12, 26, 9) |
Examples
SMA(14)
EMA(20)
RSI(14) OPTIONS:{PANEL:NEW}
MACD(12, 26, 9) OPTIONS:{PANEL:NEW, AXIS:RIGHT}
SMA(14) OPTIONS:{INPUT:$2, PANEL:$3}
Collections
Collections are tabular adapter data. Grammar follows SQL-like clauses; string literals in WHERE are not force-uppercased.
Syntax: COLLECTION[:PARAM][:ADAPTER] [[COL, COL, ...]] [WHERE ...] [ORDER BY ...] [LIMIT:N]
| Part | Delimiter | Required | Description | Examples |
|---|---|---|---|---|
collection |
yes | Adapter-declared collection name. | ORDERS, POSITIONS, BALANCES, ACCOUNTS |
|
param |
: |
no | Collection parameter (e.g. account label). Quote if it has spaces. | :sp500, :"My Tech Stocks" |
adapter |
: |
no | Force a specific adapter (only when 2+ provide this collection). | :Schwab, :"Schwab Test" |
columns |
[ ] |
no | Project specific columns; default is the collection's declared columns. | [SYMBOL, SIDE, QTY], [SYMBOL, LAST, CHANGE%] |
where |
WHERE |
no | Conditions joined by AND / OR. | WHERE STATUS='Filled', WHERE UNREALIZEDPNL > 0 |
orderBy |
ORDER BY |
no | One or more columns with optional ASC | DESC (default ASC). | ORDER BY TIME DESC, ORDER BY SYMBOL ASC, UNREALIZEDPNL DESC |
limit |
LIMIT: |
no | Maximum row count. Positive integer. | LIMIT:25, LIMIT:100 |
WHERE operators
| Operator | Applies to | Notes |
|---|---|---|
= |
string, number, date, boolean | |
!= |
string, number, date, boolean | |
> |
number, date | |
< |
number, date | |
>= |
number, date | |
<= |
number, date | |
~ |
string | Regex match |
IN |
string, number |
Examples
ORDERS
ORDERS:Schwab
ORDERS [SYMBOL, SIDE, QTY, STATUS]
ORDERS WHERE STATUS='Filled' ORDER BY TIME DESC
POSITIONS WHERE UNREALIZEDPNL > 0 LIMIT:20
ORDERS:"Schwab Test"
POSITIONS:acct1 [SYMBOL, QTY, UNREALIZEDPNL] WHERE UNREALIZEDPNL > 0
Options
At most one OPTIONS:{KEY:VALUE, ...} tail block per row. Schema is per row-type; collection rows do not accept OPTIONS.
Syntax: OPTIONS:{KEY:VALUE[, KEY:VALUE ...]}
Per-row-type keys and values are listed on VectarisQL options.
Examples
AAPL 1D 1Y OPTIONS:{STYLE:LINE}
AAPL 1D 30D OPTIONS:{STYLE:CANDLE, EXTENDED:TRUE, AXIS:RIGHT}
RSI(14) OPTIONS:{PANEL:NEW}
SMA(14) OPTIONS:{INPUT:$2, PANEL:$3}
Row references
Row positions and nicknames flow through indicator OPTIONS. $1, $2, ... reference rows by position; $name references a nicknamed row. Nicknames are assigned out-of-band, not via the row string.
Examples: $1, $2, $price, NEW (panel only)