Prerequisites

In this section we demonstrate how to set up an environment with PyTorch.

TradeMaster supports different operating systems: Linux, Windows and macOS. It requires Python xx, CUDA xx and PyTorch xx.

Step 0. Download and install Miniconda from the official website.

Installation

Linux Installation

Step 1: Install Anaconda

  • Please follow the steps in this blog

Step 2: Install OpenAI

  • Open an ubuntu terminal and type:

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

Step 3: Install TradeMaster

  • Open a terminal amd type

    conda create --name TradeMaster python=3.7.13
    

    to install a new conda environment for TradeMaster

  • Install TradeMaster

    git clone https://github.com/TradeMaster-NTU/TradeMaster.git
    
  • Open the folder TradeMaster and open a terminal under the same position

  • Install the dependency of TradeMaster, run the command:

    conda activate TradeMaster
    cd ./requirement
    pip install -r requirements.txt
    conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
    

Windows Installation

Step 1: Install WSL

  • Please follow the steps in this blog

Step 2: Install Anaconda

  • Please follow the steps in this blog

Step 3: Install OpenAI

  • Open an ubuntu terminal and type:

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

Step 4: Install TradeMaster

  • Open a terminal amd type

    conda create --name TradeMaster python=3.7.13
    

    to install a new conda environment for TradeMaster

  • Install TradeMaster

    git clone https://github.com/TradeMaster-NTU/TradeMaster.git
    
  • Open the folder TradeMaster and open a terminal under the same position

  • Install the dependency of TradeMaster, run the command:

    conda activate TradeMaster
    cd ./requirement
    pip install -r requirements.txt
    conda install pytorch torchvision torchaudio cpuonly -c pytorch
    

MacOS Installation

Step 1: Install Anaconda

  • Follow Anaconda’s instruction: macOS graphical install, to install the newest version of Anaconda.

  • Open your terminal and type: which python, it should show:

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

    It means that your Python interpreter path has been pinned to Anaconda’s python version. If it shows something like this:

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

    It means that you still use the default python path, you either fix it and pin it to the anaconda path (try this blog), or you can use Anaconda Navigator to open a terminal manually.

Step 2: Install Homebrew

  • Open a terminal and make sure that you have installed Anaconda.

  • Install Homebrew:

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

Step 3: Install OpenAI

Installation of system packages on Mac requires Homebrew. With Homebrew installed, run the following in your terminal:

brew install cmake openmpi

Step 4: Install TradeMaster

  • Open a terminal amd type

    conda create --name TradeMaster python=3.7.13
    

    to install a new conda environment for TradeMaster

  • Install TradeMaster

     git clone https://github.com/TradeMaster-NTU/TradeMaster.git
    
  • Open the folder TradeMaster and open a terminal under the same position

  • Install the dependency of TradeMaster, run the command:

    conda activate TradeMaster
    cd ./requirement
    pip install -r requirements.txt
    conda install pytorch torchvision torchaudio -c pytorch
    

Verify the installation

Customize Installation

Install on Google Colab

Using TradeMaster with Docker

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.

Step 1: Install Docker

  • Please follow the steps in this blog

  • To check whether the Docker has been installed properly, type docker version, it should show:

    Client:
     Cloud integration: v1.0.29
     Version:           20.10.17
     API version:       1.41
     Go version:        go1.17.11
     Git commit:        100c701
     Built:             Mon Jun  6 23:09:02 2022
     OS/Arch:           windows/amd64
     Context:           default
     Experimental:      true
    
    Server: Docker Desktop 4.12.0 (85629)
     Engine:
      Version:          20.10.17
      API version:      1.41 (minimum version 1.12)
      Go version:       go1.17.11
      Git commit:       a89b842
      Built:            Mon Jun  6 23:01:23 2022
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.6.8
      GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
     runc:
      Version:          1.1.4
      GitCommit:        v1.1.4-0-g5fd4c4d
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0
    

Step 2: Build the docker image from dockerfile

  • Install TradeMaster

     git clone https://github.com/TradeMaster-NTU/TradeMaster.git
    
  • Create image from the project docker file.

    If your chip is arm-architectured, open terminal or cmd in the position of the project and type

    cd ./docker/arm
    docker build -t="trademaster:0.1" .
    

    If you chip is x86-architectured, open terminal or cmd in the position of the project and type

    cd ./docker/x86
    docker build -t="trademaster:0.1" .
    

    It will take a while before the image is built.

Step 3: Test whether the image is installed correctly

  • Open the terminal in the project position and type

    docker image ls
    

    It should shows

    REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
    trademaster   0.1       02801f755797   4 minutes ago   15GB 
    
  • Create a container and run an experiment to see whether the installation is successful

    docker run -it trademaster:0.1
    python experiment/AT/DeepScalper/experiment.py