Skip to content

dedy45/Backtest-LEAN-Local-Controller

Repository files navigation

LEAN CLI Integration - QuantLab

Version: 4.2.0
Status: Local mode ✅ | Cloud mode ⚠️ experimental

Quick Start

cd QuantLab\deployment\lean
lean.bat

demo lean controller : https://lean.bamsbung.id/

Feature Status

Feature Status Notes
Local Backtest ✅ Working Docker + LEAN CLI
Web Dashboard ✅ Working Dash v4.2
CLI Manager ✅ Working Full menu
Report Generator ✅ Working HTML + JSON
Full Logging ✅ Working Real-time capture
Cloud Push/Pull ⚠️ Experimental May have errors
Live Trading ❌ Not Ready -

Directory Structure

QuantLab/deployment/lean/
├── strategies/              # All LEAN strategies
├── data/                    # LEAN-format market data
├── config/                  # YAML configurations
├── docs/                    # Documentation
├── logs/                    # Execution logs
├── lean_ui/                 # Web Dashboard (Dash v4.2)
│   ├── app.py              # Main entry point
│   ├── index.py            # Router
│   ├── theme.py            # Colors/styles
│   ├── data_loader.py      # Data loading
│   ├── pages/              # Page modules
│   │   ├── overview.py     # Strategy cards
│   │   ├── strategies.py   # Comparison table
│   │   ├── trades.py       # Trade history
│   │   ├── controls.py     # CLI operations + logging
│   │   ├── settings.py     # System status
│   │   └── strategy_detail.py
│   ├── components/         # Reusable components
│   └── assets/             # CSS
├── lean_manager.py          # CLI manager
├── lean_report_enhanced.py  # HTML report generator
├── lean.bat                 # Windows launcher
└── lean.json                # LEAN engine config

Web Dashboard

Starting

:: Via menu (recommended)
lean.bat
:: Select [9] Web Dashboard
:: Select [1] Debug Mode or [2] Production Mode

:: Direct command
python -m lean_ui.app --debug --port 8050

URL: http://127.0.0.1:8080

Pages

Page URL Description
Overview / Strategy summary cards
Strategies /strategies Comparison table
Trades /trades Trade history
Controls /controls Run backtest, reports, CLI ops
Settings /settings System status
Detail /strategy/<name> Full metrics

Dashboard Modes

Mode Use Case
Debug Development - hot reload, detailed errors
Production Normal use - optimized

Running Backtests

Via CLI

:: Local mode (recommended)
lean backtest strategies/Momentum_MA --parameter mode local

:: With parameters
lean backtest strategies/EWMAC_Trend --parameter mode local --parameter fast_span 8

Via Web UI

  1. Go to Controls page
  2. Select strategy
  3. Click "Run Backtest"
  4. Watch real-time output with timestamps

Logging Output

[10:30:01] ▶ Launching Docker container...
[10:30:05] ▶ Building algorithm...
[10:30:10] ▶ Running algorithm...
[10:31:00] 📊 Sharpe Ratio: 1.25
[10:31:00] ✓ Algorithm completed

All logs saved to logs/{strategy}_{timestamp}.log

Validation Requirements (QuantLab Law)

Metric Threshold
Sharpe Ratio >= 0.5
PSR >= 50%
Max Drawdown <= 30%
Min Trades >= 50
Win Rate >= 40%

Confidence Levels:

  • HIGH (Green): 5/5 checks pass
  • MEDIUM (Yellow): 3-4/5 pass
  • LOW (Red): <3/5 pass

Requirements

  • Conda environment: lab-quant
  • LEAN CLI: pip install lean
  • Docker Desktop: Running
  • Dash: pip install dash dash-bootstrap-components

Documentation

Known Limitations

  1. Cloud Operations - Push/Pull/Live masih experimental
  2. Config Mounting - LEAN CLI tidak mount config.json, embed di main.py
  3. Real-time UI - Dash callback synchronous, output ditampilkan setelah selesai
  4. Docker Required - LEAN engine berjalan di Docker container

Troubleshooting

Backtest stuck

Check map_files dan factor_files untuk custom symbol.

No data for symbol

Verify data exists: dir data\cfd\oanda\minute\{symbol}\

UI callback errors

Clear cache: del /s /q lean_ui\__pycache__

Docker not running

Start Docker Desktop, then retry.

Referensi

Built with ❤️ for traders who believe in data-driven decisions.

Version 5.1 | 26 December 2025

📞 Support dedy@bamsbung.id

About

Helper lean backtest with UI interactive.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors