galdamour / deeptrading

Deep Neural Network Trading collection of Tensorflow Jupyter notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeepTrading

DeepTrading is a collection of Jupyter notebooks. The objective is to organize in a systematic but flexible way all the necessary steps to calculate and conceive trading systems based on the Tensorflow software.

For more info see: TodoTrader DeepTrading Tensorflow serie

Installation

If you are Black Belt (BB) then "Quick Way" is your way of installation, else use "Detailed Way".

What!, wait...Am I a Black Belt?

Well, if you can use these Jupyter notebooks with "Quick Way" instructions then sure, you are a BB.

Quick Way (Black Belt)

It is highly recommended to run DeepTrading in designated Conda virtual environment. To install Conda you can be guided by any of the many tutorials that are disseminated throughout the Web.

git clone https://github.com/parrondo/deeptrading.git

cd deeptrading

conda env create --file environment.yml

conda activate deeptrading

It's likely you want to have a .env file. It is a configuration text file that is used to define some variables you want to pass into your application's environment.

Example of .env file:

PROJ_DIR=.

DATA_DIR=../data/

RAW_DIR=../data/raw/

INTERIM_DIR=../data/interim/

PROCESSED_DIR=../data/processed/

FIGURES_DIR=../reports/figures/

MODEL_DIR=../models/

EXTERNAL_DIR=../data/external/

PRODUCTION_DIR=/home/PRODUCTION/

Detailed Way (Brown Belt)

Set Up Your Anaconda Python Environment

Here, you will learn how to install a conda environment designed specifically for deeptrading posts called DeepTrading with Tensorflow from a .yaml file.

Objectives

At the end of these instructions, you should be able to:

  • Install a new environment in Anaconda
  • View a list of the available environments in Anaconda

What You Need

You should have Bash, Git (Git Bash for Windows users) and the Anaconda distribution of Python 3.x setup on your computer and an deeptrading working directory. Installation of Git Bash (Windows users) and Anaconda is out of the scope of these instructions. Here you can find the hyperlink and below, how to test your set-up. So, Be sure you have:

Information below is adapted from materials developed by the Conda documentation for installing conda and managing packages.

Test your set-up of Bash, Git and Anaconda

Windows

  1. Search for and open the Git Bash program. In this Terminal window, type bash and hit enter. If you do not get a message back, then Bash is available for use.
  2. Next, type git and hit enter. If you see a list of commands that you can execute, then Git has been installed correctly.
  3. Next, type conda and hit enter. Again, if you see a list of commands that you can execute, then Anaconda Python has been installed correctly.
  4. Close the Terminal by typing exit.

Mac

  1. Search for and open the Terminal program (found in /Applications/Utilities). In this Terminal window, type bash and hit enter. If you do not get a message back, then Bash is available for use.
  2. Next, type git and hit enter. If you see a list of commands that you can execute, then Git has been installed correctly.
  3. Next, type conda and hit enter. Again, if you see a list of commands that you can execute, then Anaconda Python has been installed correctly.
  4. Close the Terminal by typing exit.

Linux

  1. Search for and open the Terminal program. In this Terminal window, type bash and hit enter. If you do not get a message back, then Bash is available for use.
  2. Next, type git and hit enter. If you see a list of commands that you can execute, then Git has been installed correctly.
  3. Next, type conda and hit enter. Again, if you see a list of commands that you can execute, then Anaconda Python has been installed correctly.
  4. Close the Terminal by typing exit.

Set up a Conda Python Environment

Install the deeptrading Conda Environment

Anaconda allows you to have different environments installed on your computer to access different versions of Python and different libraries. Sometimes libraries conflict which causes errors and packages not to work.

To avoid conflicts, we created an environment specifically for deeptrading posts that contains all of the python libraries that you will need.

Tip: For more information about conda environments check out the conda documentation.

To install the deeptrading environment, you will need to follow these steps:

  1. Fork and clone a Github repository from https://github.com/parrondo/deeptrading to your deeptrading directory. This repository contains a file called yaml that is needed for the installation. (For instructions on forking/cloning repositories, see the section below on Fork and Clone Github Repository ).
  2. Be sure you have the yaml file into your deeptrading parent directory using your file manager.
  3. Open the Terminal on your computer (e.g. Git Bash for Windows or Terminal on a Mac/Linux).
  4. In the Terminal, navigate to the deeptrading directory (e.g. cd ~, then cd deeptrading).
  5. Then, type in the Terminal: conda env create -f environment.yml

Note that it takes a bit of time to run this setup, as it needs to download and install each library, and that you need to have internet access for this to run!

Tip: The instructions above will only work if you run them in the directory where you placed the environment.yml file.

Once the environment is installed, always make sure that the deeptrading environment is activated before doing work for this class.

See the instructions further down on this page to Activate a Conda Environment. Once the environment is activated, the name of the activated environment will appear in parentheses on the left side of your terminal.

Fork and Clone Github Repository

This section provides the basic steps for forking a Github repository (i.e. copying an existing repository to your Github account) and for cloning a forked repository (i.e. downloading your forked repository locally to your computer).

Also you could see my post:

https://todotrader.com/robust-git-workflow-for-research-projects/

Fork a Repository on Github.com

You can fork an existing Github repository from the main Github.com page of the repository that you want to copy (example: https://github.com/parrondo/deeptrading).

On the main Github.com page of the repository, you will see a button on the top right that says Fork.

Click on the Fork button and select your Github.com account as the home of the forked repository.

Clone a Repository to Local Computer

To download your forked copy of the deeptrading repository to your computer, open the Terminal and change directories to your deeptrading directory (e.g. cd ~, then cd deeptrading).

Then, run the command git clone followed by the URL to your fork on Github (e.g. https://github.com/your-username/deeptrading). Be sure to change your-username to your Github account username.

cd ~

cd deeptrading

git clone https://github.com/your-username/deeptrading

About the Conda Environment

The .yaml File

When you work with Anaconda, you can create custom lists that tell Anaconda where to install libraries from, and in what order. You can even specify a particular version. You write this list using yaml(Yet Another Markup Language). This is an alternative to using pip to install Python packages.

In previous steps, you used a custom .yaml list to install all of the Python libraries that you will need to complete the lessons in this course. This .yaml list is customized to install libraries from the repositories and in an order that minimizes conflicts.

The .yaml file looks like:

# run: conda env create --file environment.yml
name: deeptrading
dependencies:
- python=3.5
- pip:
- tensorflow==1.5.0
- numpy==1.15.0
- scipy==1.1.0
- scikit-learn==0.19.2
- jupyter==1.0.0
- matplotlib==2.2.2
- requests==2.18.4
- Pillow==5.1.0
- GitPython==2.1.11
- backtrader==1.9.65.122
- pandas==0.23.4
- python-dotenv==0.9.1
- seaborn==0.9.0

Notice at the top of the file there is the environment name. This file has a few key parts:

  1. NAME: the name of the environment that you will call when you wish to activate the environment. The name deeptrading is defined in the environment.yml file.
  2. Channels (optional): this lists where packages will be installed from. There are many options including conda, conda-forge and pip. You will be predominately using conda-forge.
  3. Dependencies: Dependencies are all of the things that you need installed in order for the environment to be complete. In the example, python version 3.5 is specified . The order in which the libraries should be installed is also specified.

Manage Your Conda Environment

You can have different Python environments on your computer. Anaconda allows you to easily jump between environments using a set of commands that you run in your terminal.

View a List of All Installed Conda Environments

You can see a list of all installed conda environments by typing:

conda info --envs

If you want to Jupyter Notebook to use a particular environment that you have setup on your computer, you need to activate it.

For example, if a Python package such as tensorflow is only installed in the deeptrading environment, and not the default anaconda environment, you will not be able to import it to Jupyter Notebook, unless you have the deeptrading environment activated.

Activate a Conda Environment

To activate an environment , use the Terminal to navigate to your deeptrading directory (e.g. cd to the directory). Then, type the following command to activate the environment (e.g. deeptrading):

conda activate deeptrading

For older installations of Anaconda (versions prior to 4.6) on Mac, Linux, and Git Bash for Windows, type:

source activate deeptrading

Windows Users: We assume that Windows users are using Git Bash as their primary terminal. If you need to activate a conda environment using the Command Prompt, you will need to use the following command: activate deeptrading

Once the environment is activated, the name of the activated environment will appear in parentheses on the left side of your terminal.

Tip: Note that after you restart the Terminal, the deeptrading environment is no longer active. You will need to activate the deeptrading environment each time you start the Terminal by running the appropriate command provided above for your operating system.

Deactivate a Conda Environment

If needed, you can deactivate a conda environment. Deactivating the environment switches you back to the default environment in your computer.

Mac and Linux Instructions:

Source deactivate deeptrading

Windows Instructions

deactivate deeptrading

Delete a Conda Environment

If you ever want to delete an environment, you must first deactivate that environment and then type:

conda env remove --name myenv

and replace myenv with the name of the environment that you want to remove.

Remember to never delete your working environment.

About

Deep Neural Network Trading collection of Tensorflow Jupyter notebooks

License:MIT License


Languages

Language:Jupyter Notebook 100.0%