p:: Crypto

GitHub - freqtrade/freqtrade: Free, open source crypto trading bot

Docker quick start

Quickstart with Docker - Freqtrade

mkdir ft_userdata
cd ft_userdata/
# Download the docker-compose file from the repository
curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml
 
# Pull the freqtrade image
docker-compose pull
 
# Create user directory structure
docker-compose run --rm freqtrade create-userdir --userdir user_data
 
# Create configuration - Requires answering interactive questions
docker-compose run --rm freqtrade new-config --config user_data/config.json
2022-12-25 18:04:40,883 - freqtrade - INFO - freqtrade 2022.11
? Do you want to enable Dry-run (simulated trades)? Yes
? Please insert your stake currency: USDT
? Please insert your stake amount (Number or 'unlimited'): 100
? Please insert max_open_trades (Integer or -1 for unlimited open trades): 3
? Time Have the strategy define timeframe.
? Please insert your display Currency (for reporting): USD
? Select exchange binance
? Do you want to trade Perpetual Swaps (perpetual futures)? No
? Do you want to enable Telegram? No
? Do you want to enable the Rest API (includes FreqUI)? Yes
? Insert Api server Listen Address (0.0.0.0 for docker, otherwise best left untouched) 0.0.0.0
? Insert api-server username freqtrader
? Insert api-server password ***********
2022-12-25 18:05:19,833 - freqtrade.commands.build_config_commands - INFO - Writing config to `user_data/config.json`.
2022-12-25 18:05:19,833 - freqtrade.commands.build_config_commands - INFO - Please make sure to check the configuration contents and adjust settings to your needs.
vim user_data/config.json
...
"pair_whitelist": ["BTC/USDT", "ETH/USDT"],
...
docker-compose run --rm \
	freqtrade download-data \
	--config user_data/config.json \
	--days 9 \
	-t 5m
2022-12-25 18:26:25,093 - freqtrade - INFO - freqtrade 2022.11
2022-12-25 18:26:25,093 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2022-12-25 18:26:25,099 - freqtrade.loggers - INFO - Verbosity set to 0
2022-12-25 18:26:25,127 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2022-12-25 18:26:25,127 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2022-12-25 18:26:25,128 - freqtrade.configuration.configuration - INFO - timeframes --timeframes: ['5m']
2022-12-25 18:26:25,128 - freqtrade.configuration.configuration - INFO - Detected --days: 9
2022-12-25 18:26:25,128 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2022-12-25 18:26:25,133 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2022-12-25 18:26:25,134 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2022-12-25 18:26:25,134 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-12-25 18:26:25,136 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2022-12-25 18:26:25,136 - freqtrade.exchange.exchange - INFO - Using CCXT 2.1.96
2022-12-25 18:26:25,145 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2022-12-25 18:26:25,145 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2022-12-25 18:26:25,145 - freqtrade.exchange.exchange - INFO - Markets were not loaded. Loading them now..
2022-12-25 18:26:26,341 - freqtrade.commands.data_commands - INFO - About to download pairs: ['BTC/USDT', 'ETH/USDT'], intervals: ['5m'] to /freqtrade/user_data/data/binance
2022-12-25 18:26:26,342 - freqtrade.data.history.history_utils - INFO - Downloading pair BTC/USDT, interval 5m.
2022-12-25 18:26:26,345 - freqtrade.data.history.history_utils - INFO - (1/2) - Download history data for "BTC/USDT", 5m, spot and store in /freqtrade/user_data/data/binance. From 2022-12-16T00:00:00 to now
2022-12-25 18:26:28,473 - freqtrade.exchange.exchange - INFO - Downloaded data for BTC/USDT with length 2814.
2022-12-25 18:26:28,492 - freqtrade.data.history.history_utils - INFO - Downloading pair ETH/USDT, interval 5m.
2022-12-25 18:26:28,495 - freqtrade.data.history.history_utils - INFO - (2/2) - Download history data for "ETH/USDT", 5m, spot and store in /freqtrade/user_data/data/binance. From 2022-12-16T00:00:00 to now
2022-12-25 18:26:29,560 - freqtrade.exchange.exchange - INFO - Downloaded data for ETH/USDT with length 2814.
vim user_data/config.json
...
"pairlists": [{ "method": "StaticPairList" }],
...
docker-compose run --rm \
	freqtrade backtesting \
	--config user_data/config.json \
	--strategy SampleStrategy
2022-12-25 18:28:31,692 - freqtrade - INFO - freqtrade 2022.11
2022-12-25 18:28:31,700 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2022-12-25 18:28:31,702 - freqtrade.loggers - INFO - Verbosity set to 0
2022-12-25 18:28:31,702 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2022-12-25 18:28:31,736 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2022-12-25 18:28:31,736 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2022-12-25 18:28:31,736 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2022-12-25 18:28:31,737 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2022-12-25 18:28:31,742 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2022-12-25 18:28:31,742 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2022-12-25 18:28:31,742 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-12-25 18:28:31,744 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2022-12-25 18:28:31,744 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2022-12-25 18:28:31,744 - freqtrade.exchange.exchange - INFO - Using CCXT 2.1.96
2022-12-25 18:28:31,755 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2022-12-25 18:28:33,445 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2022-12-25 18:28:33,459 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy SampleStrategy from '/freqtrade/user_data/strategies/sample_strategy.py'...
2022-12-25 18:28:33,459 - freqtrade.strategy.hyper - INFO - Found no parameter file.
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 100.
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}.
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'60': 0.01, '30': 0.02, '0': 0.04}
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 5m
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.1
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.0
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False}
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 100
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using protections: []
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 30
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2022-12-25 18:28:33,460 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2022-12-25 18:28:33,460 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-12-25 18:28:33,466 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
2022-12-25 18:28:33,471 - freqtrade.data.history.history_utils - INFO - Using indicator startup period: 30 ...
2022-12-25 18:28:33,499 - freqtrade.optimize.backtesting - INFO - Loading data from 2022-12-16 00:00:00 up to 2022-12-25 18:20:00 (9 days).
2022-12-25 18:28:33,499 - freqtrade.configuration.timerange - WARNING - Moving start-date by 30 candles to account for startup time.
2022-12-25 18:28:33,499 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2022-12-25 18:28:33,501 - freqtrade.optimize.backtesting - WARNING - Backtest result caching disabled due to use of open-ended timerange.
2022-12-25 18:28:33,501 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy SampleStrategy
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - No params for buy found, using default values.
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - Strategy Parameter(default): buy_rsi = 30
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - Strategy Parameter(default): exit_short_rsi = 30
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - No params for sell found, using default values.
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - Strategy Parameter(default): sell_rsi = 70
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - Strategy Parameter(default): short_rsi = 70
2022-12-25 18:28:33,501 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
2022-12-25 18:28:33,513 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2022-12-16 02:30:00 up to 2022-12-25 18:20:00 (9 days).
2022-12-25 18:28:33,983 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2022-12-25_18-28-33.meta.json"
2022-12-25 18:28:33,986 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2022-12-25_18-28-33.json"
2022-12-25 18:28:33,988 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/.last_result.json"
Result for strategy SampleStrategy
============================================================ BACKTESTING REPORT ============================================================
|     Pair |   Entries |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |     Avg Duration |   Win  Draw  Loss  Win% |
|----------+-----------+----------------+----------------+-------------------+----------------+------------------+-------------------------|
| ETH/USDT |         3 |           0.36 |           1.08 |             1.085 |           0.11 |  1 day, 15:50:00 |     2     0     1  66.7 |
| BTC/USDT |         1 |          -1.48 |          -1.48 |            -1.475 |          -0.15 |  9 days, 7:45:00 |     0     0     1     0 |
|    TOTAL |         4 |          -0.10 |          -0.39 |            -0.390 |          -0.04 | 3 days, 13:49:00 |     2     0     2  50.0 |
============================================================ ENTER TAG STATS ============================================================
|   TAG |   Entries |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |     Avg Duration |   Win  Draw  Loss  Win% |
|-------+-----------+----------------+----------------+-------------------+----------------+------------------+-------------------------|
| TOTAL |         4 |          -0.10 |          -0.39 |            -0.390 |          -0.04 | 3 days, 13:49:00 |     2     0     2  50.0 |
===================================================== EXIT REASON STATS =====================================================
|   Exit Reason |   Exits |   Win  Draws  Loss  Win% |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |
|---------------+---------+--------------------------+----------------+----------------+-------------------+----------------|
|           roi |       2 |      2     0     0   100 |            1   |           2    |              2    |            1   |
|    force_exit |       2 |      0     0     2     0 |           -1.2 |          -2.39 |             -2.39 |           -1.2 |
========================================================= LEFT OPEN TRADES REPORT ==========================================================
|     Pair |   Entries |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |     Avg Duration |   Win  Draw  Loss  Win% |
|----------+-----------+----------------+----------------+-------------------+----------------+------------------+-------------------------|
| ETH/USDT |         1 |          -0.91 |          -0.91 |            -0.915 |          -0.09 |         12:50:00 |     0     0     1     0 |
| BTC/USDT |         1 |          -1.48 |          -1.48 |            -1.475 |          -0.15 |  9 days, 7:45:00 |     0     0     1     0 |
|    TOTAL |         2 |          -1.20 |          -2.39 |            -2.390 |          -0.24 | 4 days, 22:18:00 |     0     0     2     0 |
================== SUMMARY METRICS ==================
| Metric                      | Value               |
|-----------------------------+---------------------|
| Backtesting from            | 2022-12-16 02:30:00 |
| Backtesting to              | 2022-12-25 18:20:00 |
| Max open trades             | 2                   |
|                             |                     |
| Total/Daily Avg Trades      | 4 / 0.44            |
| Starting balance            | 1000 USDT           |
| Final balance               | 999.61 USDT         |
| Absolute profit             | -0.39 USDT          |
| Total profit %              | -0.04%              |
| CAGR %                      | -1.57%              |
| Profit factor               | 0.84                |
| Trades per day              | 0.44                |
| Avg. daily profit %         | -0.00%              |
| Avg. stake amount           | 99.95 USDT          |
| Total trade volume          | 399.8 USDT          |
|                             |                     |
| Best Pair                   | ETH/USDT 1.08%      |
| Worst Pair                  | BTC/USDT -1.48%     |
| Best trade                  | ETH/USDT 1.00%      |
| Worst trade                 | BTC/USDT -1.48%     |
| Best day                    | 1 USDT              |
| Worst day                   | -2.39 USDT          |
| Days win/draw/lose          | 2 / 3 / 1           |
| Avg. Duration Winners       | 2 days, 5:20:00     |
| Avg. Duration Loser         | 4 days, 22:18:00    |
| Rejected Entry signals      | 0                   |
| Entry/Exit Timeouts         | 0 / 0               |
|                             |                     |
| Min balance                 | 999.61 USDT         |
| Max balance                 | 1002 USDT           |
| Max % of account underwater | 0.24%               |
| Absolute Drawdown (Account) | 0.24%               |
| Absolute Drawdown           | 2.39 USDT           |
| Drawdown high               | 2 USDT              |
| Drawdown low                | -0.39 USDT          |
| Drawdown Start              | 2022-12-22 20:20:00 |
| Drawdown End                | 2022-12-25 18:20:00 |
| Market change               | -3.95%              |
=====================================================
docker-compose run --rm \
	freqtrade new-strategy \
	--strategy SmaRsiStrategy
2022-12-25 18:48:29,479 - freqtrade - INFO - freqtrade 2022.11
2022-12-25 18:48:29,480 - freqtrade.loggers - INFO - Verbosity set to 0
2022-12-25 18:48:29,522 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2022-12-25 18:48:29,523 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data ...
2022-12-25 18:48:29,523 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-12-25 18:48:29,539 - freqtrade.commands.deploy_commands - INFO - Writing strategy to `/freqtrade/user_data/strategies/SmaRsiStrategy.py`.
vim user_data/config.json
...
"pair_whitelist": ["BTC/USDT", "ETH/USDT"],
...
docker-compose run --rm \
	freqtrade download-data \
	--config user_data/config.json \
	--days 200 \
	-t 1d
docker-compose run --rm \
	freqtrade backtesting \
	--config user_data/config.json \
	--strategy SmaRsiStrategy
...
 
================== SUMMARY METRICS ==================
| Metric                      | Value               |
|-----------------------------+---------------------|
| Backtesting from            | 2022-07-03 00:00:00 |
| Backtesting to              | 2022-12-24 00:00:00 |
| Max open trades             | 3                   |
|                             |                     |
| Total/Daily Avg Trades      | 17 / 0.1            |
| Starting balance            | 1000 USDT           |
| Final balance               | 978.711 USDT        |
| Absolute profit             | -21.289 USDT        |
| Total profit %              | -2.13%              |
| CAGR %                      | -4.41%              |
| Profit factor               | 0.63                |
| Trades per day              | 0.1                 |
| Avg. daily profit %         | -0.01%              |
| Avg. stake amount           | 99.918 USDT         |
| Total trade volume          | 1698.612 USDT       |
|                             |                     |
| Best Pair                   | XRP/USDT 27.82%     |
| Worst Pair                  | BTC/USDT -17.19%    |
| Best trade                  | XRP/USDT 30.57%     |
| Worst trade                 | BTC/USDT -10.18%    |
| Best day                    | 20.35 USDT          |
| Worst day                   | -12.729 USDT        |
| Days win/draw/lose          | 3 / 138 / 10        |
| Avg. Duration Winners       | 36 days, 8:00:00    |
| Avg. Duration Loser         | 9 days, 20:34:00    |
| Rejected Entry signals      | 83                  |
| Entry/Exit Timeouts         | 0 / 0               |
|                             |                     |
| Min balance                 | 961.713 USDT        |
| Max balance                 | 996.684 USDT        |
| Max % of account underwater | 3.51%               |
| Absolute Drawdown (Account) | 3.51%               |
| Absolute Drawdown           | 34.971 USDT         |
| Drawdown high               | -3.316 USDT         |
| Drawdown low                | -38.287 USDT        |
| Drawdown Start              | 2022-08-18 00:00:00 |
| Drawdown End                | 2022-11-08 00:00:00 |
| Market change               | -28.13%             |
=====================================================

Once this is done, you’re ready to launch the bot in trading mode (Dry-run or Live-trading, depending on your answer to the corresponding question you made above).

docker-compose up -d

Accessing the UI

Quickstart with Docker - Freqtrade

If you’ve selected to enable FreqUI in the new-config step, you will have freqUI available at port http://localhost:8080.