Merge branch 'develop' into stoploss_restart
This commit is contained in:
204
docs/docker.md
Normal file
204
docs/docker.md
Normal file
@@ -0,0 +1,204 @@
|
||||
# Using FreqTrade with Docker
|
||||
|
||||
## Install Docker
|
||||
|
||||
Start by downloading and installing Docker CE for your platform:
|
||||
|
||||
* [Mac](https://docs.docker.com/docker-for-mac/install/)
|
||||
* [Windows](https://docs.docker.com/docker-for-windows/install/)
|
||||
* [Linux](https://docs.docker.com/install/)
|
||||
|
||||
Once you have Docker installed, simply prepare the config file (e.g. `config.json`) and run the image for `freqtrade` as explained below.
|
||||
|
||||
## Download the official FreqTrade docker image
|
||||
|
||||
Pull the image from docker hub.
|
||||
|
||||
Branches / tags available can be checked out on [Dockerhub](https://hub.docker.com/r/freqtradeorg/freqtrade/tags/).
|
||||
|
||||
```bash
|
||||
docker pull freqtradeorg/freqtrade:develop
|
||||
# Optionally tag the repository so the run-commands remain shorter
|
||||
docker tag freqtradeorg/freqtrade:develop freqtrade
|
||||
```
|
||||
|
||||
To update the image, simply run the above commands again and restart your running container.
|
||||
|
||||
Should you require additional libraries, please [build the image yourself](#build-your-own-docker-image).
|
||||
|
||||
### Prepare the configuration files
|
||||
|
||||
Even though you will use docker, you'll still need some files from the github repository.
|
||||
|
||||
#### Clone the git repository
|
||||
|
||||
Linux/Mac/Windows with WSL
|
||||
|
||||
```bash
|
||||
git clone https://github.com/freqtrade/freqtrade.git
|
||||
```
|
||||
|
||||
Windows with docker
|
||||
|
||||
```bash
|
||||
git clone --config core.autocrlf=input https://github.com/freqtrade/freqtrade.git
|
||||
```
|
||||
|
||||
#### Copy `config.json.example` to `config.json`
|
||||
|
||||
```bash
|
||||
cd freqtrade
|
||||
cp -n config.json.example config.json
|
||||
```
|
||||
|
||||
> To understand the configuration options, please refer to the [Bot Configuration](configuration.md) page.
|
||||
|
||||
#### Create your database file
|
||||
|
||||
Production
|
||||
|
||||
```bash
|
||||
touch tradesv3.sqlite
|
||||
````
|
||||
|
||||
Dry-Run
|
||||
|
||||
```bash
|
||||
touch tradesv3.dryrun.sqlite
|
||||
```
|
||||
|
||||
!!! Note
|
||||
Make sure to use the path to this file when starting the bot in docker.
|
||||
|
||||
### Build your own Docker image
|
||||
|
||||
Best start by pulling the official docker image from dockerhub as explained [here](#download-the-official-docker-image) to speed up building.
|
||||
|
||||
To add additional libraries to your docker image, best check out [Dockerfile.technical](https://github.com/freqtrade/freqtrade/blob/develop/Dockerfile.technical) which adds the [technical](https://github.com/freqtrade/technical) module to the image.
|
||||
|
||||
```bash
|
||||
docker build -t freqtrade -f Dockerfile.technical .
|
||||
```
|
||||
|
||||
If you are developing using Docker, use `Dockerfile.develop` to build a dev Docker image, which will also set up develop dependencies:
|
||||
|
||||
```bash
|
||||
docker build -f Dockerfile.develop -t freqtrade-dev .
|
||||
```
|
||||
|
||||
!!! Note
|
||||
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.
|
||||
|
||||
#### Verify the Docker image
|
||||
|
||||
After the build process you can verify that the image was created with:
|
||||
|
||||
```bash
|
||||
docker images
|
||||
```
|
||||
|
||||
The output should contain the freqtrade image.
|
||||
|
||||
### 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
|
||||
docker run --rm -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
|
||||
```
|
||||
|
||||
!!! Warning
|
||||
In this example, the database will be created inside the docker instance and will be lost when you will refresh your image.
|
||||
|
||||
#### Adjust timezone
|
||||
|
||||
By default, the container will use UTC timezone.
|
||||
Should you find this irritating please add the following to your docker commands:
|
||||
|
||||
##### Linux
|
||||
|
||||
``` bash
|
||||
-v /etc/timezone:/etc/timezone:ro
|
||||
|
||||
# Complete command:
|
||||
docker run --rm -v /etc/timezone:/etc/timezone:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
|
||||
```
|
||||
|
||||
##### MacOS
|
||||
|
||||
There is known issue in OSX Docker versions after 17.09.1, whereby `/etc/localtime` cannot be shared causing Docker to not start. A work-around for this is to start with the following cmd.
|
||||
|
||||
```bash
|
||||
docker run --rm -e TZ=`ls -la /etc/localtime | cut -d/ -f8-9` -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
|
||||
```
|
||||
|
||||
More information on this docker issue and work-around can be read [here](https://github.com/docker/for-mac/issues/2396).
|
||||
|
||||
### Run a restartable docker image
|
||||
|
||||
To run a restartable instance in the background (feel free to place your configuration and database files wherever it feels comfortable on your filesystem).
|
||||
|
||||
#### Move your config file and database
|
||||
|
||||
The following will assume that you place your configuration / database files to `~/.freqtrade`, which is a hidden folder in your home directory. Feel free to use a different folder and replace the folder in the upcomming commands.
|
||||
|
||||
```bash
|
||||
mkdir ~/.freqtrade
|
||||
mv config.json ~/.freqtrade
|
||||
mv tradesv3.sqlite ~/.freqtrade
|
||||
```
|
||||
|
||||
#### Run the docker image
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name freqtrade \
|
||||
-v ~/.freqtrade/config.json:/freqtrade/config.json \
|
||||
-v ~/.freqtrade/user_data/:/freqtrade/user_data \
|
||||
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
|
||||
freqtrade --db-url sqlite:///tradesv3.sqlite --strategy MyAwesomeStrategy
|
||||
```
|
||||
|
||||
!!! Note
|
||||
db-url defaults to `sqlite:///tradesv3.sqlite` but it defaults to `sqlite://` if `dry_run=True` is being used.
|
||||
To override this behaviour use a custom db-url value: i.e.: `--db-url sqlite:///tradesv3.dryrun.sqlite`
|
||||
|
||||
!!! Note
|
||||
All available bot command line parameters can be added to the end of the `docker run` command.
|
||||
|
||||
### Monitor your Docker instance
|
||||
|
||||
You can 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
|
||||
```
|
||||
|
||||
For more information on how to operate Docker, please refer to the [official Docker documentation](https://docs.docker.com/).
|
||||
|
||||
!!! Note
|
||||
You do not need to rebuild the image for configuration changes, it will suffice to edit `config.json` and restart the container.
|
||||
|
||||
### Backtest with docker
|
||||
|
||||
The following assumes that the download/setup of the docker image have been completed successfully.
|
||||
Also, backtest-data should be available at `~/.freqtrade/user_data/`.
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name freqtrade \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ~/.freqtrade/config.json:/freqtrade/config.json \
|
||||
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
|
||||
-v ~/.freqtrade/user_data/:/freqtrade/user_data/ \
|
||||
freqtrade --strategy AwsomelyProfitableStrategy backtesting
|
||||
```
|
||||
|
||||
Head over to the [Backtesting Documentation](backtesting.md) for more details.
|
||||
|
||||
!!! Note
|
||||
Additional bot command line parameters can be appended after the image name (`freqtrade` in the above example).
|
@@ -122,9 +122,10 @@ So let's write the buy strategy using these values:
|
||||
dataframe['macd'], dataframe['macdsignal']
|
||||
))
|
||||
|
||||
dataframe.loc[
|
||||
reduce(lambda x, y: x & y, conditions),
|
||||
'buy'] = 1
|
||||
if conditions:
|
||||
dataframe.loc[
|
||||
reduce(lambda x, y: x & y, conditions),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
|
@@ -21,8 +21,8 @@ Freqtrade is a cryptocurrency trading bot written in Python.
|
||||
|
||||
We strongly recommend you to have basic coding skills and Python knowledge. Do not hesitate to read the source code and understand the mechanisms of this bot, algorithms and techniques implemented in it.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Based on Python 3.6+: For botting on any operating system — Windows, macOS and Linux.
|
||||
- Persistence: Persistence is achieved through sqlite database.
|
||||
- Dry-run mode: Run the bot without playing money.
|
||||
@@ -31,17 +31,19 @@ Freqtrade is a cryptocurrency trading bot written in Python.
|
||||
- Edge position sizing: Calculate your win rate, risk reward ratio, the best stoploss and adjust your position size before taking a position for each specific market.
|
||||
- Whitelist crypto-currencies: Select which crypto-currency you want to trade or use dynamic whitelists based on market (pair) trade volume.
|
||||
- Blacklist crypto-currencies: Select which crypto-currency you want to avoid.
|
||||
- Manageable via Telegram: Manage the bot with Telegram.
|
||||
- Manageable via Telegram or REST APi: Manage the bot with Telegram or via the builtin REST API.
|
||||
- Display profit/loss in fiat: Display your profit/loss in any of 33 fiat currencies supported.
|
||||
- Daily summary of profit/loss: Receive the daily summary of your profit/loss.
|
||||
- Performance status report: Receive the performance status of your current trades.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
### Up to date clock
|
||||
|
||||
The clock on the system running the bot must be accurate, synchronized to a NTP server frequently enough to avoid problems with communication to the exchanges.
|
||||
|
||||
### Hardware requirements
|
||||
|
||||
To run this bot we recommend you a cloud instance with a minimum of:
|
||||
|
||||
- 2GB RAM
|
||||
@@ -49,6 +51,7 @@ To run this bot we recommend you a cloud instance with a minimum of:
|
||||
- 2vCPU
|
||||
|
||||
### Software requirements
|
||||
|
||||
- Python 3.6.x
|
||||
- pip (pip3)
|
||||
- git
|
||||
@@ -56,12 +59,13 @@ To run this bot we recommend you a cloud instance with a minimum of:
|
||||
- virtualenv (Recommended)
|
||||
- Docker (Recommended)
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
Help / Slack
|
||||
For any questions not covered by the documentation or for further information about the bot, we encourage you to join our Slack channel.
|
||||
|
||||
Click [here](https://join.slack.com/t/highfrequencybot/shared_invite/enQtMjQ5NTM0OTYzMzY3LWMxYzE3M2MxNDdjMGM3ZTYwNzFjMGIwZGRjNTc3ZGU3MGE3NzdmZGMwNmU3NDM5ZTNmM2Y3NjRiNzk4NmM4OGE) to join Slack channel.
|
||||
|
||||
## Ready to try?
|
||||
|
||||
Begin by reading our installation guide [here](installation).
|
||||
|
@@ -1,58 +1,21 @@
|
||||
# Installation
|
||||
|
||||
This page explains how to prepare your environment for running the bot.
|
||||
|
||||
## Prerequisite
|
||||
|
||||
Before running your bot in production you will need to setup few
|
||||
external API. In production mode, the bot required valid Bittrex API
|
||||
credentials and a Telegram bot (optional but recommended).
|
||||
external API. In production mode, the bot will require valid Exchange API
|
||||
credentials. We also reccomend a [Telegram bot](telegram-usage.md#setup-your-telegram-bot) (optional but recommended).
|
||||
|
||||
- [Setup your exchange account](#setup-your-exchange-account)
|
||||
- [Backtesting commands](#setup-your-telegram-bot)
|
||||
|
||||
### Setup your exchange account
|
||||
*To be completed, please feel free to complete this section.*
|
||||
|
||||
### Setup your Telegram bot
|
||||
The only things you need is a working Telegram bot and its API token.
|
||||
Below we explain how to create your Telegram Bot, and how to get your
|
||||
Telegram user id.
|
||||
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.
|
||||
|
||||
### 1. Create your Telegram bot
|
||||
|
||||
**1.1. Start a chat with https://telegram.me/BotFather**
|
||||
|
||||
**1.2. Send the message `/newbot`. ** *BotFather response:*
|
||||
```
|
||||
Alright, a new bot. How are we going to call it? Please choose a name for your bot.
|
||||
```
|
||||
|
||||
**1.3. Choose the public name of your bot (e.x. `Freqtrade bot`)**
|
||||
*BotFather response:*
|
||||
```
|
||||
Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
|
||||
```
|
||||
**1.4. Choose the name id of your bot (e.x "`My_own_freqtrade_bot`")**
|
||||
|
||||
**1.5. Father bot will return you the token (API key)**<br/>
|
||||
Copy it and keep it you will use it for the config parameter `token`.
|
||||
*BotFather response:*
|
||||
```hl_lines="4"
|
||||
Done! Congratulations on your new bot. You will find it at t.me/My_own_freqtrade_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
|
||||
|
||||
Use this token to access the HTTP API:
|
||||
521095879:AAEcEZEL7ADJ56FtG_qD0bQJSKETbXCBCi0
|
||||
|
||||
For a description of the Bot API, see this page: https://core.telegram.org/bots/api
|
||||
```
|
||||
**1.6. Don't forget to start the conversation with your bot, by clicking /START button**
|
||||
|
||||
### 2. Get your user id
|
||||
**2.1. Talk to https://telegram.me/userinfobot**
|
||||
|
||||
**2.2. Get your "Id", you will use it for the config parameter
|
||||
`chat_id`.**
|
||||
<hr/>
|
||||
## Quick start
|
||||
|
||||
Freqtrade provides a Linux/MacOS script to install all dependencies and help you to configure the bot.
|
||||
|
||||
```bash
|
||||
@@ -61,9 +24,10 @@ cd freqtrade
|
||||
git checkout develop
|
||||
./setup.sh --install
|
||||
```
|
||||
|
||||
!!! Note
|
||||
Windows installation is explained [here](#windows).
|
||||
<hr/>
|
||||
|
||||
## 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.
|
||||
@@ -101,193 +65,6 @@ Config parameter is a `config.json` configurator. This script will ask you quest
|
||||
|
||||
------
|
||||
|
||||
## Automatic Installation - Docker
|
||||
|
||||
Start by downloading Docker for your platform:
|
||||
|
||||
* [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**
|
||||
|
||||
Linux/Mac/Windows with WSL
|
||||
```bash
|
||||
git clone https://github.com/freqtrade/freqtrade.git
|
||||
```
|
||||
|
||||
Windows with docker
|
||||
```bash
|
||||
git clone --config core.autocrlf=input https://github.com/freqtrade/freqtrade.git
|
||||
```
|
||||
|
||||
**1.2. (Optional) Checkout the develop branch**
|
||||
|
||||
```bash
|
||||
git checkout develop
|
||||
```
|
||||
|
||||
**1.3. Go into the new directory**
|
||||
|
||||
```bash
|
||||
cd freqtrade
|
||||
```
|
||||
|
||||
**1.4. Copy `config.json.example` to `config.json`**
|
||||
|
||||
```bash
|
||||
cp -n config.json.example config.json
|
||||
```
|
||||
|
||||
> To edit the config please refer to the [Bot Configuration](configuration.md) page.
|
||||
|
||||
**1.5. Create your database file *(optional - the bot will create it if it is missing)**
|
||||
|
||||
Production
|
||||
|
||||
```bash
|
||||
touch tradesv3.sqlite
|
||||
````
|
||||
|
||||
Dry-Run
|
||||
|
||||
```bash
|
||||
touch tradesv3.dryrun.sqlite
|
||||
```
|
||||
|
||||
### 2. Download or build the docker image
|
||||
|
||||
Either use the prebuilt image from docker hub - or build the image yourself if you would like more control on which version is used.
|
||||
|
||||
Branches / tags available can be checked out on [Dockerhub](https://hub.docker.com/r/freqtradeorg/freqtrade/tags/).
|
||||
|
||||
**2.1. Download the docker image**
|
||||
|
||||
Pull the image from docker hub and (optionally) change the name of the image
|
||||
|
||||
```bash
|
||||
docker pull freqtradeorg/freqtrade:develop
|
||||
# Optionally tag the repository so the run-commands remain shorter
|
||||
docker tag freqtradeorg/freqtrade:develop freqtrade
|
||||
```
|
||||
|
||||
To update the image, simply run the above commands again and restart your running container.
|
||||
|
||||
**2.2. Build the Docker image**
|
||||
|
||||
```bash
|
||||
cd freqtrade
|
||||
docker build -t freqtrade .
|
||||
```
|
||||
|
||||
If you are developing using Docker, use `Dockerfile.develop` to build a dev Docker image, which will also set up develop dependencies:
|
||||
|
||||
```bash
|
||||
docker build -f ./Dockerfile.develop -t freqtrade-dev .
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
### 3. Verify the Docker image
|
||||
|
||||
After the build process you can verify that the image was created with:
|
||||
|
||||
```bash
|
||||
docker images
|
||||
```
|
||||
|
||||
### 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
|
||||
docker run --rm -v /etc/localtime:/etc/localtime:ro -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
|
||||
```
|
||||
|
||||
There is known issue in OSX Docker versions after 17.09.1, whereby /etc/localtime cannot be shared causing Docker to not start. A work-around for this is to start with the following cmd.
|
||||
|
||||
```bash
|
||||
docker run --rm -e TZ=`ls -la /etc/localtime | cut -d/ -f8-9` -v `pwd`/config.json:/freqtrade/config.json -it freqtrade
|
||||
```
|
||||
|
||||
More information on this docker issue and work-around can be read [here](https://github.com/docker/for-mac/issues/2396).
|
||||
|
||||
In this example, the database will be created inside the docker instance and will be lost when you will refresh your image.
|
||||
|
||||
### 5. Run a restartable docker image
|
||||
|
||||
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**
|
||||
|
||||
```bash
|
||||
mkdir ~/.freqtrade
|
||||
mv config.json ~/.freqtrade
|
||||
mv tradesv3.sqlite ~/.freqtrade
|
||||
```
|
||||
|
||||
**5.2. Run the docker image**
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name freqtrade \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ~/.freqtrade/config.json:/freqtrade/config.json \
|
||||
-v ~/.freqtrade/user_data/:/freqtrade/user_data \
|
||||
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
|
||||
freqtrade --db-url sqlite:///tradesv3.sqlite --strategy MyAwesomeStrategy
|
||||
```
|
||||
|
||||
!!! Note
|
||||
db-url defaults to `sqlite:///tradesv3.sqlite` but it defaults to `sqlite://` if `dry_run=True` is being used.
|
||||
To override this behaviour use a custom db-url value: i.e.: `--db-url sqlite:///tradesv3.dryrun.sqlite`
|
||||
|
||||
!!! Note
|
||||
All command line arguments can be added to the end of the `docker run` command.
|
||||
|
||||
### 6. Monitor your Docker instance
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
For more information on how to operate Docker, please refer to the [official Docker documentation](https://docs.docker.com/).
|
||||
|
||||
!!! Note
|
||||
You do not need to rebuild the image for configuration changes, it will suffice to edit `config.json` and restart the container.
|
||||
|
||||
### 7. Backtest with docker
|
||||
|
||||
The following assumes that the above steps (1-4) have been completed successfully.
|
||||
Also, backtest-data should be available at `~/.freqtrade/user_data/`.
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name freqtrade \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ~/.freqtrade/config.json:/freqtrade/config.json \
|
||||
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
|
||||
-v ~/.freqtrade/user_data/:/freqtrade/user_data/ \
|
||||
freqtrade --strategy AwsomelyProfitableStrategy backtesting
|
||||
```
|
||||
|
||||
Head over to the [Backtesting Documentation](backtesting.md) for more details.
|
||||
|
||||
!!! Note
|
||||
Additional parameters can be appended after the image name (`freqtrade` in the above example).
|
||||
|
||||
------
|
||||
|
||||
## 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.
|
||||
@@ -413,7 +190,7 @@ If this is the first time you run the bot, ensure you are running it in Dry-run
|
||||
python3.6 freqtrade -c config.json
|
||||
```
|
||||
|
||||
*Note*: If you run the bot on a server, you should consider using [Docker](#automatic-installation---docker) a terminal multiplexer like `screen` or [`tmux`](https://en.wikipedia.org/wiki/Tmux) to avoid that the bot is stopped on logout.
|
||||
*Note*: If you run the bot on a server, you should consider using [Docker](docker.md) or a terminal multiplexer like `screen` or [`tmux`](https://en.wikipedia.org/wiki/Tmux) to avoid that the bot is stopped on logout.
|
||||
|
||||
#### 7. [Optional] Configure `freqtrade` as a `systemd` service
|
||||
|
||||
@@ -441,14 +218,13 @@ The `freqtrade.service.watchdog` file contains an example of the service unit co
|
||||
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.
|
||||
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](#docker) as this will work much easier and smoother (also more secure).
|
||||
We recommend that Windows users use [Docker](docker.md) 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.
|
||||
@@ -492,7 +268,7 @@ error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++
|
||||
|
||||
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](https://visualstudio.microsoft.com/downloads/) 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.
|
||||
The easiest way is to download install Microsoft Visual Studio Community [here](https://visualstudio.microsoft.com/downloads/) 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](docker.md) first.
|
||||
|
||||
---
|
||||
|
||||
|
@@ -1,63 +1,83 @@
|
||||
# Plotting
|
||||
This page explains how to plot prices, indicator, profits.
|
||||
|
||||
This page explains how to plot prices, indicators and profits.
|
||||
|
||||
## Installation
|
||||
|
||||
Plotting scripts use Plotly library. Install/upgrade it with:
|
||||
|
||||
``` bash
|
||||
pip install -U -r requirements-plot.txt
|
||||
```
|
||||
pip install --upgrade plotly
|
||||
```
|
||||
|
||||
At least version 2.3.0 is required.
|
||||
|
||||
## Plot price and indicators
|
||||
|
||||
Usage for the price plotter:
|
||||
|
||||
```
|
||||
script/plot_dataframe.py [-h] [-p pairs] [--live]
|
||||
``` bash
|
||||
python3 script/plot_dataframe.py [-h] [-p pairs] [--live]
|
||||
```
|
||||
|
||||
Example
|
||||
```
|
||||
python scripts/plot_dataframe.py -p BTC/ETH
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -p BTC/ETH
|
||||
```
|
||||
|
||||
The `-p` pairs argument, can be used to specify
|
||||
pairs you would like to plot.
|
||||
The `-p` pairs argument can be used to specify pairs you would like to plot.
|
||||
|
||||
**Advanced use**
|
||||
Specify custom indicators.
|
||||
Use `--indicators1` for the main plot and `--indicators2` for the subplot below (if values are in a different range than prices).
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -p BTC/ETH --indicators1 sma,ema --indicators2 macd
|
||||
```
|
||||
|
||||
### Advanced use
|
||||
|
||||
To plot multiple pairs, separate them with a comma:
|
||||
```
|
||||
python scripts/plot_dataframe.py -p BTC/ETH,XRP/ETH
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -p BTC/ETH,XRP/ETH
|
||||
```
|
||||
|
||||
To plot the current live price use the `--live` flag:
|
||||
```
|
||||
python scripts/plot_dataframe.py -p BTC/ETH --live
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -p BTC/ETH --live
|
||||
```
|
||||
|
||||
To plot a timerange (to zoom in):
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -p BTC/ETH --timerange=100-200
|
||||
```
|
||||
python scripts/plot_dataframe.py -p BTC/ETH --timerange=100-200
|
||||
```
|
||||
|
||||
Timerange doesn't work with live data.
|
||||
|
||||
To plot trades stored in a database use `--db-url` argument:
|
||||
```
|
||||
python scripts/plot_dataframe.py --db-url sqlite:///tradesv3.dry_run.sqlite -p BTC/ETH
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py --db-url sqlite:///tradesv3.dry_run.sqlite -p BTC/ETH
|
||||
```
|
||||
|
||||
To plot a test strategy the strategy should have first be backtested.
|
||||
The results may then be plotted with the -s argument:
|
||||
To plot trades from a backtesting result, use `--export-filename <filename>`
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py --export-filename user_data/backtest_data/backtest-result.json -p BTC/ETH
|
||||
```
|
||||
python scripts/plot_dataframe.py -s Strategy_Name -p BTC/ETH --datadir user_data/data/<exchange_name>/
|
||||
|
||||
To plot a custom strategy the strategy should have first be backtested.
|
||||
The results may then be plotted with the -s argument:
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_dataframe.py -s Strategy_Name -p BTC/ETH --datadir user_data/data/<exchange_name>/
|
||||
```
|
||||
|
||||
## Plot profit
|
||||
|
||||
The profit plotter show a picture with three plots:
|
||||
The profit plotter shows a picture with three plots:
|
||||
|
||||
1) Average closing price for all pairs
|
||||
2) The summarized profit made by backtesting.
|
||||
Note that this is not the real-world profit, but
|
||||
@@ -67,7 +87,7 @@ The profit plotter show a picture with three plots:
|
||||
The first graph is good to get a grip of how the overall market
|
||||
progresses.
|
||||
|
||||
The second graph will show how you algorithm works or doesnt.
|
||||
The second graph will show how your algorithm works or doesn't.
|
||||
Perhaps you want an algorithm that steadily makes small profits,
|
||||
or one that acts less seldom, but makes big swings.
|
||||
|
||||
@@ -76,13 +96,14 @@ that makes profit spikes.
|
||||
|
||||
Usage for the profit plotter:
|
||||
|
||||
```
|
||||
script/plot_profit.py [-h] [-p pair] [--datadir directory] [--ticker_interval num]
|
||||
``` bash
|
||||
python3 script/plot_profit.py [-h] [-p pair] [--datadir directory] [--ticker_interval num]
|
||||
```
|
||||
|
||||
The `-p` pair argument, can be used to plot a single pair
|
||||
|
||||
Example
|
||||
```
|
||||
|
||||
``` bash
|
||||
python3 scripts/plot_profit.py --datadir ../freqtrade/freqtrade/tests/testdata-20171221/ -p LTC/BTC
|
||||
```
|
||||
|
193
docs/rest-api.md
Normal file
193
docs/rest-api.md
Normal file
@@ -0,0 +1,193 @@
|
||||
# REST API Usage
|
||||
|
||||
## Configuration
|
||||
|
||||
Enable the rest API by adding the api_server section to your configuration and setting `api_server.enabled` to `true`.
|
||||
|
||||
Sample configuration:
|
||||
|
||||
``` json
|
||||
"api_server": {
|
||||
"enabled": true,
|
||||
"listen_ip_address": "127.0.0.1",
|
||||
"listen_port": 8080,
|
||||
"username": "Freqtrader",
|
||||
"password": "SuperSecret1!"
|
||||
},
|
||||
```
|
||||
|
||||
!!! Danger: Security warning
|
||||
By default, the configuration listens on localhost only (so it's not reachable from other systems). We strongly recommend to not expose this API to the internet and choose a strong, unique password, since others will potentially be able to control your bot.
|
||||
|
||||
!!! Danger: Password selection
|
||||
Please make sure to select a very strong, unique password to protect your bot from unauthorized access.
|
||||
|
||||
You can then access the API by going to `http://127.0.0.1:8080/api/v1/version` to check if the API is running correctly.
|
||||
|
||||
To generate a secure password, either use a password manager, or use the below code snipped.
|
||||
|
||||
``` python
|
||||
import secrets
|
||||
secrets.token_hex()
|
||||
```
|
||||
|
||||
### Configuration with docker
|
||||
|
||||
If you run your bot using docker, you'll need to have the bot listen to incomming connections. The security is then handled by docker.
|
||||
|
||||
``` json
|
||||
"api_server": {
|
||||
"enabled": true,
|
||||
"listen_ip_address": "0.0.0.0",
|
||||
"listen_port": 8080
|
||||
},
|
||||
```
|
||||
|
||||
Add the following to your docker command:
|
||||
|
||||
``` bash
|
||||
-p 127.0.0.1:8080:8080
|
||||
```
|
||||
|
||||
A complete sample-command may then look as follows:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name freqtrade \
|
||||
-v ~/.freqtrade/config.json:/freqtrade/config.json \
|
||||
-v ~/.freqtrade/user_data/:/freqtrade/user_data \
|
||||
-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \
|
||||
-p 127.0.0.1:8080:8080 \
|
||||
freqtrade --db-url sqlite:///tradesv3.sqlite --strategy MyAwesomeStrategy
|
||||
```
|
||||
|
||||
!!! Danger "Security warning"
|
||||
By using `-p 8080:8080` the API is available to everyone connecting to the server under the correct port, so others may be able to control your bot.
|
||||
|
||||
## Consuming the API
|
||||
|
||||
You can consume the API by using the script `scripts/rest_client.py`.
|
||||
The client script only requires the `requests` module, so FreqTrade does not need to be installed on the system.
|
||||
|
||||
``` bash
|
||||
python3 scripts/rest_client.py <command> [optional parameters]
|
||||
```
|
||||
|
||||
By default, the script assumes `127.0.0.1` (localhost) and port `8080` to be used, however you can specify a configuration file to override this behaviour.
|
||||
|
||||
### Minimalistic client config
|
||||
|
||||
``` json
|
||||
{
|
||||
"api_server": {
|
||||
"enabled": true,
|
||||
"listen_ip_address": "0.0.0.0",
|
||||
"listen_port": 8080
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
``` bash
|
||||
python3 scripts/rest_client.py --config rest_config.json <command> [optional parameters]
|
||||
```
|
||||
|
||||
## Available commands
|
||||
|
||||
| Command | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `start` | | Starts the trader
|
||||
| `stop` | | Stops the trader
|
||||
| `stopbuy` | | Stops the trader from opening new trades. Gracefully closes open trades according to their rules.
|
||||
| `reload_conf` | | Reloads the configuration file
|
||||
| `status` | | Lists all open trades
|
||||
| `status table` | | List all open trades in a table format
|
||||
| `count` | | Displays number of trades used and available
|
||||
| `profit` | | Display a summary of your profit/loss from close trades and some stats about your performance
|
||||
| `forcesell <trade_id>` | | Instantly sells the given trade (Ignoring `minimum_roi`).
|
||||
| `forcesell all` | | Instantly sells all open trades (Ignoring `minimum_roi`).
|
||||
| `forcebuy <pair> [rate]` | | Instantly buys the given pair. Rate is optional. (`forcebuy_enable` must be set to True)
|
||||
| `performance` | | Show performance of each finished trade grouped by pair
|
||||
| `balance` | | Show account balance per currency
|
||||
| `daily <n>` | 7 | Shows profit or loss per day, over the last n days
|
||||
| `whitelist` | | Show the current whitelist
|
||||
| `blacklist [pair]` | | Show the current blacklist, or adds a pair to the blacklist.
|
||||
| `edge` | | Show validated pairs by Edge if it is enabled.
|
||||
| `version` | | Show version
|
||||
|
||||
Possible commands can be listed from the rest-client script using the `help` command.
|
||||
|
||||
``` bash
|
||||
python3 scripts/rest_client.py help
|
||||
```
|
||||
|
||||
``` output
|
||||
Possible commands:
|
||||
balance
|
||||
Get the account balance
|
||||
:returns: json object
|
||||
|
||||
blacklist
|
||||
Show the current blacklist
|
||||
:param add: List of coins to add (example: "BNB/BTC")
|
||||
:returns: json object
|
||||
|
||||
count
|
||||
Returns the amount of open trades
|
||||
:returns: json object
|
||||
|
||||
daily
|
||||
Returns the amount of open trades
|
||||
:returns: json object
|
||||
|
||||
edge
|
||||
Returns information about edge
|
||||
:returns: json object
|
||||
|
||||
forcebuy
|
||||
Buy an asset
|
||||
:param pair: Pair to buy (ETH/BTC)
|
||||
:param price: Optional - price to buy
|
||||
:returns: json object of the trade
|
||||
|
||||
forcesell
|
||||
Force-sell a trade
|
||||
:param tradeid: Id of the trade (can be received via status command)
|
||||
:returns: json object
|
||||
|
||||
performance
|
||||
Returns the performance of the different coins
|
||||
:returns: json object
|
||||
|
||||
profit
|
||||
Returns the profit summary
|
||||
:returns: json object
|
||||
|
||||
reload_conf
|
||||
Reload configuration
|
||||
:returns: json object
|
||||
|
||||
start
|
||||
Start the bot if it's in stopped state.
|
||||
:returns: json object
|
||||
|
||||
status
|
||||
Get the status of open trades
|
||||
:returns: json object
|
||||
|
||||
stop
|
||||
Stop the bot. Use start to restart
|
||||
:returns: json object
|
||||
|
||||
stopbuy
|
||||
Stop buying (but handle sells gracefully).
|
||||
use reload_conf to reset
|
||||
:returns: json object
|
||||
|
||||
version
|
||||
Returns the version of the bot
|
||||
:returns: json object containing the version
|
||||
|
||||
whitelist
|
||||
Show the current whitelist
|
||||
:returns: json object
|
||||
```
|
@@ -1,10 +1,45 @@
|
||||
# Telegram usage
|
||||
|
||||
## Prerequisite
|
||||
## Setup your Telegram bot
|
||||
|
||||
To control your bot with Telegram, you need first to
|
||||
[set up a Telegram bot](installation.md)
|
||||
and add your Telegram API keys into your config file.
|
||||
Below we explain how to create your Telegram Bot, and how to get your
|
||||
Telegram user id.
|
||||
|
||||
### 1. Create your Telegram bot
|
||||
|
||||
Start a chat with the [Telegram BotFather](https://telegram.me/BotFather)
|
||||
|
||||
Send the message `/newbot`.
|
||||
|
||||
*BotFather response:*
|
||||
|
||||
> Alright, a new bot. How are we going to call it? Please choose a name for your bot.
|
||||
|
||||
Choose the public name of your bot (e.x. `Freqtrade bot`)
|
||||
|
||||
*BotFather response:*
|
||||
|
||||
> Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
|
||||
|
||||
Choose the name id of your bot and send it to the BotFather (e.g. "`My_own_freqtrade_bot`")
|
||||
|
||||
*BotFather response:*
|
||||
|
||||
> Done! Congratulations on your new bot. You will find it at `t.me/yourbots_name_bot`. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
|
||||
|
||||
> Use this token to access the HTTP API: `22222222:APITOKEN`
|
||||
|
||||
> For a description of the Bot API, see this page: https://core.telegram.org/bots/api Father bot will return you the token (API key)
|
||||
|
||||
Copy the API Token (`22222222:APITOKEN` in the above example) and keep use it for the config parameter `token`.
|
||||
|
||||
Don't forget to start the conversation with your bot, by clicking `/START` button
|
||||
|
||||
### 2. Get your user id
|
||||
|
||||
Talk to the [userinfobot](https://telegram.me/userinfobot)
|
||||
|
||||
Get your "Id", you will use it for the config parameter `chat_id`.
|
||||
|
||||
## Telegram commands
|
||||
|
||||
|
Reference in New Issue
Block a user