freqtrade_origin/docs/installation.md

351 lines
9.0 KiB
Markdown
Raw Normal View History

2018-01-13 02:36:12 +00:00
# Installation
2018-01-09 04:27:41 +00:00
This page explains how to prepare your environment for running the bot.
2018-01-13 02:36:12 +00:00
To understand how to set up the bot please read the [Bot Configuration](https://github.com/gcarq/freqtrade/blob/develop/docs/configuration.md) page.
2018-01-02 02:17:10 +00:00
## Table of Contents
2018-01-13 02:36:12 +00:00
2018-01-13 05:32:09 +00:00
* [Table of Contents](#table-of-contents)
* [Easy Installation - Linux Script](#easy-installation---linux-script)
* [Automatic Installation - Docker](#automatic-installation---docker)
* [Custom Linux MacOS Installation](#custom-installation)
2018-01-13 05:32:09 +00:00
- [Requirements](#requirements)
- [Linux - Ubuntu 16.04](#linux---ubuntu-1604)
2018-01-13 05:32:09 +00:00
- [MacOS](#macos)
- [Setup Config and virtual env](#setup-config-and-virtual-env)
* [Windows](#windows)
2018-01-13 05:32:09 +00:00
<!-- /TOC -->
------
## Easy Installation - Linux Script
If you are on Debian, Ubuntu or MacOS a freqtrade provides a script to Install, Update, Configure, and Reset your bot.
```bash
$ ./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: `Python3`, `ta-lib`, `wget`
* 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`.
2018-01-13 02:36:12 +00:00
------
## Automatic Installation - Docker
2018-01-02 02:17:10 +00:00
Start by downloading Docker for your platform:
2018-01-13 02:36:12 +00:00
* [Mac](https://www.docker.com/products/docker#/mac)
* [Windows](https://www.docker.com/products/docker#/windows)
* [Linux](https://www.docker.com/products/docker#/linux)
Once you have Docker installed, simply create the config file (e.g. `config.json`) and then create a Docker image for `freqtrade` using the Dockerfile in this repo.
### 1. Prepare the Bot
#### 1.1. Clone the git repository
2018-01-02 02:17:10 +00:00
```bash
2018-01-09 04:27:41 +00:00
git clone https://github.com/gcarq/freqtrade.git
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
#### 1.2. (Optional) Checkout the develop branch
2018-01-02 02:17:10 +00:00
```bash
git checkout develop
```
2018-01-13 02:36:12 +00:00
#### 1.3. Go into the new directory
2018-01-02 02:17:10 +00:00
```bash
cd freqtrade
```
2018-01-13 02:36:12 +00:00
#### 1.4. Copy `config.json.example` to `config.json`
2018-01-02 02:17:10 +00:00
```bash
2018-01-14 17:25:30 +00:00
cp -n config.json.example config.json
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
> To edit the config please refer to the [Bot Configuration](https://github.com/gcarq/freqtrade/blob/develop/docs/configuration.md) page.
#### 1.5. Create your database file *(optional - the bot will create it if it is missing)*
2018-01-13 05:32:09 +00:00
Production
2018-01-02 02:17:10 +00:00
```bash
touch tradesv3.sqlite
2018-01-13 05:32:09 +00:00
````
2018-01-02 02:17:10 +00:00
2018-01-13 05:32:09 +00:00
Dry-Run
```bash
2018-01-02 02:17:10 +00:00
touch tradesv3.dryrun.sqlite
```
2018-01-13 02:36:12 +00:00
### 2. Build the Docker image
2018-01-02 02:17:10 +00:00
```bash
cd freqtrade
docker build -t freqtrade .
```
2018-01-13 02:36:12 +00:00
For security reasons, your configuration file will not be included in the image, you will need to bind mount it. It is also advised to bind mount an SQLite database file (see the "5. Run a restartable docker image" section) to keep it between updates.
2018-01-02 02:17:10 +00:00
2018-01-13 02:36:12 +00:00
### 3. Verify the Docker image
After the build process you can verify that the image was created with:
```bash
2018-01-02 02:17:10 +00:00
docker images
```
2018-01-13 02:36:12 +00:00
### 4. Run the Docker image
You can run a one-off container that is immediately deleted upon exiting with the following command (`config.json` must be in the current working directory):
```bash
2018-03-10 08:53:38 +00:00
docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
In this example, the database will be created inside the docker instance and will be lost when you will refresh your image.
2018-01-02 02:17:10 +00:00
### 5. Run a restartable docker image
2018-01-13 02:36:12 +00:00
To run a restartable instance in the background (feel free to place your configuration and database files wherever it feels comfortable on your filesystem).
#### 5.1. Move your config file and database
2018-01-02 02:17:10 +00:00
```bash
mkdir ~/.freqtrade
mv config.json ~/.freqtrade
mv tradesv3.sqlite ~/.freqtrade
```
2018-01-13 02:36:12 +00:00
#### 5.2. Run the docker image
2018-01-02 02:17:10 +00:00
```bash
docker run -d \
--name freqtrade \
-v /etc/localtime:/etc/localtime:ro \
2018-01-02 02:17:10 +00:00
-v ~/.freqtrade/config.json:/freqtrade/config.json \
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
freqtrade
```
2018-01-13 02:36:12 +00:00
If you are using `dry_run=True` it's not necessary to mount `tradesv3.sqlite`, but you can mount `tradesv3.dryrun.sqlite` if you plan to use the dry run mode with the param `--dry-run-db`.
2018-01-02 02:17:10 +00:00
### 6. Monitor your Docker instance
2018-01-13 02:36:12 +00:00
2018-01-02 02:17:10 +00:00
You can then use the following commands to monitor and manage your container:
```bash
docker logs freqtrade
docker logs -f freqtrade
docker restart freqtrade
docker stop freqtrade
docker start freqtrade
```
2018-01-13 02:36:12 +00:00
You do not need to rebuild the image for configuration changes, it will suffice to edit `config.json` and restart the container.
------
## 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.
### Requirements
2018-01-02 02:17:10 +00:00
Click each one for install guide:
2018-01-13 02:36:12 +00:00
* [Python 3.6.x](http://docs.python-guide.org/en/latest/starting/installation/), note the bot was not tested on Python >= 3.7.x
* [pip](https://pip.pypa.io/en/stable/installing/)
* [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) (Recommended)
* [TA-Lib](https://mrjbq7.github.io/ta-lib/install.html)
2018-01-02 02:17:10 +00:00
2018-01-13 02:36:12 +00:00
### Linux - Ubuntu 16.04
#### 1. Install Python 3.6, Git, and wget
2018-01-02 02:17:10 +00:00
```bash
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6 python3.6-venv python3.6-dev build-essential autoconf libtool pkg-config make wget git
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
#### 2. Install TA-Lib
2018-01-02 02:17:10 +00:00
Official webpage: https://mrjbq7.github.io/ta-lib/install.html
2018-01-13 02:36:12 +00:00
```bash
2018-01-02 02:17:10 +00:00
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
./configure --prefix=/usr
make
make install
cd ..
rm -rf ./ta-lib*
```
2018-01-13 02:36:12 +00:00
#### 3. [Optional] Install MongoDB
2018-01-02 02:17:10 +00:00
Install MongoDB if you plan to optimize your strategy with Hyperopt.
```bash
sudo apt-get install mongodb-org
```
2018-01-13 02:36:12 +00:00
> Complete tutorial from Digital Ocean: [How to Install MongoDB on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04).
2018-01-02 02:17:10 +00:00
2018-01-13 02:36:12 +00:00
#### 4. Install FreqTrade
2018-01-02 02:17:10 +00:00
2018-01-13 02:36:12 +00:00
Clone the git repository:
2018-01-02 02:17:10 +00:00
```bash
2018-01-13 02:36:12 +00:00
git clone https://github.com/gcarq/freqtrade.git
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
Optionally checkout the develop branch:
```bash
git checkout develop
```
#### 5. 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:
```bash
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.
```bash
sudo loginctl enable-linger "$USER"
```
2018-01-13 05:32:09 +00:00
### MacOS
2018-01-13 02:36:12 +00:00
#### 1. Install Python 3.6, git, wget and ta-lib
```bash
brew install python3 git wget ta-lib
```
#### 2. [Optional] Install MongoDB
2018-01-02 02:17:10 +00:00
Install MongoDB if you plan to optimize your strategy with Hyperopt.
2018-01-13 02:36:12 +00:00
2018-01-02 02:17:10 +00:00
```bash
curl -O https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.4.10.tgz
tar -zxvf mongodb-osx-ssl-x86_64-3.4.10.tgz
mkdir -p <path_freqtrade>/env/mongodb
cp -R -n mongodb-osx-x86_64-3.4.10/ <path_freqtrade>/env/mongodb
export PATH=<path_freqtrade>/env/mongodb/bin:$PATH
```
2018-01-13 02:36:12 +00:00
#### 3. Install FreqTrade
2018-01-02 02:17:10 +00:00
2018-01-13 02:36:12 +00:00
Clone the git repository:
2018-01-02 02:17:10 +00:00
```bash
2018-01-13 02:36:12 +00:00
git clone https://github.com/gcarq/freqtrade.git
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
Optionally checkout the develop branch:
2018-01-02 02:17:10 +00:00
```bash
2018-01-13 02:36:12 +00:00
git checkout develop
2018-01-02 02:17:10 +00:00
```
2018-01-13 02:36:12 +00:00
### Setup Config and virtual env
2018-01-13 05:32:09 +00:00
#### 1. Initialize the configuration
2018-01-13 02:36:12 +00:00
```bash
cd freqtrade
cp config.json.example config.json
```
> *To edit the config please refer to [Bot Configuration](https://github.com/gcarq/freqtrade/blob/develop/docs/configuration.md).*
#### 2. Setup your Python virtual environment (virtualenv)
2018-01-13 05:32:09 +00:00
2018-01-13 02:36:12 +00:00
```bash
python3.6 -m venv .env
source .env/bin/activate
2018-01-29 02:01:02 +00:00
pip3.6 install --upgrade pip
2018-01-13 02:36:12 +00:00
pip3.6 install -r requirements.txt
pip3.6 install -e .
```
#### 3. Run the Bot
2018-01-13 05:32:09 +00:00
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.
2018-01-13 02:36:12 +00:00
```bash
python3.6 ./freqtrade/main.py -c config.json
```
------
## Windows
We recommend that Windows users use [Docker](#docker) as this will work
much easier and smoother (also more secure).
### Install freqtrade
copy paste `config.json` to ``\path\freqtrade-develop\freqtrade`
```cmd
>cd \path\freqtrade-develop
>python -m venv .env
>cd .env\Scripts
>activate.bat
>cd \path\freqtrade-develop
>pip install -r requirements.txt
>pip install -e .
>cd freqtrade
>python main.py
```
> Thanks [Owdr](https://github.com/Owdr) for the commands. Source: [Issue #222](https://github.com/gcarq/freqtrade/issues/222)
2018-01-13 02:36:12 +00:00
Now you have an environment ready, the next step is
[Bot Configuration](https://github.com/gcarq/freqtrade/blob/develop/docs/configuration.md)...