A production-ready algorithmic portfolio management system targeting $100,000 with Reg-T margin, implementing a three-sleeve diversified strategy.
DSP-100K implements a systematic approach to portfolio management with three independent return drivers:
| Sleeve | Strategy | Allocation | Volatility Target |
|---|---|---|---|
| Sleeve A | Equity Momentum (Long-Only) + SPY Hedge | Configurable (default 60% NAV) | 5% cap |
| Sleeve B | Cross-Asset Trend ETFs | 30% NAV | 3.5% |
| Sleeve DM | ETF Dual Momentum (asset-class rotation) | Configurable | 8% target (conservative estimator) |
| Sleeve C | SPY Put-Spread Hedge | 1.25% annual budget | N/A |
Note: Sleeve B and Sleeve DM are mutually exclusive in production to avoid overlapping ETF exposure.
- Risk Management: 7% portfolio vol target, 8% cap, 6% DD warning, 10% hard stop
- Double-Strike Protection: Automatic 50% deleveraging after 2 drawdown breaches in 365 days
- Margin Control: 60% utilization cap with what-if checking
- IBKR Integration: Full broker integration via ib_insync
- Execution Window: 09:35-10:15 ET with marketable limit orders
# Clone the repository
git clone https://github.com/your-org/dsp100k.git
cd dsp100k
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Or for development
pip install -e ".[dev]"Copy and modify the default configuration:
cp config/dsp100k.yaml config/my_config.yamlOr use the ready-to-run Dual Momentum config:
dsp --config config/dsp100k_etf_dual_momentum.yaml validate
dsp --config config/dsp100k_etf_dual_momentum.yaml plan
dsp --config config/dsp100k_etf_dual_momentum.yaml runKey configuration sections:
# IBKR connection
ibkr:
host: "127.0.0.1"
port: 7497 # Paper trading
client_id: 100
# Risk settings
risk:
vol_target: 0.07 # 7% portfolio volatility
dd_warning: 0.06 # 6% drawdown warning
dd_hard_stop: 0.10 # 10% hard stop
margin_cap: 0.60 # 60% margin cap
# Execution window
execution:
window_start: "09:35"
window_end: "10:15"# Check configuration and IBKR connectivity
dsp --config config/dsp100k.yaml validate# Run the daily trading cycle
dsp run
# Force execution (even if market closed)
dsp run --force# Show system status and risk metrics
dsp status
# Show current positions
dsp positions
# Show Sleeve B trend signals
dsp signals# Enable debug logging
dsp -v rundsp100k/
├── src/dsp/
│ ├── cli.py # CLI entry point
│ ├── ibkr/ # IBKR client and models
│ ├── data/ # Data fetching and caching
│ ├── sleeves/ # Sleeve B and C implementations
│ ├── risk/ # Risk management
│ ├── execution/ # Order execution and orchestration
│ └── utils/ # Configuration, logging, time utilities
├── config/
│ └── dsp100k.yaml # Default configuration
└── tests/ # Test suite
Large-cap long-only 12-1 momentum with a SPY short hedge to reduce (not neutralize) equity beta:
- Universe: Static, versioned YAML with sectors at
config/universes/sleeve_a_universe.yaml - Signal: 12-month return skipping the most recent month (12-1 convention)
- Selection: Top
n_longnames by momentum (monthly) - Caps: 4% single-name cap, 20% sector gross cap
- Hedge: SPY short capped at 20% of sleeve NAV to reduce beta (default beta limit 0.60)
Non-equity ETF trend-following with multi-horizon signals:
- Signal: 0.25 × 1M + 0.50 × 3M + 0.25 × 12M (skip most recent month)
- Universe: TLT, GLD, USO, UUP, etc. (no equity ETFs)
- Sizing: Inverse-volatility weighting to 3.5% vol target
- Caps: 15% single-name maximum
Monthly rotation across a diversified ETF universe (no single-stock survivorship issues):
- Signal: 12-month return skipping the most recent month (12-1 convention)
- Selection: Hold top
Kassets with momentum > 0, else holdcash_symbol(e.g., SHY) - Sizing: Equal weight across selected assets, then scale by a conservative vol estimate to the target
- Rebalance: First NYSE trading day of month (execution at the configured window)
SPY put spreads for tail protection:
- Structure: 25-delta long put, 10-delta short put
- Budget: 1.25% annual (premium paid)
- Roll: At 10 DTE, target 30-45 DTE
- Sizing: Budget-based, max 5 spreads
| Control | Threshold | Action |
|---|---|---|
| Portfolio Vol | > 8% | Scale positions to hit cap |
| Drawdown | > 6% | Strike 1 logged |
| Drawdown | > 10% | HALT TRADING - liquidate to cash |
| Double Strike | 2 in 365 days | 50% exposure for 30 days |
| Margin | > 60% | Block new exposure |
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src tests
isort src tests
# Type checking
mypy src
# Lint
ruff src testsBefore running with real capital:
- Run paper trading for minimum 2 weeks
- Verify fill rates and slippage match expectations
- Confirm EOD flat rates > 95%
- Test drawdown and circuit breaker behavior
- Verify option chain fetching works correctly
- Review audit logs for any anomalies
This software is for educational and informational purposes only. It is not financial advice. Trading involves substantial risk of loss. Past performance does not guarantee future results. Use at your own risk.
MIT License - see LICENSE file for details.