![Lean CLI](http://cdn.quantconnect.com.s3.us-east-1.amazonaws.com/i/github/lean-cli-splash.png)
# QuantConnect Lean CLI
[![Build Status](https://github.com/QuantConnect/lean-cli/workflows/Build/badge.svg)](https://github.com/QuantConnect/lean-cli/actions?query=workflow%3ABuild)
[![PyPI Version](https://img.shields.io/pypi/v/lean)](https://pypi.org/project/lean/)
[![Project Status](https://img.shields.io/pypi/status/lean)](https://pypi.org/project/lean/)
The Lean CLI is a cross-platform CLI aimed at making it easier to develop with the LEAN engine locally and in the cloud.
Visit the [documentation website](https://www.quantconnect.com/docs/v2/lean-cli/getting-started/lean-cli) for comprehensive and up-to-date documentation.
## Highlights
- [Project scaffolding](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/project-management)
- [Local autocomplete](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/local-autocomplete)
- [Local data downloading](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/local-data/downloading-from-quantconnect)
- [Local backtesting](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/backtesting/running-backtests#02-Running-local-backtests)
- [Local debugging](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/backtesting/debugging-local-backtests)
- [Local research environment](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/research)
- [Local optimization](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/optimization/local-optimizations)
- [Local live trading](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/live-trading/local-live-trading)
- [Local backtest report creation](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/generating-reports)
- [Cloud synchronization](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/cloud-synchronization)
- [Cloud backtesting](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/backtesting/running-backtests#03-Running-cloud-backtests)
- [Cloud optimization](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/optimization/cloud-optimizations)
- [Cloud live trading](https://www.quantconnect.com/docs/v2/lean-cli/tutorials/live-trading/cloud-live-trading)
## Installation
The CLI can be installed and updated by running `pip install --upgrade lean`.
Note that many commands in the CLI require Docker to run. See [Get Docker](https://docs.docker.com/get-docker/) for instructions on how to install Docker for your operating system.
After installing the CLI, open a terminal in an empty directory and run `lean init`. This command downloads the latest configuration file and sample data from the [QuantConnect/Lean](https://github.com/QuantConnect/Lean) repository. We recommend running all Lean CLI commands in the same directory `lean init` was ran in.
## Usage
The Lean CLI supports multiple workflows. The examples below serve as a starting point, you're free to mix local and cloud features in any way you'd like.
A cloud-focused workflow (local development, cloud execution) with the CLI may look like this:
1. Open a terminal in the directory you ran `lean init` in.
2. Run `lean cloud pull` to pull remotely changed files.
3. Start programming locally and run backtests in the cloud with `lean cloud backtest "Project Name" --open --push` whenever there is something to backtest. The `--open` flag means that the backtest results will be opened in the browser when done, while the `--push` flag means that local changes are pushed to the cloud before running the backtest.
4. Whenever you want to create a new project, run `lean create-project "Project Name"` and `lean cloud push --project "Project Name"` to create a new project containing some basic code and to push it to the cloud.
5. When you're finished for the moment, run `lean cloud push` to push all locally changed files to the cloud.
A locally-focused workflow (local development, local execution) with the CLI may look like this:
1. Open a terminal in the directory you ran `lean init` in.
2. Run `lean create-project "Project Name"` to create a new project with some basic code to get you started.
3. Work on your strategy in `./Project Name`.
4. Run `lean research "Project Name"` to start a Jupyter Lab session to perform research in.
5. Run `lean backtest "Project Name"` to run a backtest whenever there's something to test. This runs your strategy in a Docker container containing the same packages as the ones used on QuantConnect.com, but with your own data.
## Commands
*Note: the readme only contains the `--help` text of all commands. Visit the [documentation website](https://www.quantconnect.com/docs/v2/lean-cli/getting-started/lean-cli) for more comprehensive documentation.*
<!-- commands start -->
- [`lean backtest`](#lean-backtest)
- [`lean cloud backtest`](#lean-cloud-backtest)
- [`lean cloud live`](#lean-cloud-live)
- [`lean cloud optimize`](#lean-cloud-optimize)
- [`lean cloud pull`](#lean-cloud-pull)
- [`lean cloud push`](#lean-cloud-push)
- [`lean config get`](#lean-config-get)
- [`lean config list`](#lean-config-list)
- [`lean config set`](#lean-config-set)
- [`lean create-project`](#lean-create-project)
- [`lean data download cfd`](#lean-data-download-cfd)
- [`lean data download forex`](#lean-data-download-forex)
- [`lean data generate`](#lean-data-generate)
- [`lean init`](#lean-init)
- [`lean live`](#lean-live)
- [`lean login`](#lean-login)
- [`lean logout`](#lean-logout)
- [`lean optimize`](#lean-optimize)
- [`lean report`](#lean-report)
- [`lean research`](#lean-research)
### `lean backtest`
Backtest a project locally using Docker.
```
Usage: lean backtest [OPTIONS] PROJECT
Backtest a project locally using Docker.
If PROJECT is a directory, the algorithm in the main.py or Main.cs file inside it will be executed.
If PROJECT is a file, the algorithm in the specified file will be executed.
Go to the following url to learn how to debug backtests locally using the Lean CLI:
https://www.quantconnect.com/docs/v2/lean-cli/tutorials/backtesting/debugging-local-backtests
Options:
--output DIRECTORY Directory to store results in (defaults to PROJECT/backtests/TIMESTAMP)
--debug [pycharm|ptvsd|mono] Enable a certain debugging method (see --help for more information)
--update Pull the selected LEAN engine version before running the backtest
--version TEXT The LEAN engine version to run (defaults to the latest installed version)
--lean-config FILE The Lean configuration file that should be used (defaults to the nearest lean.json)
--verbose Enable debug logging
--help Show this message and exit.
```
_See code: [lean/commands/backtest.py](lean/commands/backtest.py)_
### `lean cloud backtest`
Backtest a project in the cloud.
```
Usage: lean cloud backtest [OPTIONS] PROJECT
Backtest a project in the cloud.
PROJECT must be the name or id of the project to run a backtest for.
If the project that has to be backtested has been pulled to the local drive with `lean cloud pull` it is possible to
use the --push option to push local modifications to the cloud before running the backtest.
Options:
--name TEXT The name of the backtest (a random one is generated if not specified)
--push Push local modifications to the cloud before running the backtest
--open Automatically open the results in the browser when the backtest is finished
--verbose Enable debug logging
--help Show this message and exit.
```
_See code: [lean/commands/cloud/backtest.py](lean/commands/cloud/backtest.py)_
### `lean cloud live`
Start live trading for a project in the cloud.
```
Usage: lean cloud live [OPTIONS] PROJECT
Start live trading for a project in the cloud.
An interactive prompt will be shown to configure the deployment.
PROJECT must be the name or the id of the project to start live trading for.
If the project t
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:lean-0.1.39.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
lean-0.1.39.tar.gz (86个子文件)
lean-0.1.39
PKG-INFO 31KB
lean
constants.py 2KB
models
options.py 4KB
logger.py 907B
errors.py 2KB
pydantic.py 1KB
__init__.py 664B
config.py 950B
brokerages.py 9KB
api.py 10KB
optimizer.py 2KB
data.py 2KB
click.py 6KB
main.py 2KB
commands
report.py 9KB
config
get.py 2KB
list.py 2KB
__init__.py 1KB
set.py 1KB
create_project.py 9KB
data
generate.py 6KB
__init__.py 1KB
download
cfd.py 3KB
forex.py 4KB
__init__.py 1KB
init.py 6KB
research.py 4KB
logout.py 900B
backtest.py 4KB
live.py 9KB
__init__.py 2KB
optimize.py 7KB
login.py 2KB
cloud
push.py 2KB
pull.py 2KB
backtest.py 3KB
live.py 9KB
__init__.py 1KB
optimize.py 9KB
__init__.py 914B
container.py 4KB
components
config
storage.py 3KB
lean_config_manager.py 9KB
project_config_manager.py 1KB
__init__.py 664B
cli_config_manager.py 3KB
optimizer_config_manager.py 8KB
api
compile_client.py 2KB
account_client.py 2KB
project_client.py 5KB
data_client.py 2KB
node_client.py 3KB
__init__.py 664B
api_client.py 7KB
optimization_client.py 8KB
backtest_client.py 4KB
live_client.py 5KB
file_client.py 3KB
__init__.py 664B
docker
csharp_compiler.py 5KB
__init__.py 664B
lean_runner.py 8KB
docker_manager.py 6KB
util
project_manager.py 18KB
path_validator.py 2KB
logger.py 3KB
__init__.py 664B
task_manager.py 4KB
update_manager.py 5KB
name_generator.py 3KB
market_hours_database.py 3KB
cloud
pull_manager.py 9KB
data_downloader.py 8KB
cloud_runner.py 8KB
push_manager.py 7KB
__init__.py 664B
cloud_project_manager.py 5KB
setup.cfg 38B
lean.egg-info
PKG-INFO 31KB
requires.txt 162B
SOURCES.txt 3KB
entry_points.txt 41B
top_level.txt 5B
dependency_links.txt 1B
setup.py 2KB
README.md 25KB
共 86 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功