Professional quantitative trading DSL for strategy development and execution
Project description
CroweLang - Quantitative Trading DSL
CroweLang is a domain-specific language designed for quantitative trading, strategy research, execution, and risk management. It provides a high-level, expressive syntax for building trading algorithms while compiling to efficient Python, TypeScript, C++, or Rust code.
๐ Quick Start
# Install CroweLang compiler
npm install -g crowelang
# Compile a strategy
crowelang compile strategy.crowe --target python
# Run backtest
crowelang backtest strategy.crowe --start 2022-01-01 --end 2023-12-31
โจ Language Features
Strategy Definition
strategy MeanReversion {
params {
lookback: int = 20
zscore_entry: float = 2.0
position_size: float = 0.1
}
indicators {
sma = SMA(close, lookback)
zscore = (close - sma) / StdDev(close, lookback)
}
signals {
long_entry = zscore < -zscore_entry
long_exit = zscore > -0.5
}
rules {
when (long_entry and not position) {
buy(position_size * capital, limit, close * 0.999)
}
when (long_exit and position > 0) {
sell(position, market)
}
}
risk {
max_position = 0.25 * capital
stop_loss = 0.02
daily_var_limit = 0.03
}
}
Market Data Types
data Bar {
symbol: string
timestamp: datetime
open: float
high: float
low: float
close: float
volume: int
}
data OrderBook {
symbol: string
timestamp: datetime
bids: Level[]
asks: Level[]
spread: float = asks[0].price - bids[0].price
}
Built-in Indicators
indicator RSI(series: float[], period: int = 14) -> float {
gains = [max(0, series[i] - series[i-1]) for i in 1..len(series)]
losses = [max(0, series[i-1] - series[i]) for i in 1..len(series)]
rs = avg(gains[-period:]) / avg(losses[-period:])
return 100 - (100 / (1 + rs))
}
๐ ๏ธ Development Phases
Phase 0: Foundation (Weeks 0-4) โ
- Core language parser and AST
- Basic backtest engine
- VS Code extension with syntax highlighting
- Example strategies (mean reversion, market making)
- Mock broker connections
Target KPI: 1k VS Code extension installs, 3 early fund user interviews
Phase 1: Pro Tools (Months 1-3)
- Event-driven backtester
- Real broker connections (IBKR, Alpaca, Polygon)
- Portfolio optimization engine
- Risk analytics dashboard
- Strategy cookbook and templates
Pricing:
- Indie: $149/month
- Fund (โค$100M AUM): $24k/year
- Enterprise (>$100M): Custom pricing
Target KPI: 5 paid funds, $250k ARR
Phase 2: Production (Months 4-12)
- Live execution engine
- Co-location support
- Smart order routing
- Compliance and audit logs
- Alternative data ingestion
Add-ons:
- Routing + co-location: $50k-$150k/year
- Alt-data feeds: $25k-$100k/year
Target KPI: 15 funds, 2 HFT pilots, $1-3M ARR
Phase 3: Enterprise (Years 1-3)
- Multi-venue execution
- Cross-asset support (options, futures, forex, crypto)
- Regulatory compliance (MiFID II, SEC reporting)
- Strategy marketplace with revenue share
- Certification program
Target KPI: 50+ funds, $5-20M ARR, zero critical audit incidents
๐ฏ Compilation Targets
| Target | Use Case | Performance | Libraries |
|---|---|---|---|
| Python | Research, backtesting | Fast development | pandas, numpy, scipy |
| TypeScript | Web dashboards, APIs | Good balance | Node.js ecosystem |
| C++ | Low-latency execution | Ultra-high performance | Boost, Intel TBB |
| Rust | Safety-critical systems | High performance + safety | tokio, serde |
๐ฆ Standard Library
Data Providers
- Polygon.io: Real-time and historical market data
- Interactive Brokers: Professional trading platform
- Alpaca: Commission-free stock trading API
- Binance: Cryptocurrency exchange
- Yahoo Finance: Free historical data
Technical Indicators
- Trend: SMA, EMA, MACD, ADX, Parabolic SAR
- Momentum: RSI, Stochastic, Williams %R, ROC
- Volatility: Bollinger Bands, ATR, Standard Deviation
- Volume: OBV, VWAP, Accumulation/Distribution
Risk Models
- Value at Risk: Historical, Monte Carlo, Parametric
- Factor Models: Fama-French, BARRA, Custom
- Stress Testing: Historical scenarios, Monte Carlo
- Portfolio Optimization: Mean-variance, Black-Litterman
Execution Algorithms
- TWAP: Time-weighted average price
- VWAP: Volume-weighted average price
- POV: Percent of volume
- Implementation Shortfall: Minimize market impact
- Iceberg: Hide large order size
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CroweLang DSL โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Strategy Code (.crowe files) โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Compiler โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Lexer โ Parser โ AST โ Validator โ Code Generator โ
โโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโ
โ โ โ โ
โโโโโโโผโโ โโโโโผโโโโ โโโผโโโ โโโโโโผโโโโโ
โPython โ โTypeScriptโ โC++ โ โ Rust โ
โโโโโโโโโ โโโโโโโโโ โโโโโโ โโโโโโโโโโโ
โ โ โ โ
โโโโโโโผโโ โโโโโผโโโโ โโโผโโโโโโโ โโโโโโโโผโโโโโโโ
โPandas โ โNode.jsโ โLow โ โSafe Systems โ
โNumPy โ โReact โ โLatency โ โHigh Perf โ
โโโโโโโโโ โโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโโโโ
๐ง Installation
VS Code Extension
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "CroweLang"
- Install the extension
Compiler
# Via npm
npm install -g crowelang
# Via pip (Python target)
pip install crowelang
# From source
git clone https://github.com/croweai/crowelang.git
cd crowelang
npm install
npm run build
๐ Documentation
๐ค Contributing
We welcome contributions! See our Contributing Guide for details.
๐ Performance Benchmarks
| Strategy Type | Python | TypeScript | C++ | Rust |
|---|---|---|---|---|
| Mean Reversion | 2.1ms | 1.8ms | 0.3ms | 0.4ms |
| Market Making | 5.2ms | 4.1ms | 0.8ms | 0.9ms |
| Pairs Trading | 3.7ms | 2.9ms | 0.5ms | 0.6ms |
Benchmarks: 1M bars, 10 strategies, Intel i7-12700K
๐ Success Stories
"CroweLang reduced our strategy development time by 70% while improving backtest reliability. The risk management features are exactly what we needed."
โ Jane Chen, CTO at Meridian Capital
"We deployed 15 market making strategies in production using CroweLang's C++ target. Rock solid performance with sub-microsecond latency."
โ Alex Rodriguez, Head of Trading at Quantum Dynamics
๐ Security & Compliance
- SOC 2 Type II certified
- ISO 27001 compliant
- MiFID II reporting ready
- SEC audit trail support
- End-to-end encryption for all data
๐ Roadmap
See our detailed Product Roadmap for upcoming features and timelines.
๐ License
CroweLang is open-source under the MIT License. Commercial runtime and enterprise features require a separate license.
๐ Community
๐ Commercial Support
For enterprise support, training, or custom development:
- Email: enterprise@crowelang.com
- Website: https://crowelang.com
- Calendar: Book a Demo
Building the future of quantitative trading, one strategy at a time. ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crowelang-1.0.0.tar.gz.
File metadata
- Download URL: crowelang-1.0.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
802ba61e32a4df0d29dc6d8e2e420ae84d73083cbcbbc4986651cb04c0687ece
|
|
| MD5 |
0365dc6e3efa98fa7fb52114eef3e54e
|
|
| BLAKE2b-256 |
8b11b88e5a22c17f62816d3dda8c35de6cae4178a3ad7c358d7c939a979a853a
|
File details
Details for the file crowelang-1.0.0-py3-none-any.whl.
File metadata
- Download URL: crowelang-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d17dd1defb15e1e7d0327540eac6865e2f9623193e6d67703a8f887321fa07bf
|
|
| MD5 |
479182db302e26bd699747acd778c76d
|
|
| BLAKE2b-256 |
35371141a49b6aef7dbf698c149c15ae0b50f8efc02db01d5db5cd8b6da87118
|