Write quantitative trading strategies once. Compile to multiple platforms. Bitwise-identical decisions everywhere.
TIR is a domain-specific language for quantitative finance. This extension brings the full TIR experience to VS Code — syntax highlighting, intelligent editing, step debugging, and one-click backtesting with an equity curve — all powered by native sidecar binaries that ship with the extension (no Rust toolchain required).
Features
🎨 Syntax Highlighting
Precise, grammar-driven highlighting for every TIR production — keywords, series, handles, and built-ins are all tokenized with intent.
🧠 Intelligent Editing (LSP)
- Completion with relevance-ranked candidates and method snippets
- Signature help for built-in functions, host methods (
p.position.qty(), and user-defined fn
- Hover with full type and documentation
- Diagnostics with clickable code descriptions and auto-fix quick actions (missing semicolons, undefined names with nearest-match suggestions)
- Semantic highlighting that distinguishes variables, parameters, namespaces, members, types, and built-ins on top of TextMate
- Inlay hints showing inferred types (
: float) for unannotated assignments
- Reference highlighting, outline/breadcrumbs, and code folding
🐞 Step Debugging (DAP)
- Breakpoints and per-bar single-stepping
- Variables, call stack, and scopes
- Expandable series history — inspect the last 64 bars of any
series right in the debugger
- Evaluate strategy-scope names (
close, position_qty, bar_index, …)
📈 One-Click Backtest
Press the play button (Ctrl+F5) to compile and backtest the current strategy, then view the equity curve and risk ratios in a live webview.
⚡ Ships With Native Binaries
The tir compiler, tir-lsp, and tir-dap are bundled as release-built sidecars. Install and start working immediately — no Rust toolchain, no manual setup.
Screenshots
📌 Replace the placeholders below with real screenshots before publishing.
A TIR strategy in action
strategy "Dual Moving Average" {
instrument "rb2401";
param fast: int = 10;
param slow: int = 60;
param risk_pct: float = 2.0;
series close: float confirmed;
series f: float = ta.sma(close, fast);
series s: float = ta.sma(close, slow);
series atr14: float = ta.atr(14);
account p;
on bar closed {
if p.ledger.drift() != 0.0 { return; }
local a14: float? = atr14;
if math.is_na(a14) { return; }
local tick: float = contract.tick_size();
local mult: float = contract.multiplier();
local lot: float = contract.lot_size();
local stop_dist: float = math.round((2.0 * a14) / tick) * tick;
local equity: float = p.asset.equity() ?? 0.0;
local risk_amt: float = equity * (risk_pct / 100.0);
local qty: float = math.floor((risk_amt / (stop_dist * mult)) / lot) * lot;
if ta.crossover(f, s) and p.position.open_count() == 0 and qty >= lot {
p.execution.place_order(
side=buy, type=market, qty=qty, tag="trend",
stop=close - stop_dist
);
}
if ta.crossunder(f, s) and p.position.qty() > 0.0 {
p.execution.close();
}
}
}
What is TIR?
TIR (Trading Intermediate Representation) is a minimalist DSL that describes trading intent — not platform mechanics. One .tirs source compiles to Python, C++20, C#, ATAS, and Pine (reverse), with bitwise-identical (1 ulp) decisions across every backend.
The language is deliberately small: no loops, no mutable containers, and host data (account, quotes, orders) is always explicitly declared. Missing values propagate as na — never silently coerced to 0 — so a strategy's correctness never depends on where the data started.
Requirements
- VS Code 1.85+
- Windows x64 (more platforms coming soon)
Quick Start
- Install the extension.
- Open any
.tirs file — syntax highlighting, completion, and diagnostics activate automatically.
- Press
Ctrl+F5 to backtest and view the equity curve.
- Set a breakpoint and press
F5 to step through the strategy bar by bar.
Extension Settings
| Setting |
Default |
Description |
tir.inlayHints.enabled |
true |
Show inferred type hints on unannotated assignments |
tir.path |
— |
Override the path to the tir compiler binary |
tir.lsp.path |
— |
Override the path to the tir-lsp binary |
tir.dap.path |
— |
Override the path to the tir-dap binary |
Documentation
- Language manual: TIR Language Manual
- Troubleshooting: see the extension's bundled developer guide (
README.dev.md) for implementation details.
License
See LICENSE.
Release Notes
See CHANGELOG.md for the full history. Highlights in v0.5.1: semantic tokens, signature help, inlay hints, expandable series history in the debugger, and code actions for quick fixes.