Installation - Loren1166/NautilusTrader- GitHub Wiki

Installation 安装指南

NautilusTrader is tested and supported for Python 3.10-3.12 on the following 64-bit platforms:
NautilusTrader 已经在以下 64 位平台上针对 Python 3.10-3.12 进行了测试和支持:

| Operating System | Supported Versions | CPU Architecture |

操作系统 支持的版本 CPU 架构
Linux (Ubuntu) 20.04 或更高版本 x86_64
macOS 14 或更高版本 ARM64
Windows Server 2022 或更高版本 x86_64

tip 提示
We recommend running the platform with the latest stable version of Python, and in a virtual environment to isolate the dependencies.
我们建议使用最新稳定版本的 Python,并在虚拟环境中运行平台,以隔离依赖项。

From PyPI 从 PyPI 安装

To install the latest binary wheel (or sdist package) from PyPI using Python's pip package manager:
要使用 Python 的 pip 包管理器从 PyPI 安装最新的二进制轮子包(或 sdist 源代码包):

pip install -U nautilus_trader

Extras 可选依赖项

Install optional dependencies as 'extras' for specific integrations:
安装特定集成的可选依赖项作为 "extras":

  • betfair: Betfair adapter (integration) dependencies
    Betfair 适配器(集成)依赖项
  • docker: Needed for Docker when using the IB gateway (with the Interactive Brokers adapter)
    使用 IB 网关(与 Interactive Brokers 适配器一起)时需要 Docker
  • dydx: dYdX adapter (integration) dependencies
    dYdX 适配器(集成)依赖项
  • ib: Interactive Brokers adapter (integration) dependencies
    Interactive Brokers 适配器(集成)依赖项

To install with specific extras using pip:
使用 pip 安装特定的 extras:

pip install -U "nautilus_trader[docker,ib]"

From Source 从源码安装

Installation from source requires the Python.h header file, which is included in development releases such as python-dev. You'll also need the latest stable rustc and cargo to compile the Rust libraries.
从源码安装需要 Python.h 头文件,它包含在 python-dev 等开发版中。您还需要最新的稳定版本 rustccargo 来编译 Rust 库。

For MacBook Pro M1/M2, make sure your Python installed using pyenv is configured with --enable-shared:
对于 MacBook Pro M1/M2,确保您使用 pyenv 安装的 Python 配置了 --enable-shared

PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install <python_version>

See https://pyo3.rs/latest/getting_started#virtualenvs.
参考:https://pyo3.rs/latest/getting_started#virtualenvs。

It's possible to install from source using pip if you first install the build dependencies as specified in the pyproject.toml. We highly recommend installing using poetry as below.
如果您先安装 pyproject.toml 中指定的构建依赖项,也可以使用 pip 从源码安装。我们强烈推荐使用如下方式的 poetry 进行安装。

Install rustup (the Rust toolchain installer):

安装 rustup(Rust 工具链安装程序):

Linux and macOS:

curl https://sh.rustup.rs -sSf | sh

Windows:

Download and install rustup-init.exe
下载并安装 rustup-init.exe

Install "Desktop development with C++" with Build Tools for Visual Studio 2019
通过 Visual Studio 2019 的构建工具安装“C++ 桌面开发”

Verify (any system): from a terminal session run:
验证(任何系统):在终端会话中运行:

rustc --version

Enable cargo in the current shell

在当前 shell 中启用 cargo:

Linux and macOS:

source $HOME/.cargo/env

Windows:

Start a new PowerShell
启动新的 PowerShell

Install clang (a C language frontend for LLVM):

安装 clang(LLVM 的 C 语言前端):

Linux:

sudo apt-get install clang

Windows:

Add Clang to your Build Tools for Visual Studio 2019:
将 Clang 添加到您的 Visual Studio 2019 构建工具中:

Start | Visual Studio Installer | Modify | C++ Clang tools for Windows (12.0.0 - x64…) = checked | Modify
开始 | Visual Studio 安装程序 | 修改 | 为 Windows 提供的 C++ Clang 工具(12.0.0 - x64…)= 选中 | 修改

Enable clang in the current shell:
在当前 shell 中启用 clang:

[System.Environment]::SetEnvironmentVariable('path', "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\Llvm\x64\bin\;" + $env:Path,"User")

Verify (any system): from a terminal session run:
验证(任何系统):在终端会话中运行:

clang --version

Install poetry (or follow the installation guide on their site):

安装 poetry(或遵循其网站上的安装指南):

curl -sSL https://install.python-poetry.org | python3 -

Clone the source with git, and install from the project's root directory:
使用 git 克隆源码,并从项目的根目录安装:

git clone https://github.com/nautechsystems/nautilus_trader
cd nautilus_trader
poetry install --only main --all-extras

From GitHub Release 从 GitHub 发布版安装

To install a binary wheel from GitHub, first navigate to the latest release. Download the appropriate .whl for your operating system and Python version, then run:
要从 GitHub 安装二进制轮子包,首先导航到最新的发布版本。下载适用于您的操作系统和 Python 版本的 .whl 文件,然后运行:

pip install <file-name>.whl
⚠️ **GitHub.com Fallback** ⚠️