<metaname="description"content="Freqtrade is a free and open source crypto trading bot written in Python, designed to support all major exchanges and be controlled via Telegram or builtin Web UI">
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="default"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to dark mode"type="radio"name="__palette"id="__palette_0">
<labelclass="md-header__button md-icon"title="Switch to dark mode"for="__palette_1"hidden>
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="slate"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to light mode"type="radio"name="__palette"id="__palette_1">
<labelclass="md-header__button md-icon"title="Switch to light mode"for="__palette_0"hidden>
<p>This page explains some advanced tasks and configuration options that can be performed after the bot installation and may be uselful in some environments.</p>
<p>If you do not know what things mentioned here mean, you probably do not need it.</p>
<h2id="running-multiple-instances-of-freqtrade">Running multiple instances of Freqtrade<aclass="headerlink"href="#running-multiple-instances-of-freqtrade"title="Permanent link">¶</a></h2>
<p>This section will show you how to run multiple bots at the same time, on the same machine.</p>
<h3id="things-to-consider">Things to consider<aclass="headerlink"href="#things-to-consider"title="Permanent link">¶</a></h3>
<ul>
<li>Use different database files.</li>
<li>Use different Telegram bots (requires multiple different configuration files; applies only when Telegram is enabled).</li>
<li>Use different ports (applies only when Freqtrade REST API webserver is enabled).</li>
<p>In order to keep track of your trades, profits, etc., freqtrade is using a SQLite database where it stores various types of information such as the trades you performed in the past and the current position(s) you are holding at any time. This allows you to keep track of your profits, but most importantly, keep track of ongoing activity if the bot process would be restarted or would be terminated unexpectedly.</p>
<p>Freqtrade will, by default, use separate database files for dry-run and live bots (this assumes no database-url is given in either configuration nor via command line argument).
For live trading mode, the default database will be <code>tradesv3.sqlite</code> and for dry-run it will be <code>tradesv3.dryrun.sqlite</code>.</p>
<p>The optional argument to the trade command used to specify the path of these files is <code>--db-url</code>, which requires a valid SQLAlchemy url.
So when you are starting a bot with only the config and strategy arguments in dry-run mode, the following 2 commands would have the same outcome.</p>
<p>It means that if you are running the trade command in two different terminals, for example to test your strategy both for trades in USDT and in another instance for trades in BTC, you will have to run them with different databases.</p>
<p>If you specify the URL of a database which does not exist, freqtrade will create one with the name you specified. So to test your custom strategy with BTC and USDT stake currencies, you could use the following commands (in 2 separate terminals):</p>
<p>Conversely, if you wish to do the same thing in production mode, you will also have to create at least one new database (in addition to the default one) and specify the path to the "live" databases, for example:</p>
<p>For more information regarding usage of the sqlite databases, for example to manually enter or remove trades, please refer to the <ahref="../sql_cheatsheet/">SQL Cheatsheet</a>.</p>
<h3id="multiple-instances-using-docker">Multiple instances using docker<aclass="headerlink"href="#multiple-instances-using-docker"title="Permanent link">¶</a></h3>
<p>To run multiple instances of freqtrade using docker you will need to edit the docker-compose.yml file and add all the instances you want as separate services. Remember, you can separate your configuration into multiple files, so it's a good idea to think about making them modular, then if you need to edit something common to all bots, you can do that in a single config file.
<divclass="highlight"><pre><span></span><code>---
version: '3'
services:
freqtrade1:
image: freqtradeorg/freqtrade:stable
# image: freqtradeorg/freqtrade:develop
# Use plotting image
# image: freqtradeorg/freqtrade:develop_plot
# Build step - only needed when additional dependencies are needed
<p>You can use whatever naming convention you want, freqtrade1 and 2 are arbitrary. Note, that you will need to use different database files, port mappings and telegram configurations for each instance, as mentioned above. </p>
<h2id="use-a-different-database-system">Use a different database system<aclass="headerlink"href="#use-a-different-database-system"title="Permanent link">¶</a></h2>
<p>Freqtrade is using SQLAlchemy, which supports multiple different database systems. As such, a multitude of database systems should be supported.
Freqtrade does not depend or install any additional database driver. Please refer to the <ahref="https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls">SQLAlchemy docs</a> on installation instructions for the respective database systems.</p>
<p>The following systems have been tested and are known to work with freqtrade:</p>
<ul>
<li>sqlite (default)</li>
<li>PostgreSQL</li>
<li>MariaDB</li>
</ul>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>By using one of the below database systems, you acknowledge that you know how to manage such a system. The freqtrade team will not provide any support with setup or maintenance (or backups) of the below database systems.</p>
<p>Freqtrade will automatically create the tables necessary upon startup.</p>
<p>If you're running different instances of Freqtrade, you must either setup one database per Instance or use different users / schemas for your connections.</p>
<h2id="configure-the-bot-running-as-a-systemd-service">Configure the bot running as a systemd service<aclass="headerlink"href="#configure-the-bot-running-as-a-systemd-service"title="Permanent link">¶</a></h2>
<p>Copy the <code>freqtrade.service</code> file to your systemd user directory (usually <code>~/.config/systemd/user</code>) and update <code>WorkingDirectory</code> and <code>ExecStart</code> to match your setup.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>Certain systems (like Raspbian) don't load service unit files from the user directory. In this case, copy <code>freqtrade.service</code> into <code>/etc/systemd/user/</code> (requires superuser permissions).</p>
<p>On many Linux systems the bot can be configured to send its log messages to <code>syslog</code> or <code>journald</code> system services. Logging to a remote <code>syslog</code> server is also available on Windows. The special values for the <code>--logfile</code> command line option can be used for this.</p>
<h3id="logging-to-syslog">Logging to syslog<aclass="headerlink"href="#logging-to-syslog"title="Permanent link">¶</a></h3>
<p>To send Freqtrade log messages to a local or remote <code>syslog</code> service use the <code>--logfile</code> command line option with the value in the following format:</p>
<ul>
<li><code>--logfile syslog:<syslog_address></code> -- send log messages to <code>syslog</code> service using the <code><syslog_address></code> as the syslog address.</li>
</ul>
<p>The syslog address can be either a Unix domain socket (socket filename) or a UDP socket specification, consisting of IP address and UDP port, separated by the <code>:</code> character.</p>
<p>So, the following are the examples of possible usages:</p>
<ul>
<li><code>--logfile syslog:/dev/log</code> -- log to syslog (rsyslog) using the <code>/dev/log</code> socket, suitable for most systems.</li>
<li><code>--logfile syslog</code> -- same as above, the shortcut for <code>/dev/log</code>.</li>
<li><code>--logfile syslog:/var/run/syslog</code> -- log to syslog (rsyslog) using the <code>/var/run/syslog</code> socket. Use this on MacOS.</li>
<li><code>--logfile syslog:localhost:514</code> -- log to local syslog using UDP socket, if it listens on port 514.</li>
<li><code>--logfile syslog:<ip>:514</code> -- log to remote syslog at IP address and port 514. This may be used on Windows for remote logging to an external syslog server.</li>
</ul>
<p>Log messages are send to <code>syslog</code> with the <code>user</code> facility. So you can see them with the following commands:</p>
<ul>
<li><code>tail -f /var/log/user</code>, or </li>
<li>install a comprehensive graphical viewer (for instance, 'Log File Viewer' for Ubuntu).</li>
</ul>
<p>On many systems <code>syslog</code> (<code>rsyslog</code>) fetches data from <code>journald</code> (and vice versa), so both <code>--logfile syslog</code> or <code>--logfile journald</code> can be used and the messages be viewed with both <code>journalctl</code> and a syslog viewer utility. You can combine this in any way which suites you better.</p>
<p>For <code>rsyslog</code> the messages from the bot can be redirected into a separate dedicated log file. To achieve this, add</p>
<divclass="highlight"><pre><span></span><code>if $programname startswith "freqtrade" then -/var/log/freqtrade.log
</code></pre></div>
<p>to one of the rsyslog configuration files, for example at the end of the <code>/etc/rsyslog.d/50-default.conf</code>.</p>
<p>For <code>syslog</code> (<code>rsyslog</code>), the reduction mode can be switched on. This will reduce the number of repeating messages. For instance, multiple bot Heartbeat messages will be reduced to a single message when nothing else happens with the bot. To achieve this, set in <code>/etc/rsyslog.conf</code>:</p>
<h3id="logging-to-journald">Logging to journald<aclass="headerlink"href="#logging-to-journald"title="Permanent link">¶</a></h3>
<p>This needs the <code>cysystemd</code> python package installed as dependency (<code>pip install cysystemd</code>), which is not available on Windows. Hence, the whole journald logging functionality is not available for a bot running on Windows.</p>
<p>To send Freqtrade log messages to <code>journald</code> system service use the <code>--logfile</code> command line option with the value in the following format:</p>
<ul>
<li><code>--logfile journald</code> -- send log messages to <code>journald</code>.</li>
</ul>
<p>Log messages are send to <code>journald</code> with the <code>user</code> facility. So you can see them with the following commands:</p>
<ul>
<li><code>journalctl -f</code> -- shows Freqtrade log messages sent to <code>journald</code> along with other log messages fetched by <code>journald</code>.</li>
<li><code>journalctl -f -u freqtrade.service</code> -- this command can be used when the bot is run as a <code>systemd</code> service.</li>
</ul>
<p>There are many other options in the <code>journalctl</code> utility to filter the messages, see manual pages for this utility.</p>
<p>On many systems <code>syslog</code> (<code>rsyslog</code>) fetches data from <code>journald</code> (and vice versa), so both <code>--logfile syslog</code> or <code>--logfile journald</code> can be used and the messages be viewed with both <code>journalctl</code> and a syslog viewer utility. You can combine this in any way which suites you better.</p>
<scriptid="__config"type="application/json">{"base":"..","features":["content.code.annotate","search.share","content.code.copy","navigation.top","navigation.footer"],"search":"../assets/javascripts/workers/search.07f07601.min.js","translations":{"clipboard.copied":"Copied to clipboard","clipboard.copy":"Copy to clipboard","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.placeholder":"Type to start searching","search.result.term.missing":"Missing","select.version":"Select version"},"version":{"alias":true,"provider":"mike"}}</script>