Skip to main content

Professional quantitative trading DSL for strategy development and execution

Project description

CroweLang - Quantitative Trading DSL

CroweLang Logo

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

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "CroweLang"
  4. 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:


Building the future of quantitative trading, one strategy at a time. ๐Ÿš€

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crowelang-1.0.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crowelang-1.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

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

Hashes for crowelang-1.0.0.tar.gz
Algorithm Hash digest
SHA256 802ba61e32a4df0d29dc6d8e2e420ae84d73083cbcbbc4986651cb04c0687ece
MD5 0365dc6e3efa98fa7fb52114eef3e54e
BLAKE2b-256 8b11b88e5a22c17f62816d3dda8c35de6cae4178a3ad7c358d7c939a979a853a

See more details on using hashes here.

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

Hashes for crowelang-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d17dd1defb15e1e7d0327540eac6865e2f9623193e6d67703a8f887321fa07bf
MD5 479182db302e26bd699747acd778c76d
BLAKE2b-256 35371141a49b6aef7dbf698c149c15ae0b50f8efc02db01d5db5cd8b6da87118

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page