Elffuss BraidHub

kikocis/freqtrade public

develop · 13.4 KiBRenderedRawPermalink
1# Installation
2
3This page explains how to prepare your environment for running the bot.
4
5The freqtrade documentation describes various ways to install freqtrade
6
7* [Docker images](docker_quickstart.md) (separate page)
8* [Script Installation](#script-installation)
9* [Manual Installation](#manual-installation)
10* [Installation with Conda](#installation-with-conda)
11
12Please consider using the prebuilt [docker images](docker_quickstart.md) to get started quickly while evaluating how freqtrade works.
13
14------
15
16## Information
17
18For Windows installation, please use the [windows installation guide](windows_installation.md).
19
20The easiest way to install and run Freqtrade is to clone the bot Github repository and then run the `./setup.sh` script, if it's available for your platform.
21
22!!! Note "Version considerations"
23 When cloning the repository the default working branch has the name `develop`. This branch contains all last features (can be considered as relatively stable, thanks to automated tests).
24 The `stable` branch contains the code of the last release (done usually once per month on an approximately one week old snapshot of the `develop` branch to prevent packaging bugs, so potentially it's more stable).
25
26!!! Note
27 Python3.7 or higher and the corresponding `pip` are assumed to be available. The install-script will warn you and stop if that's not the case. `git` is also needed to clone the Freqtrade repository.
28 Also, python headers (`python<yourversion>-dev` / `python<yourversion>-devel`) must be available for the installation to complete successfully.
29
30!!! Warning "Up-to-date clock"
31 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.
32
33------
34
35## Requirements
36
37These requirements apply to both [Script Installation](#script-installation) and [Manual Installation](#manual-installation).
38
39### Install guide
40
41* [Python >= 3.7.x](http://docs.python-guide.org/en/latest/starting/installation/)
42* [pip](https://pip.pypa.io/en/stable/installing/)
43* [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
44* [virtualenv](https://virtualenv.pypa.io/en/stable/installation.html) (Recommended)
45* [TA-Lib](https://mrjbq7.github.io/ta-lib/install.html) (install instructions [below](#install-ta-lib))
46
47### Install code
48
49We've included/collected install instructions for Ubuntu, MacOS, and Windows. These are guidelines and your success may vary with other distros.
50OS Specific steps are listed first, the [Common](#common) section below is necessary for all systems.
51
52!!! Note
53 Python3.7 or higher and the corresponding pip are assumed to be available.
54
55=== "Debian/Ubuntu"
56 #### Install necessary dependencies
57
58 ```bash
59 # update repository
60 sudo apt-get update
61
62 # install packages
63 sudo apt install -y python3-pip python3-venv python3-pandas python3-pip git
64 ```
65
66=== "RaspberryPi/Raspbian"
67 The following assumes the latest [Raspbian Buster lite image](https://www.raspberrypi.org/downloads/raspbian/).
68 This image comes with python3.7 preinstalled, making it easy to get freqtrade up and running.
69
70 Tested using a Raspberry Pi 3 with the Raspbian Buster lite image, all updates applied.
71
72
73 ```bash
74 sudo apt-get install python3-venv libatlas-base-dev cmake
75 # Use pywheels.org to speed up installation
76 sudo echo "[global]\nextra-index-url=https://www.piwheels.org/simple" > tee /etc/pip.conf
77
78 git clone https://github.com/freqtrade/freqtrade.git
79 cd freqtrade
80
81 bash setup.sh -i
82 ```
83
84 !!! Note "Installation duration"
85 Depending on your internet speed and the Raspberry Pi version, installation can take multiple hours to complete.
86 Due to this, we recommend to use the pre-build docker-image for Raspberry, by following the [Docker quickstart documentation](docker_quickstart.md)
87
88 !!! Note
89 The above does not install hyperopt dependencies. To install these, please use `python3 -m pip install -e .[hyperopt]`.
90 We do not advise to run hyperopt on a Raspberry Pi, since this is a very resource-heavy operation, which should be done on powerful machine.
91
92------
93
94## Freqtrade repository
95
96Freqtrade is an open source crypto-currency trading bot, whose code is hosted on `github.com`
97
98```bash
99# Download `develop` branch of freqtrade repository
100git clone https://github.com/freqtrade/freqtrade.git
101
102# Enter downloaded directory
103cd freqtrade
104
105# your choice (1): novice user
106git checkout stable
107
108# your choice (2): advanced user
109git checkout develop
110```
111
112(1) This command switches the cloned repository to the use of the `stable` branch. It's not needed, if you wish to stay on the (2) `develop` branch.
113
114You may later switch between branches at any time with the `git checkout stable`/`git checkout develop` commands.
115
116------
117
118## Script Installation
119
120First of the ways to install Freqtrade, is to use provided the Linux/MacOS `./setup.sh` script, which install all dependencies and help you configure the bot.
121
122Make sure you fulfill the [Requirements](#requirements) and have downloaded the [Freqtrade repository](#freqtrade-repository).
123
124### Use /setup.sh -install (Linux/MacOS)
125
126If you are on Debian, Ubuntu or MacOS, freqtrade provides the script to install freqtrade.
127
128```bash
129# --install, Install freqtrade from scratch
130./setup.sh -i
131```
132
133### Activate your virtual environment
134
135Each time you open a new terminal, you must run `source .env/bin/activate` to activate your virtual environment.
136
137```bash
138# then activate your .env
139source ./.env/bin/activate
140```
141
142### Congratulations
143
144[You are ready](#you-are-ready), and run the bot
145
146### Other options of /setup.sh script
147
148You can as well update, configure and reset the codebase of your bot with `./script.sh`
149
150```bash
151# --update, Command git pull to update.
152./setup.sh -u
153# --reset, Hard reset your develop/stable branch.
154./setup.sh -r
155```
156
157```
158** --install **
159
160With this option, the script will install the bot and most dependencies:
161You will need to have git and python3.7+ installed beforehand for this to work.
162
163* Mandatory software as: `ta-lib`
164* Setup your virtualenv under `.env/`
165
166This option is a combination of installation tasks and `--reset`
167
168** --update **
169
170This option will pull the last version of your current branch and update your virtualenv. Run the script with this option periodically to update your bot.
171
172** --reset **
173
174This option will hard reset your branch (only if you are on either `stable` or `develop`) and recreate your virtualenv.
175```
176
177-----
178
179## Manual Installation
180
181Make sure you fulfill the [Requirements](#requirements) and have downloaded the [Freqtrade repository](#freqtrade-repository).
182
183### Install TA-Lib
184
185#### TA-Lib script installation
186
187```bash
188sudo ./build_helpers/install_ta-lib.sh
189```
190
191!!! Note
192 This will use the ta-lib tar.gz included in this repository.
193
194##### TA-Lib manual installation
195
196Official webpage: https://mrjbq7.github.io/ta-lib/install.html
197
198```bash
199wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
200tar xvzf ta-lib-0.4.0-src.tar.gz
201cd ta-lib
202sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h
203./configure --prefix=/usr/local
204make
205sudo make install
206cd ..
207rm -rf ./ta-lib*
208```
209
210#### Setup Python virtual environment (virtualenv)
211
212You will run freqtrade in separated `virtual environment`
213
214```bash
215# create virtualenv in directory /freqtrade/.env
216python3 -m venv .env
217
218# run virtualenv
219source .env/bin/activate
220```
221
222#### Install python dependencies
223
224```bash
225python3 -m pip install --upgrade pip
226python3 -m pip install -e .
227```
228
229### Congratulations
230
231[You are ready](#you-are-ready), and run the bot
232
233#### (Optional) Post-installation Tasks
234
235!!! Note
236 If you run the bot on a server, you should consider using [Docker](docker_quickstart.md) or a terminal multiplexer like `screen` or [`tmux`](https://en.wikipedia.org/wiki/Tmux) to avoid that the bot is stopped on logout.
237
238On Linux with software suite `systemd`, as an optional post-installation task, you may wish to setup the bot to run as a `systemd service` or configure it to send the log messages to the `syslog`/`rsyslog` or `journald` daemons. See [Advanced Logging](advanced-setup.md#advanced-logging) for details.
239
240------
241
242## Installation with Conda
243
244Freqtrade can also be installed with Miniconda or Anaconda. We recommend using Miniconda as it's installation footprint is smaller. Conda will automatically prepare and manage the extensive library-dependencies of the Freqtrade program.
245
246### What is Conda?
247
248Conda is a package, dependency and environment manager for multiple programming languages: [conda docs](https://docs.conda.io/projects/conda/en/latest/index.html)
249
250### Installation with conda
251
252#### Install Conda
253
254[Installing on linux](https://conda.io/projects/conda/en/latest/user-guide/install/linux.html#install-linux-silent)
255
256[Installing on windows](https://conda.io/projects/conda/en/latest/user-guide/install/windows.html)
257
258Answer all questions. After installation, it is mandatory to turn your terminal OFF and ON again.
259
260#### Freqtrade download
261
262Download and install freqtrade.
263
264```bash
265# download freqtrade
266git clone https://github.com/freqtrade/freqtrade.git
267
268# enter downloaded directory 'freqtrade'
269cd freqtrade
270```
271
272#### Freqtrade instal: Conda Environment
273
274Prepare conda-freqtrade environment, using file `environment.yml`, which exist in main freqtrade directory
275
276```bash
277conda env create -n freqtrade-conda -f environment.yml
278```
279
280!!! Note "Creating Conda Environment"
281 The conda command `create -n` automatically installs all nested dependencies for the selected libraries, general structure of installation command is:
282
283 ```bash
284 # choose your own packages
285 conda env create -n [name of the environment] [python version] [packages]
286
287 # point to file with packages
288 conda env create -n [name of the environment] -f [file]
289 ```
290
291#### Enter/exit freqtrade-conda environment
292
293To check available environments, type
294
295```bash
296conda env list
297```
298
299Enter installed environment
300
301```bash
302# enter conda environment
303conda activate freqtrade-conda
304
305# exit conda environment - don't do it now
306conda deactivate
307```
308
309Install last python dependencies with pip
310
311```bash
312python3 -m pip install --upgrade pip
313python3 -m pip install -e .
314```
315
316### Congratulations
317
318[You are ready](#you-are-ready), and run the bot
319
320### Important shortcuts
321
322```bash
323# list installed conda environments
324conda env list
325
326# activate base environment
327conda activate
328
329# activate freqtrade-conda environment
330conda activate freqtrade-conda
331
332#deactivate any conda environments
333conda deactivate
334```
335
336### Further info on anaconda
337
338!!! Info "New heavy packages"
339 It may happen that creating a new Conda environment, populated with selected packages at the moment of creation takes less time than installing a large, heavy library or application, into previously set environment.
340
341!!! Warning "pip install within conda"
342 The documentation of conda says that pip should NOT be used within conda, because internal problems can occur.
343 However, they are rare. [Anaconda Blogpost](https://www.anaconda.com/blog/using-pip-in-a-conda-environment)
344
345 Nevertheless, that is why, the `conda-forge` channel is preferred:
346
347 * more libraries are available (less need for `pip`)
348 * `conda-forge` works better with `pip`
349 * the libraries are newer
350
351Happy trading!
352
353-----
354
355## You are ready
356
357You've made it this far, so you have successfully installed freqtrade.
358
359### Initialize the configuration
360
361```bash
362# Step 1 - Initialize user folder
363freqtrade create-userdir --userdir user_data
364
365# Step 2 - Create a new configuration file
366freqtrade new-config --config config.json
367```
368
369You are ready to run, read [Bot Configuration](configuration.md), remember to start with `dry_run: True` and verify that everything is working.
370
371To learn how to setup your configuration, please refer to the [Bot Configuration](configuration.md) documentation page.
372
373### Start the Bot
374
375```bash
376freqtrade trade --config config.json --strategy SampleStrategy
377```
378
379!!! Warning
380 You should read through the rest of the documentation, backtest the strategy you're going to use, and use dry-run before enabling trading with real money.
381
382-----
383
384## Troubleshooting
385
386### Common problem: "command not found"
387
388If you used (1)`Script` or (2)`Manual` installation, you need to run the bot in virtual environment. If you get error as below, make sure venv is active.
389
390```bash
391# if:
392bash: freqtrade: command not found
393
394# then activate your .env
395source ./.env/bin/activate
396```
397
398### MacOS installation error
399
400Newer versions of MacOS may have installation failed with errors like `error: command 'g++' failed with exit status 1`.
401
402This error will require explicit installation of the SDK Headers, which are not installed by default in this version of MacOS.
403For MacOS 10.14, this can be accomplished with the below command.
404
405```bash
406open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
407```
408
409If this file is inexistent, then you're probably on a different version of MacOS, so you may need to consult the internet for specific resolution details.
410
411### MacOS installation error with python 3.9
412
413When using python 3.9 on macOS, it's currently necessary to install some os-level modules to allow dependencies to compile.
414The errors you'll see happen during installation and are related to the installation of `tables` or `blosc`.
415
416You can install the necessary libraries with the following command:
417
418```bash
419brew install hdf5 c-blosc
420```
421
422After this, please run the installation (script) again.