stable/docs/installation.md
2019-07-26 02:59:10 +03:00

9.2 KiB
Raw Blame History

Installation

This page explains how to prepare your environment for running the bot.

Prerequisite

Requirements

Click each one for install guide:

API keys

Before running your bot in production you will need to setup few external API. In production mode, the bot will require valid Exchange API credentials. We also recommend a Telegram bot (optional but recommended).

Setup your exchange account

You will need to create API Keys (Usually you get key and secret) from the Exchange website and insert this into the appropriate fields in the configuration or when asked by the installation script.

Quick start

Freqtrade provides a Linux/MacOS script to install all dependencies and help you to configure the bot.

!!! Note Python3.6 or higher and the corresponding pip are assumed to be available. The install-script will warn and stop if that's not the case.

git clone git@github.com:freqtrade/freqtrade.git
cd freqtrade
git checkout develop
./setup.sh --install

!!! Note Windows installation is explained here.

Easy Installation - Linux Script

If you are on Debian, Ubuntu or MacOS freqtrade provides a script to Install, Update, Configure, and Reset your bot.

$ ./setup.sh
usage:
	-i,--install    Install freqtrade from scratch
	-u,--update     Command git pull to update.
	-r,--reset      Hard reset your develop/master branch.
	-c,--config     Easy config generator (Will override your existing file).

** --install **

This script will install everything you need to run the bot:

  • Mandatory software as: ta-lib
  • Setup your virtualenv
  • Configure your config.json file

This script is a combination of install script --reset, --config

** --update **

Update parameter will pull the last version of your current branch and update your virtualenv.

** --reset **

Reset parameter will hard reset your branch (only if you are on master or develop) and recreate your virtualenv.

** --config **

Config parameter is a config.json configurator. This script will ask you questions to setup your bot and create your config.json.


Custom Installation

We've included/collected install instructions for Ubuntu 16.04, MacOS, and Windows. These are guidelines and your success may vary with other distros. OS Specific steps are listed first, the Common section below is necessary for all systems.

!!! Note Python3.6 or higher and the corresponding pip are assumed to be available.

Linux - Ubuntu 16.04

Install necessary dependencies

sudo apt-get update
sudo apt-get install build-essential git

Raspberry Pi / Raspbian

Before installing FreqTrade on a Raspberry Pi running the official Raspbian Image, make sure you have at least Python 3.6 installed. The default image only provides Python 3.5. Probably the easiest way to get a recent version of python is miniconda.

The following assumes that miniconda3 is installed and available in your environment. Last miniconda3 installation file use python 3.4, we will update to python 3.6 on this installation. It's recommended to use (mini)conda for this as installation/compilation of numpy, scipy and pandas takes a long time.

Additional package to install on your Raspbian, libffi-dev required by cryptography (from python-telegram-bot).

conda config --add channels rpi
conda install python=3.6
conda create -n freqtrade python=3.6
conda activate freqtrade
conda install scipy pandas numpy

sudo apt install libffi-dev
python3 -m pip install -r requirements-common.txt
python3 -m pip install -e .

Common

1. Install TA-Lib

Official webpage: https://mrjbq7.github.io/ta-lib/install.html

wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar xvzf ta-lib-0.4.0-src.tar.gz
cd ta-lib
sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h
./configure --prefix=/usr/local
make
sudo make install
cd ..
rm -rf ./ta-lib*

!!! Note An already downloaded version of ta-lib is included in the repository, as the sourceforge.net source seems to have problems frequently.

2. Setup your Python virtual environment (virtualenv)

!!! Note This step is optional but strongly recommended to keep your system organized

python3 -m venv .env
source .env/bin/activate

3. Install FreqTrade

Clone the git repository:

git clone https://github.com/freqtrade/freqtrade.git

Optionally checkout the master branch to get the latest stable release:

git checkout master

4. Initialize the configuration

cd freqtrade
cp config.json.example config.json

To edit the config please refer to Bot Configuration.

5. Install python dependencies

python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install -e .

6. Run the Bot

If this is the first time you run the bot, ensure you are running it in Dry-run "dry_run": true, otherwise it will start to buy and sell coins.

freqtrade -c config.json

Note: If you run the bot on a server, you should consider using Docker or a terminal multiplexer like screen or tmux to avoid that the bot is stopped on logout.

7. [Optional] Configure freqtrade as a systemd service

From the freqtrade repo... copy freqtrade.service to your systemd user directory (usually ~/.config/systemd/user) and update WorkingDirectory and ExecStart to match your setup.

After that you can start the daemon with:

systemctl --user start freqtrade

For this to be persistent (run when user is logged out) you'll need to enable linger for your freqtrade user.

sudo loginctl enable-linger "$USER"

If you run the bot as a service, you can use systemd service manager as a software watchdog monitoring freqtrade bot state and restarting it in the case of failures. If the internals.sd_notify parameter is set to true in the configuration or the --sd-notify command line option is used, the bot will send keep-alive ping messages to systemd using the sd_notify (systemd notifications) protocol and will also tell systemd its current state (Running or Stopped) when it changes.

The freqtrade.service.watchdog file contains an example of the service unit configuration file which uses systemd as the watchdog.

!!! Note The sd_notify communication between the bot and the systemd service manager will not work if the bot runs in a Docker container.


Windows

We recommend that Windows users use Docker as this will work much easier and smoother (also more secure).

If that is not possible, try using the Windows Linux subsystem (WSL) - for which the Ubuntu instructions should work. If that is not available on your system, feel free to try the instructions below, which led to success for some.

Install freqtrade manually

Clone the git repository

git clone https://github.com/freqtrade/freqtrade.git

Install ta-lib

Install ta-lib according to the ta-lib documentation.

As compiling from source on windows has heavy dependencies (requires a partial visual studio installation), there is also a repository of unofficial precompiled windows Wheels here, which needs to be downloaded and installed using pip install TA_Lib0.4.17cp36cp36mwin32.whl (make sure to use the version matching your python version)

>cd \path\freqtrade-develop
>python -m venv .env
>cd .env\Scripts
>activate.bat
>cd \path\freqtrade-develop
REM optionally install ta-lib from wheel
REM >pip install TA_Lib0.4.17cp36cp36mwin32.whl
>pip install -r requirements.txt
>pip install -e .
>python freqtrade\main.py

Thanks Owdr for the commands. Source: Issue #222

Error during installation under Windows

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Unfortunately, many packages requiring compilation don't provide a pre-build wheel. It is therefore mandatory to have a C/C++ compiler installed and available for your python environment to use.

The easiest way is to download install Microsoft Visual Studio Community here and make sure to install "Common Tools for Visual C++" to enable building c code on Windows. Unfortunately, this is a heavy download / dependency (~4Gb) so you might want to consider WSL or docker first.


Now you have an environment ready, the next step is Bot Configuration.