安装

MAC OS

步骤 1: 安装 Anaconda

-下载 Anaconda 安装程序,Anaconda 包含 Python 编程所需的一切。

-按照 Anaconda 的说明:macOS 图形界面安装,安装最新版本的 Anaconda。

-打开终端并输入:‘which python’,应显示

/Users/your_user_name/opt/anaconda3/bin/python

这意味着你的 Python 解释器路径已指向 Anaconda 的 Python 版本。如果显示类似以下内容

/Users/your_user_name/opt/anaconda3/bin/python

这意味着你仍然使用默认的 Python 路径,你需要修复它并将其指向 anaconda 路径(尝试这篇博客),或者你可以使用 Anaconda Navigator 手动打开终端。

步骤 2: 安装 Homebrew

-打开终端,并确保你已安装 Anaconda。

-安装 Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

步骤 3: 安装 OpenAI

在 Mac 上安装系统软件包需要 Homebrew。安装 Homebrew 后,在终端中运行以下命令

brew install cmake openmpi

步骤 4: 安装 FinRL

由于我们仍在积极更新 FinRL 仓库,请使用 pip 安装 FinRL 的不稳定开发版本

pip install git+https://github.com/AI4Finance-Foundation/FinRL.git

步骤 5: 安装 box2d (如果使用 box2d)

用户可以尝试

brew install swig
pip install box2d-py
pip install box2d
pip install Box2D

如果出现错误 “AttributeError: module ‘_Box2D’ has no attribute ‘RAND_LIMIT_swigconstant’ “,用户可以尝试

pip install box2d box2d-kengz

步骤 6: 运行 FinRL

通过终端下载 FinRL 仓库

git clone https://github.com/AI4Finance-Foundation/FinRL.git

或手动下载

../_images/download_FinRL.png

通过 Anaconda Navigator 打开 Jupyter Notebook,找到你刚下载的 FinRL/tutorials 中的一个股票交易 notebook。你应该能够运行它。

Ubuntu

步骤 1: 安装 Anaconda

请按照这篇博客中的步骤操作

步骤 2: 安装 OpenAI

打开 ubuntu 终端并输入

sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev libgl1-mesa-glx swig

步骤 3: 安装 FinRL

由于我们仍在积极更新 FinRL 仓库,请使用 pip 安装 FinRL 的不稳定开发版本

pip install git+https://github.com/AI4Finance-Foundation/FinRL.git

步骤 4: 安装 box2d (如果使用 box2d)

步骤 5: 运行 FinRL

在终端下载 FinRL 仓库

git clone https://github.com/AI4Finance-Foundation/FinRL.git

在 ubuntu 终端输入 'jupyter notebook' 打开 Jupyter Notebook。

找到你刚下载的 FinRL/tutorials 中的一个股票交易 notebook。你应该能够运行它。

Windows 10

安装准备

  1. 如果在国内使用 YahooFinance,需要 VPN(pyfolio, elegantRL pip 依赖项需要拉取代码,YahooFinance 在中国已停止服务)。否则,请忽略。

  2. python 版本 >=3.7

  3. pip remove zipline,如果你的系统已安装 zipline,zipline 会与 FinRL 冲突。

步骤 1: 克隆 FinRL

git clone https://github.com/AI4Finance-Foundation/FinRL.git

步骤 2: 安装依赖项

cd FinRL
pip install .

步骤 3: 安装 box2d (如果使用 box2d)

步骤 4: 测试 (如果在中国使用 YahooFinance,需要 VPN)

python Stock_NeurIPS2018.py

运行错误提示

如果出现以下输出,请放心,安装仍然成功。

  1. UserWarning: 找不到模块 “zipline.assets”;乘数将不会应用于持仓名义价值。找不到模块 “zipline.assets”;乘数将不会应用’

如果出现以下输出,请确保 VPN 有助于访问 YahooFinance

  1. 下载失败: xxxx: 此日期范围内未找到数据,该股票可能已退市,或数据缺失。

Windows 10 (使用 WSL 安装)

步骤 1: 在 Windows 10 上安装 Ubuntu

请查看此视频了解详细步骤

步骤 2: 安装 Anaconda

请按照这篇博客中的步骤操作

步骤 3: 安装 OpenAI

打开 ubuntu 终端并输入

sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev libgl1-mesa-glx

步骤 4: 安装 FinRL

由于我们仍在积极更新 FinRL 仓库,请使用 pip 安装 FinRL 的不稳定开发版本

pip install git+https://github.com/AI4Finance-Foundation/FinRL.git

步骤 5: 安装 box2d (如果使用 box2d)

步骤 6: 运行 FinRL

在终端下载 FinRL 仓库

git clone https://github.com/AI4Finance-Foundation/FinRL.git

在 ubuntu 终端输入 'jupyter notebook' 打开 Jupyter Notebook。请参阅 jupyter notebook

找到你刚下载的 FinRL/tutorials 中的一个股票交易 notebook。你应该能够运行它。