Version History [click to expand]
* 2020-12-14
Upgraded to **Pytorch** with stable-baselines3; Remove tensorflow 1.0 at this moment, under development to support tensorflow 2.0
* 2020-11-27
0.1: Beta version with tensorflow 1.5
# Installation:
## Docker Installation
### Option 1: Use the bin
```bash
# grant access to execute scripting (read it, it's harmless)
$ sudo chmod -R 777 docker/bin
# build the container!
$ ./docker/bin/build_container.sh
# start notebook on port 8887!
$ ./docker/bin/start_notebook.sh
# proceed to party!
```
### Option 2: Do it manually
Build the container:
```bash
$ docker build -f docker/Dockerfile -t finrl docker/
```
Start the container:
```bash
$ docker run -it --rm -v ${PWD}:/home -p 8888:8888 finrl
```
Note: The default container run starts jupyter lab in the root directory, allowing you to run scripts, notebooks, etc.
## Bare-metal installation (More difficult)
Clone this repository:
```shell
git clone https://github.com/AI4Finance-LLC/FinRL-Library.git
```
Install the unstable development version of FinRL:
```shell
pip install git+https://github.com/AI4Finance-LLC/FinRL-Library.git
```
## Prerequisites
For [OpenAI Baselines](https://github.com/openai/baselines), you'll need system packages CMake, OpenMPI and zlib. Those can be installed as follows:
#### Ubuntu
```bash
sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev libgl1-mesa-glx
```
#### Mac OS X
Installation of system packages on Mac requires [Homebrew](https://brew.sh). With Homebrew installed, run the following:
```bash
brew install cmake openmpi
```
#### Windows 10
To install stable-baselines on Windows, please look at the [documentation](https://stable-baselines3.readthedocs.io/en/master/guide/install.html#prerequisites).
#### Create and Activate Python Virtual-Environment (Optional but highly recommended)
cd into this repository:
```bash
cd FinRL-Library
```
Under folder /FinRL-Library, create a Python virtual-environment:
```bash
pip install virtualenv
```
Virtualenvs are essentially folders that have copies of python executable and all python packages.
**Virtualenvs can also avoid packages conflicts.**
Create a virtualenv **venv** under folder /FinRL-Library
```bash
virtualenv -p python3 venv
```
To activate a virtualenv:
```
source venv/bin/activate
```
To activate a virtualenv on windows:
```
venv\Scripts\activate
```
## Dependencies
The script has been tested running under **Python >= 3.6.0**, with the following packages installed:
```shell
pip install -r requirements.txt
```
#### Stable-Baselines3 using Pytorch
#### About [Stable-Baselines 3](https://github.com/DLR-RM/stable-baselines3)
Stable-Baselines3 is a set of improved implementations of reinforcement learning algorithms in PyTorch. It is the next major version of Stable Baselines. If you have questions regarding Stable-baselines package, please refer to [Stable-baselines3 installation guide](https://stable-baselines3.readthedocs.io/en/master/guide/install.html). Install the Stable Baselines package using pip:
```
pip install stable-baselines3[extra]
```
A migration guide from SB2 to SB3 can be found in the [documentation](https://stable-baselines3.readthedocs.io/en/master/guide/migration.html).
#### Stable-Baselines using Tensorflow 2.0
Still [Under Development](https://github.com/Stable-Baselines-Team/stable-baselines-tf2)
### Run
```shell
python main.py --mode=train
```
### Backtesting
Use Quantopian's [pyfolio package](https://github.com/quantopian/pyfolio) to do the backtesting.
### Data
The stock data we use is pulled from Yahoo Finance API.
(The following time line is used in the paper; users can update to new time windows.)