Token导航 LogoToken导航TokenDH.com
运维敏感数据clawhub未标认证来源可访问clear审计通过

lean-engine精益发动机

Agent Skill

lean-engine 用于辅助前端页面、组件、样式和交互逻辑开发,适合在 OpenClaw 中需要维护前端项目、生成组件或检查界面实现时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

8,232

周安装

343

GitHub Stars

1

下载量

2,744
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:lean-engine(精益发动机)
来源仓库:https://github.com/cylqqqcyl/lean-engine
安装命令:
openclaw skills install lean-engine
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install lean-engine

简介

运行 QuantConnect LEAN 回测引擎管理股票算法开发。

  • 支持美国股票市场策略回溯测试与分析。
  • 适用于量化交易系统开发与维护任务。lean-engine 属于运维类 Skill,可作为该场景下的辅助能力补充。
  • 安装命令:openclaw skills install lean-engine。
  • 注意金融数据访问许可与计算资源消耗问题。

SKILL.md

name
lean
description
Run QuantConnect LEAN backtests and manage US equity algorithm development. Use when asked to backtest a trading strategy, run a LEAN algorithm, analyze backtest results, download market data, or deploy to Interactive Brokers TWS. Covers algorithm creation, data management, config editing, and result analysis.
metadata

LEAN Engine — QuantConnect Algorithmic Trading

Prerequisites & Setup

Required Environment Variables

VariablePurposeExample
LEAN_ROOTPath to cloned LEAN repository/home/user/lean
DOTNET_ROOTPath to .NET SDK installation/home/user/.dotnet
PYTHONNET_PYDLLPath to Python shared library (required by LEAN's pythonnet)$LEAN_ROOT/.libs/libpython3.11.so.1.0

All three must be set before using this skill. Add to your shell profile:

export LEAN_ROOT="$HOME/lean"
export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$PATH:$DOTNET_ROOT"
export PYTHONNET_PYDLL="$LEAN_ROOT/.libs/libpython3.11.so.1.0"
Note: LEAN bundles its own Python shared library in $LEAN_ROOT/.libs/. If you built LEAN from source, the library should be there after dotnet build. If not, install libpython3.11-dev and point PYTHONNET_PYDLL to your system's libpython3.11.so.

First-Time Setup

  1. Install .NET 8 SDK:
   # Linux/macOS
   wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
   chmod +x dotnet-install.sh
   ./dotnet-install.sh --channel 8.0
   export DOTNET_ROOT="$HOME/.dotnet"
   export PATH="$PATH:$DOTNET_ROOT"
  1. Clone and build LEAN:
   git clone https://github.com/QuantConnect/Lean.git "$LEAN_ROOT"
   cd "$LEAN_ROOT"
   dotnet build QuantConnect.Lean.sln -c Debug
  1. Download initial market data:
   pip install yfinance pandas
   python3 {baseDir}/scripts/download_us_universe.py --symbols sp500 --start 2020-01-01 --data-dir "$LEAN_ROOT/Data"
  1. Verify setup:
   ls "$LEAN_ROOT/Data/equity/usa/daily/"  # Should list .zip files
   ls "$LEAN_ROOT/Launcher/bin/Debug/"      # Should contain QuantConnect.Lean.Launcher.dll

Environment

  • LEAN source: $LEAN_ROOT/
  • Launcher (pre-built): $LEAN_ROOT/Launcher/bin/Debug/
  • Config: $LEAN_ROOT/Launcher/config.json
  • Python algos: $LEAN_ROOT/Algorithm.Python/
  • Market data: $LEAN_ROOT/Data/
  • dotnet: $DOTNET_ROOT/dotnet (add to PATH: export PATH="$PATH:$DOTNET_ROOT")

Quick Reference

Run a Backtest

  1. Place algorithm in $LEAN_ROOT/Algorithm.Python/YourAlgo.py
  2. Edit config to point to it:
   # Update config.json — set these fields:
   # "algorithm-type-name": "YourClassName"
   # "algorithm-language": "Python"
   # "algorithm-location": "../../../Algorithm.Python/YourAlgo.py"
  1. Run:
   export PATH="$PATH:$DOTNET_ROOT"
   cd "$LEAN_ROOT/Launcher/bin/Debug"
   dotnet QuantConnect.Lean.Launcher.dll
  1. Results appear in stdout + $LEAN_ROOT/Results/

Or use the helper script:

bash {baseDir}/scripts/run_backtest.sh YourClassName YourAlgo.py

Config Editing

Edit $LEAN_ROOT/Launcher/config.json with these key fields:

FieldPurposeExample
algorithm-type-namePython class name"MyStrategy"
algorithm-languageLanguage"Python"
algorithm-locationPath to .py file"../../../Algorithm.Python/MyStrategy.py"
data-folderMarket data path"../Data/"
environmentMode"backtesting" or "live-interactive"

For IB live trading, set environment to "live-interactive" and configure the ib-* fields (account, username, password, host, port, trading-mode).

Data Management

Check available data:

ls "$LEAN_ROOT/Data/equity/usa/daily/"

Data format: ZIP files containing CSV. Each line: YYYYMMDD HH:MM,Open*10000,High*10000,Low*10000,Close*10000,Volume

Prices are stored as integers (multiply by 10000). LEAN handles conversion internally.

Download more data:

python3 {baseDir}/scripts/download_us_universe.py --symbols sp500 --data-dir "$LEAN_ROOT/Data"

See {baseDir}/references/data-download.md for additional methods to expand the universe.

Writing Algorithms

LEAN Python algorithms inherit from QCAlgorithm:

from AlgorithmImports import *

class MyAlgo(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2024, 1, 1)
        self.SetEndDate(2025, 1, 1)
        self.SetCash(100_000)
        self.AddEquity("SPY", Resolution.Daily)
        self.SetBenchmark("SPY")
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage,
                               AccountType.Margin)

    def OnData(self, data):
        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1.0)

Key API patterns:

  • self.History(symbol, periods, resolution) — get historical bars
  • self.SetHoldings(symbol, weight) — target portfolio weight
  • self.Liquidate(symbol) — close position
  • self.AddUniverse(coarse_fn, fine_fn) — dynamic universe selection
  • self.Schedule.On(date_rule, time_rule, action) — scheduled events
  • self.Debug(msg) — log output

Analyzing Results

After a backtest run, check:

ls "$LEAN_ROOT/Results/"
# Key files: *-log.txt, *-order-log.txt, *.json (statistics)

Rebuild LEAN (if source changes)

export PATH="$PATH:$DOTNET_ROOT"
cd "$LEAN_ROOT"
dotnet build QuantConnect.Lean.sln -c Debug

Security Notes

Config.json Safety

The run_backtest.sh script does NOT modify your original config.json. Instead, it:

  1. Reads the original config as a template (read-only)
  2. Creates a separate config.backtest.json with only algorithm fields changed (class name, file path, language, environment=backtesting)
  3. Temporarily swaps it in for the LEAN run, then restores the original via a trap cleanup handler

The configure_algo.py helper performs the field substitution in an isolated output file. Your original config — including any Interactive Brokers credentials for live trading — is never modified.

Modified fields (in the temp copy only):

  • algorithm-type-name — set to the requested class name
  • algorithm-language — set to Python
  • algorithm-location — set to the requested .py file path
  • environment — set to backtesting

Network Access

The setup instructions involve network downloads:

  • git clone from GitHub (QuantConnect/Lean repository)
  • dotnet build may restore NuGet packages
  • pip install yfinance pandas installs Python packages from PyPI
  • download_us_universe.py fetches market data from Yahoo Finance

All downloads are from well-known public sources. For maximum isolation, run setup in a container or VM.

Environment Variables

This skill requires the following environment variables at runtime:

  • LEAN_ROOT — path to your cloned LEAN repository
  • DOTNET_ROOT — path to your .NET SDK installation
  • PYTHONNET_PYDLL — path to Python shared library (auto-detected from $LEAN_ROOT/.libs/ if not set)

These are declared in the skill metadata and must be set before use.

Troubleshooting

  • "No data files found" → Check data-folder in config.json points to correct path
  • Python import errors → LEAN bundles its own Python; check python-venv config if using custom packages
  • Slow backtest → Reduce universe size or date range; check Resolution (Minute >> Daily)
  • IB connection issues → Verify TWS/Gateway is running, port matches config (default 4002 for Gateway)
  • LEAN_ROOT not set → Add export LEAN_ROOT="$HOME/lean" to your shell profile
  • dotnet not found → Add export PATH="$PATH:$DOTNET_ROOT" to your shell profile
  • Runtime.PythonDLL was not set → Set PYTHONNET_PYDLL to the Python shared library path (see env var table above)

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

77.1%
按下载量换算2,116

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills