IDE Setup¶
Set up VS Code for the best sigc development experience.
VS Code Extension¶
The sigc VS Code extension provides:
- Syntax highlighting for
.sigfiles - 25+ code snippets for common patterns
- Compile, Run, and Explain commands
- Language Server Protocol (LSP) integration
- Real-time error diagnostics
- Hover documentation for operators
- Code completion
Installation¶
Step 1: Build the Extension¶
cd /path/to/sigc/editors/vscode
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Package as VSIX
npx @vscode/vsce package
This creates sigc-0.1.0.vsix.
Step 2: Install in VS Code¶
- Open VS Code
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type "Install from VSIX"
- Select
sigc-0.1.0.vsix - Reload VS Code
Step 3: Verify Installation¶
- Create a new file with
.sigextension - You should see syntax highlighting
- Type
signaland press Tab - a snippet should expand
Features¶
Syntax Highlighting¶
The extension highlights:
- Keywords:
data,params,signal,portfolio,fn,macro,emit,let - Operators:
ret,zscore,rank,rolling_mean, etc. - Comments:
//and#style - Strings and numbers
Code Snippets¶
Type a prefix and press Tab to expand:
| Prefix | Expands To |
|---|---|
strategy |
Complete strategy template |
signal |
Signal block |
data |
Data section |
params |
Parameters section |
portfolio |
Portfolio block |
fn |
Function definition |
macro |
Macro definition |
momentum |
Momentum signal template |
meanrev |
Mean reversion template |
rmean |
rolling_mean(${1:x}, ${2:window}) |
rstd |
rolling_std(${1:x}, ${2:window}) |
zs |
zscore(${1:x}) |
win |
winsor(${1:x}, p=${2:0.01}) |
ret |
ret(${1:prices}, ${2:lookback}) |
lag |
lag(${1:x}, ${2:n}) |
ema |
ema(${1:x}, ${2:span}) |
rsi |
rsi(${1:x}, ${2:period}) |
macd |
macd(${1:x}, ${2:fast}, ${3:slow}, ${4:signal}) |
longshort |
long_short(top=${1:0.2}, bottom=${2:0.2}) |
where |
where(${1:cond}, ${2:true_val}, ${3:false_val}) |
Commands¶
Access via Command Palette (Cmd/Ctrl+Shift+P):
| Command | Description |
|---|---|
sigc: Compile |
Compile current file |
sigc: Run |
Run backtest |
sigc: Explain |
Show IR structure |
You can also right-click in the editor for context menu options.
Language Server (LSP)¶
The LSP provides real-time feedback:
Error Diagnostics¶
Errors appear as you type with red underlines:
signal test:
x = ret(prices, lookback)
emit unknownfunction(x) // Error: Unknown function 'unknownfunction'
Hover Documentation¶
Hover over any operator to see its documentation:
zscore(x)
Cross-sectional z-score normalization.
Subtracts mean and divides by standard deviation.
Input: Series (cross-sectional)
Output: Series with mean=0, std=1
Example:
normalized = zscore(returns)
Code Completion¶
Press Ctrl+Space for suggestions:
- Built-in operators
- Variables in scope
- Parameters
- Signals
- Functions and macros
Go to Definition¶
Cmd/Ctrl+Click or F12 on:
- Signal references → jumps to signal definition
- Function calls → jumps to function definition
- Macro invocations → jumps to macro definition
Document Outline¶
View all signals, functions, and macros in the Outline panel (Cmd/Ctrl+Shift+O).
Configuration¶
Extension Settings¶
Open VS Code settings (Cmd+,) and search for "sigc":
| Setting | Default | Description |
|---|---|---|
sigc.binaryPath |
sigc |
Path to sigc binary |
sigc.autoCompile |
true |
Compile on save |
sigc.showInlineHints |
true |
Show type hints |
Recommended VS Code Settings¶
Add to your settings.json:
{
"[sig]": {
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": false,
"editor.wordWrap": "on"
},
"sigc.binaryPath": "/path/to/sigc/target/release/sigc",
"sigc.autoCompile": true
}
Keyboard Shortcuts¶
Add custom keybindings in keybindings.json:
[
{
"key": "cmd+shift+r",
"command": "sigc.run",
"when": "editorLangId == sig"
},
{
"key": "cmd+shift+c",
"command": "sigc.compile",
"when": "editorLangId == sig"
}
]
Troubleshooting¶
Extension Not Loading¶
- Check VS Code's Output panel (
View > Output) and select "sigc" - Ensure the
sigcbinary is in your PATH or configured in settings
No Syntax Highlighting¶
- Verify the file has
.sigextension - Try reloading VS Code (
Cmd+Shift+P→ "Reload Window") - Check that the extension is enabled
LSP Not Working¶
The LSP requires sigc-lsp binary:
# Build the LSP
cd /path/to/sigc
cargo build --release -p sig_lsp
# Verify
./target/release/sig-lsp --version
Configure the path in settings:
Slow Diagnostics¶
For large files, try:
- Increase the diagnostic delay in settings
- Disable
autoCompileand compile manually
Alternative Editors¶
Vim/Neovim¶
Basic syntax highlighting:
" ~/.vim/syntax/sig.vim
syntax match sigKeyword /\<\(data\|params\|signal\|portfolio\|fn\|macro\|emit\|let\)\>/
syntax match sigOperator /\<\(ret\|lag\|zscore\|rank\|rolling_mean\|rolling_std\)\>/
syntax match sigComment /\/\/.*/
syntax match sigComment /#.*/
highlight link sigKeyword Keyword
highlight link sigOperator Function
highlight link sigComment Comment
Sublime Text¶
Create a .sublime-syntax file in your Packages/User directory.
JetBrains IDEs¶
No official plugin yet. Use the TextMate bundle for basic highlighting.
Next Steps¶
- Sample Data - Work with included datasets
- DSL Basics - Learn the language
- Quickstart - Run your first backtest