Install extra TA modules in Freqtrade Docker (Patreon)
Content

Hi There, and welcome to this post where I will show you how you can add additional python modules, like TA libraries, to your Freqtrade Docker Image.
This is especially important imformation if you run scripts or strategies that use Python modules that are not part of the default Docker Image of the Freqtrade trading bot. In these cases the code will stop with an error that it cannot find a module. And thus you cannot run the strategy.
This is a full instruction post, so I will begin with the installation of Docker, then install Freqtrade Docker and finally show you how to install additional modules in a custom Freqtrade Docker image to use with your bot!
I Fully installed this on a Linux Mint machine. I also tried to do this installation on a Windows 10 WSL VM, but there were so many problems that I eventually gave up on it. Windows is not my preferred OS anyway...
There wil also be a video posted on my Youtube channel for those that do not want to read this post or need visuals to guide them though these steps.
Now let's begin...
Preparing the system with dependency packages
In this instruction I am going to install Docker Community Edition (CE) in Linux Mint, which uses apt based packages. Based on: https://computingforgeeks.com/install-docker-docker-compose-on-linux-mint/
Any other Linux distribution or Windows can have other instructions and commands. So please refer to the documentation for these platforms for the Docker installation.
First I am going to update the apt cache and then install some additional required software that makes it possible to safely download the packages from Docker.
sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-commonTo be sure I install the correct package versions, I can remove any already installed Docker packages on my distribution.
This step is not really necessary but can be used if you never installed Docker or haev a brand new installation. But I consider it personally as a hygiene factor. And as a way to clean up your system from packages that are not used, like unused dependencies. And you should do this only if you are sure that you
sudo apt -y remove docker*; sudo apt autoremoveAfter this is done I can add the Docker keyring and repository GPG key for downloading the Docker packages.
Keyring
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgGPG key
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullNow I can check if the keyring is installed correctly
cat /etc/apt/sources.list.d/docker.listIf this is the result, then the keyring is installed correctly:
deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stableNow update the apt index again with the Docker packages. After this is done, we can install the Docker software.
sudo apt updateDownload and install the Docker packages
After we have prepared the system with the necessary Docker source and keyring, it is time to install the Docker packages, including Docker-compose, with the following command:
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-composeVerify the installation
Now that we have installed the packages, we can verify that Docker Engine is installed correctly by running the Docker hello-world image:
sudo docker run hello-worldDocker daemon not running
It can be that the Docker deamon does not run after the installation and you get the following error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.The way you start the Docker daemon is partially dependend on your system. In my specific case I had to start it with the following command:
systemctl start dockerIf everything does work right from the start, we will get the following response back:
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/Now we can proceed with the next step.
Add a user to the Docker group for management
It is unconvienient to run the Freqtrade Docker image with root privileges every time.
To solve this, we can add the current user to a Docker group which has enough rights to run Docker containers without having to use sudo.
Execute the following commands to add the current user to the Docker group:
sudo usermod -aG docker $USER
newgrp dockerNow run hello-world again, but without the sudo part:
docker run hello-worldIf this works, we can again proceed with the next step.
Docker container and image management
Checking containers
To check all the Docker containers that are, or were in use, execute the next command:
For running containers
docker psAnd if you don't see any output, for all containers, including the stopped ones:
docker ps -aChecking images
To check the docker images that are downloaded, and take up space on your system, use:
docker imagesRemoving containers
To remove a container that is not in use and stopped, use the command:
The first four digits of the containernumber are enough to identify which container to remove here.
docker rm <containernumber>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0293dfadcf1f hello-world "/hello" 36 minutes ago Exited (0) 36 minutes ago crazy_stonebraker
docker rm 0293
0293
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESRemoving images
Before removing an image, the corresponding container should be stopped and removed first.
Then we can remove the unused image and free up diskspace again:
Here we can use the container name.
docker rmi <container name>/<container ID>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d2c94e258dcb 8 months ago 13.3kB
docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Deleted: sha256:d2c94e258dcb3c5ac2798d32e1249e42ef01cba4841c2234249495f87264ac5a
Deleted: sha256:ac28800ec8bb38d5c35b49d45a6ac4777544941199075dff8c4eb63e093aa81e
docker images
REPOSITORY TAG IMAGE ID CREATED SIZEPreparing for Freqtrade
Now that we installed Docker and Docker compose, have checked if it works and know a little bit about container and image management, it is time to finally install the Freqtrade Docker image.
Create user_data directory
let's first create a directory that will contain the docker-compose file and all the freqtrade data.
mkdir ft_userdata
cd ft_userdata/Download the docker-compose file from the repository
Now it is time to download the freqtrade docker-compose file into this directory.
curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.ymlThis file will be used by docker to download the correct image and that has all the configurations for a correctly working bot.
curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1243 100 1243 0 0 1945 0 --:--:-- --:--:-- --:--:-- 1945Pull the freqtrade image
Now we can download the Freqtrade docker image to our system. Be aware that, by default, this will download the bot's most current docker image.
docker-compose pullPulling freqtrade ... doneWith the docker images command we can check the downloaded image:
docker imagesCreate user directory structure with the necessary freqtrade directories and files
Now we can really do business and create the userdirectory that the bot will use for all it's configurations, strategies, data, logs and other files.
docker-compose run --rm freqtrade create-userdir --userdir user_dataCreating network "ft_userdata_default" with the default driver
Creating ft_userdata_freqtrade_run ... done
2024-01-23 19:49:47,973 - freqtrade - INFO - freqtrade 2023.12And we can also see which bot version will be downloaded here.
By the way, I use the --rm switch here that will remove the container after it has been ran. Otherwise Docker will create a container each time you run a docker command and this can easily build up to many unused containers on your system.
Create the Freqtrade configuration - Requires answering interactive questions
The next thing to do is to create a new configuration file with the new-config sub command.
docker-compose run --rm freqtrade new-config --config user_data/config.jsonCreating ft_userdata_freqtrade_run ... done
2024-01-23 19:50:12,945 - freqtrade - INFO - freqtrade 2023.12
? Do you want to enable Dry-run (simulated trades)? Yes
? Please insert your stake currency: USDT
? Please insert your stake amount (Number or 'unlimited'): unlimited
? 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)? No
2024-01-23 19:50:33,443 - freqtrade.commands.build_config_commands - INFO - Writing config to `user_data/config.json`.
2024-01-23 19:50:33,443 - freqtrade.commands.build_config_commands - INFO - Please make sure to check the configuration contents and adjust settings to your needs.Add a pair to the config
After the config has been created, we have to edit the config file so that it contains at least one pair for downloading data. The bot cannot backtest without at lease having some pairs data.
nano user_data/config.jsonI am going to add the Bitcoin USDT pair in this section:
"pair_whitelist": [
"BTC/USDT",
"HBAR/USDT",
"GALA/USDT"And I also have to edit this section so that the bot knows that I use a static pairlist.
From:
"pairlists": [
{
"method": "VolumePairList",
"number_assets": 20,
"sort_key": "quoteVolume",
"min_value": 0,
"refresh_period": 1800
}To:
"pairlists": [
{
"method": "StaticPairList"
}If you want, you can use a higher heartbeat interval while testing stuff out:
"internals": {
"heartbeat_interval": 2,
"process_throttle_secs": 5
}Download pair data from exchange
Now we are going to test out if the bot can download data from the exchange by using the following command to download backtest data:
docker-compose run --rm freqtrade download-data --config user_data/config.json --days 365 -t 12h 5mAgain, the --rm switch will remove the container after completion otherwise you'll end up with many closed containers.
If you see the following appear on your screen, then you are good to go:
docker-compose run --rm freqtrade download-data --config user_data/config.json --days 365 -t 12h 5m
Creating ft_userdata_freqtrade_run ... done
2024-01-25 19:30:57,010 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 19:30:57,010 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 19:30:57,011 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 19:30:57,044 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 19:30:57,044 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 19:30:57,045 - freqtrade.configuration.configuration - INFO - timeframes --timeframes: ['12h', '5m']
2024-01-25 19:30:57,045 - freqtrade.configuration.configuration - INFO - Detected --days: 365
2024-01-25 19:30:57,046 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 19:30:57,058 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 19:30:57,058 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-25 19:30:57,058 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 19:30:57,062 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-01-25 19:30:57,062 - freqtrade.exchange.exchange - INFO - Using CCXT 4.1.98
2024-01-25 19:30:57,091 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-01-25 19:30:57,092 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2024-01-25 19:30:57,092 - freqtrade.exchange.exchange - INFO - Markets were not loaded. Loading them now..
2024-01-25 19:31:04,042 - freqtrade.data.history.history_utils - INFO - About to download pairs: ['BTC/USDT', 'HBAR/USDT', 'GALA/USDT'], intervals: ['12h', '5m'] to /freqtrade/user_data/data/binance
2024-01-25 19:31:04,084 - freqtrade.data.history.history_utils - INFO - (1/3) - Download history data for "BTC/USDT", 12h, spot and store in /freqtrade/user_data/data/binance. From 2024-01-24T12:00:00 to now
2024-01-25 19:31:04,425 - freqtrade.exchange.exchange - INFO - Downloaded data for BTC/USDT with length 3.
2024-01-25 19:31:04,526 - freqtrade.data.history.history_utils - INFO - (1/3) - Download history data for "BTC/USDT", 5m, spot and store in /freqtrade/user_data/data/binance. From 2024-01-25T19:05:00 to now
2024-01-25 19:31:04,834 - freqtrade.exchange.exchange - INFO - Downloaded data for BTC/USDT with length 6.
2024-01-25 19:31:05,007 - freqtrade.data.history.history_utils - INFO - (2/3) - Download history data for "HBAR/USDT", 12h, spot and store in /freqtrade/user_data/data/binance. From 2023-01-25T00:00:00 to now
2024-01-25 19:31:06,699 - freqtrade.exchange.exchange - INFO - Downloaded data for HBAR/USDT with length 732.
2024-01-25 19:31:06,716 - freqtrade.data.history.history_utils - INFO - (2/3) - Download history data for "HBAR/USDT", 5m, spot and store in /freqtrade/user_data/data/binance. From 2023-01-25T00:00:00 to now
2024-01-25 19:31:10,668 - freqtrade.exchange.exchange - INFO - Downloaded data for HBAR/USDT with length 105355.
2024-01-25 19:31:10,893 - freqtrade.data.history.history_utils - INFO - (3/3) - Download history data for "GALA/USDT", 12h, spot and store in /freqtrade/user_data/data/binance. From 2023-01-25T00:00:00 to now
2024-01-25 19:31:11,939 - freqtrade.exchange.exchange - INFO - Downloaded data for GALA/USDT with length 732.
2024-01-25 19:31:11,955 - freqtrade.data.history.history_utils - INFO - (3/3) - Download history data for "GALA/USDT", 5m, spot and store in /freqtrade/user_data/data/binance. From 2023-01-25T00:00:00 to now
2024-01-25 19:31:15,861 - freqtrade.exchange.exchange - INFO - Downloaded data for GALA/USDT with length 105355.Backtest a test strategy
After the data is downloaded, we can check if it exists in the following directory:
ls user_data/data/binance/And now it is time to do our first backtest with the bot and the default strategy that was installed when we created the user directory.
docker-compose run --rm freqtrade backtesting --config user_data/config.json --strategy SampleStrategyCreating ft_userdata_freqtrade_run ... done
2024-01-23 20:01:07,225 - freqtrade - INFO - freqtrade 2023.12
2024-01-23 20:01:07,244 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-23 20:01:07,245 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-23 20:01:07,245 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2024-01-23 20:01:07,270 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-23 20:01:07,270 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-23 20:01:07,270 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-01-23 20:01:07,271 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-23 20:01:07,283 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-23 20:01:07,283 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-23 20:01:07,284 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-23 20:01:07,287 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
<snip>
Backtested 2023-12-24 16:40:00 -> 2024-01-23 19:50:00 | Max open trades : 1
========================================================================== STRATEGY SUMMARY ==========================================================================
| Strategy | Entries | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % | Avg Duration | Win Draw Loss Win% | Drawdown |
|----------------+-----------+----------------+----------------+-------------------+----------------+-----------------+-------------------------+--------------------|
| SampleStrategy | 8 | -0.72 | -5.72 | -19.331 | -1.93 | 3 days, 7:12:00 | 6 0 2 75.0 | 39.276 USDT 3.85% |
======================================================================================================================================================================
For more details, please look at the detail tables aboveWe know now that the bot can download data and do a backtest with a strategy that is located in the strategy folder.
Running the Freqtrade container as a Daemon
let's now do a quick demonstration where we run the bot in dry run mode. Which means that it does paper trading with the selected strategy and config settings.
Edit the docker-compose file
First we have to check the compose.yml file in the ft_userdata directory. We do not want to accidentally trade with live money, do we..? It is good practice anyway to always check this.
First check which config the bot will use when starting the docker container:
nano docker-compose.ymlYou can specify the configuration, strategy and all other freqtrade command line parameters under the "command" section:
command: >
trade
--logfile /freqtrade/user_data/logs/freqtrade.log
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite
--config /freqtrade/user_data/config.json
--strategy SampleStrategyHere is says that the config.json in the user_data directory is used. And that is correct because we just created and configured that file.
nano user_data/config.json{
"max_open_trades": 3,
"stake_currency": "BTC",
"stake_amount": "unlimited",
"tradable_balance_ratio": 0.99,
"fiat_display_currency": "USD",
"dry_run": true,
"dry_run_wallet": 1000,
"cancel_open_orders_on_exit": false,
"trading_mode": "spot",
"margin_mode": "",
"unfilledtimeout": {
"entry": 10,
"exit": 10,
"exit_timeout_count": 0,
"unit": "minutes"
},
<snip>
"exchange": {
"name": "binance",
"key": "",
"secret": "",
"ccxt_config": {},
"ccxt_async_config": {},It seems that the dry_dun option is set to true. And that there is no key and secret set. So it seems that we are safe here.
Starting the Docker container
To start dry run trading with the freqtrade bot in deamon mode, just use the command:
docker-compose up -dThe -d switch causes Docker to run the container in the background. Hence the daemon mode.
This command also automaticalle reads the compose file in the directory, with the commands and other parameters set. That's why it is important to not change the docker-compose.yml filename here.
Checking the log file
To see if Freqtrade is working, use the next commands:
The Docker processes running with:
docker psThe Docker container logs:
docker container logs <containernumber>The Freqtrade log:
tail -f user_data/logs/freqtrade.logIt looks like the bot is working great here.
And we can even see some trades happening as we speak.
So now we are ready for the next phase of this video and that is to add additional python modules to this Docker image so that is also can run strategies that depend on packages that are not installed by default in the image.
Stopping the container
To stop the container with the running freqtrade bot, we first have to get the container ID that is running:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97ec7f2352e7 freqtradeorg/freqtrade:stable "freqtrade trade --l…" 20 minutes ago Up 20 minutes 127.0.0.1:8080->8080/tcp freqtradeOnce figured out, use it in the command to stop the bot. You do not have to specify the complete container ID, the first 4 or 5 characters will do as well:
docker container stop 97ec7Check if the instance is stopped:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESRunning a strategy with additional library requirements
'This is where the fun begins'
Sometimes a strategy requires additional libraries like finta or ta. These are not installed by default in the Docker image.
Lets first install a strategy of which I know it uses the technical library 'ta' that is not installed by default in the Freqtrade container.
cd cd user_data/strategies/
wget https://raw.githubusercontent.com/freqtrade/freqtrade-strategies/main/user_data/strategies/GodStra.pyTo get a first glimpse of the unavalable module, let's do a list strategies to see which strategies we have available.
docker-compose run --rm freqtrade list-strategies
Creating ft_userdata_freqtrade_run ... done
2024-01-25 18:43:46,827 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 18:43:46,827 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 18:43:46,828 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 18:43:46,854 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 18:43:46,854 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 18:43:46,855 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 18:43:46,868 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 18:43:46,869 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-25 18:43:46,869 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 18:43:46,898 - freqtrade.resolvers.iresolver - WARNING - Could not import /freqtrade/user_data/strategies/GodStra.py due to 'No module named 'ta''
+----------------+--------------------+-------------+----------------+--------------+---------------+
| name | location | status | hyperoptable | buy-Params | sell-Params |
|----------------+--------------------+-------------+----------------+--------------+---------------|
| -- | GodStra.py | LOAD FAILED | No | 0 | 0 |
| SampleStrategy | sample_strategy.py | OK | Yes | 2 | 2 |
+----------------+--------------------+-------------+----------------+--------------+---------------+In this example the GodStra strategy has status LOAD FAILED.
The log also gives a warning that GodStra cannot be loaded because of a missing 'ta' module.
We can also do a backtest with this strategy and the original Docker container:
docker-compose run --rm freqtrade backtesting --config user_data/config.json --strategy GodStra
Creating ft_userdata_freqtrade_run ... done
2024-01-25 19:09:54,820 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 19:09:54,836 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 19:09:54,838 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 19:09:54,838 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2024-01-25 19:09:54,882 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 19:09:54,882 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 19:09:54,883 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-01-25 19:09:54,884 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 19:09:54,903 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 19:09:54,903 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-25 19:09:54,903 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 19:09:54,907 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2024-01-25 19:09:54,907 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-01-25 19:09:54,907 - freqtrade.exchange.exchange - INFO - Using CCXT 4.1.98
2024-01-25 19:09:54,938 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-01-25 19:10:02,176 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2024-01-25 19:10:02,205 - freqtrade.resolvers.iresolver - WARNING - Could not import /freqtrade/user_data/strategies/GodStra.py due to 'No module named 'ta''
2024-01-25 19:10:02,205 - freqtrade - ERROR - Impossible to load Strategy 'GodStra'. This class does not exist or contains Python code errors.But as you can see, it exits with the error that it cannot find the ta-module.
And naturally you also cannot run this strategy in dry-run or live trading mode ofcourse.
Installing modules on the host system
Installing this library on the host system with pip install ta does not solve this problem. The Docker container is an isolated environment and does not use its hosts system resources or modules. The only solution here is to install the module within the Docker image and then run the container with that newly installed module.
Adding/Installing additional modules in image
To install additional modules in your image do the following:
Preparing the files
First we are going to modify the docker-compose file so that it creates a custom image and uses an additional file which I call Dockerfile.custom.
I will first make a backup of my docker-compose like this.
cp docker-compose.yml{,.back240124}
'docker-compose.yml' -> 'docker-compose.yml.back240124'Then I will edit the docker-compose. I will call the new Docker image "freqtrade_custom" and point to a file called ./Dockerfile.custom.
image: freqtrade_custom
build:
context: .
dockerfile: "./Dockerfile.custom"Now it is time to create the Dockerfile.custom. The reason why I use ./ is that I prefer to keep the docker-compose file and all customiztions in the same location. Which is easier for me to manage.
The Dockerfile.custom file will contain the following lines:
FROM freqtradeorg/freqtrade:stable
RUN pip install --user ta fintaThe first line tells Docker where to get the initial Docker image. The second line is used to install additional modules in that image.
The second line will install two additional Python modules that are often used with other trading strategies and that are not installed by defaultin the Freqtrade image.
Create the Docker image
Now that the files are ready to use, lets use the following command to create the new custom Docker image:
docker-compose build --pullIf you watched closely, you could see that during the build these modules were installed additionally.
Building freqtrade
[+] Building 10.9s (6/6) FINISHED docker:default
=> [internal] load build definition from Dockerfile.custom 0.1s
=> => transferring dockerfile: 112B 0.0s
=> [internal] load metadata for docker.io/freqtradeorg/freqtrade:stable 1.3s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> CACHED [1/2] FROM docker.io/freqtradeorg/freqtrade:stable@sha256:cb3cb22d29d8dbc234804e21704fb92cab471f8e687e86fe96875a309d54cbed 0.1s
=> => resolve docker.io/freqtradeorg/freqtrade:stable@sha256:cb3cb22d29d8dbc234804e21704fb92cab471f8e687e86fe96875a309d54cbed 0.1s
=> [2/2] RUN pip install --user ta finta 5.9s
=> exporting to image 3.1s
=> => exporting layers 3.0s
=> => writing image sha256:5c9abcaedab3b56d48f8d41394b2f8aec8ccac056dfe1c347dbcf62995d73eba 0.0s
=> => naming to docker.io/library/freqtrade_customWe can now check the existence of our own custom image with docker images
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
freqtrade_custom latest 5c9abcaedab3 2 minutes ago 1.05GB
freqtradeorg/freqtrade stable 1ae1d68a76ef 3 weeks ago 1.05GBChecking for success
Now we can try the list-strategies command again to see if the strategy now will be accepted, since the ta library is also installed in the image.
docker-compose run --rm freqtrade list-strategies
Creating ft_userdata_freqtrade_run ... done
2024-01-25 19:06:54,012 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 19:06:54,013 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 19:06:54,014 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 19:06:54,043 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 19:06:54,043 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 19:06:54,044 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 19:06:54,056 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 19:06:54,057 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-25 19:06:54,057 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
+----------------+--------------------+----------+----------------+--------------+---------------+
| name | location | status | hyperoptable | buy-Params | sell-Params |
|----------------+--------------------+----------+----------------+--------------+---------------|
| GodStra | GodStra.py | OK | No | 0 | 0 |
| SampleStrategy | sample_strategy.py | OK | Yes | 2 | 2 |
+----------------+--------------------+----------+----------------+--------------+---------------+And behold, no error anymore. The freqtrade_custom container is used with the additional modules and freqtrade can find these to run and check the strategy:
Now we can also run a backtest which will not error out on us anymore.
docker-compose run --rm freqtrade backtesting --config user_data/config.json --strategy GodStra
Creating ft_userdata_freqtrade_run ... done
2024-01-25 19:32:54,533 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 19:32:54,548 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 19:32:54,549 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 19:32:54,550 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2024-01-25 19:32:54,582 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 19:32:54,583 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 19:32:54,583 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-01-25 19:32:54,584 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 19:32:54,600 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 19:32:54,600 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-25 19:32:54,600 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 19:32:54,605 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2024-01-25 19:32:54,606 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-01-25 19:32:54,606 - freqtrade.exchange.exchange - INFO - Using CCXT 4.1.98
2024-01-25 19:32:54,638 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-01-25 19:33:01,475 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2024-01-25 19:33:01,506 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy GodStra from '/freqtrade/user_data/strategies/GodStra.py'...
2024-01-25 19:33:01,506 - freqtrade.strategy.hyper - INFO - Found no parameter file.
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: unlimited.
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}.
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'max_open_trades' with value in config file: 3.
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.3556, '4818': 0.21275, '6395': 0.09024, '22372': 0}
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 12h
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.34549
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2024-01-25 19:33:01,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.22673
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.2684
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: True
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: unlimited
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using protections: []
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 0
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2024-01-25 19:33:01,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2024-01-25 19:33:01,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2024-01-25 19:33:01,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2024-01-25 19:33:01,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2024-01-25 19:33:01,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_open_trades: 3
2024-01-25 19:33:01,509 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 19:33:01,518 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
2024-01-25 19:33:01,620 - freqtrade.optimize.backtesting - INFO - Loading data from 2023-01-25 00:00:00 up to 2024-01-25 00:00:00 (365 days).
2024-01-25 19:33:01,620 - freqtrade.configuration.timerange - WARNING - Moving start-date by 0 candles to account for startup time.
2024-01-25 19:33:01,620 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2024-01-25 19:33:01,621 - freqtrade.optimize.backtesting - WARNING - Backtest result caching disabled due to use of open-ended timerange.
2024-01-25 19:33:01,621 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy GodStra
2024-01-25 19:33:01,622 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
2024-01-25 19:33:02,588 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2023-01-25 00:00:00 up to 2024-01-25 00:00:00 (365 days).
[0 False
1 False
2 False
3 False
4 False
...
726 False
727 False
728 False
729 False
730 False
Name: trend_ichimoku_base, Length: 731, dtype: bool]
[0 False
1 False
2 False
3 False
4 False
...
726 False
727 False
728 False
729 False
730 False
Name: trend_ichimoku_base, Length: 731, dtype: bool]
[0 True
1 True
2 True
3 True
4 True
...
726 True
727 True
728 True
729 True
730 True
Name: trend_ichimoku_base, Length: 731, dtype: bool]
2024-01-25 19:33:03,286 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2024-01-25_19-33-03.meta.json"
2024-01-25 19:33:03,288 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2024-01-25_19-33-03.json"
2024-01-25 19:33:03,292 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/.last_result.json"
Result for strategy GodStra
============================================================= BACKTESTING REPORT =============================================================
| Pair | Entries | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % | Avg Duration | Win Draw Loss Win% |
|-----------+-----------+----------------+----------------+-------------------+----------------+-------------------+-------------------------|
| HBAR/USDT | 10 | 3.83 | 38.28 | 116.871 | 11.69 | 24 days, 21:36:00 | 4 6 0 100 |
| BTC/USDT | 0 | 0.00 | 0.00 | 0.000 | 0.00 | 0:00 | 0 0 0 0 |
| GALA/USDT | 23 | -0.97 | -22.38 | -109.908 | -10.99 | 15 days, 8:52:00 | 13 5 5 56.5 |
| TOTAL | 33 | 0.48 | 15.90 | 6.963 | 0.70 | 18 days, 6:11:00 | 17 11 5 51.5 |
========================================================= LEFT OPEN TRADES REPORT ==========================================================
| Pair | Entries | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % | Avg Duration | Win Draw Loss Win% |
|-----------+-----------+----------------+----------------+-------------------+----------------+-----------------+-------------------------|
| GALA/USDT | 1 | 6.05 | 6.05 | 19.718 | 1.97 | 1 day, 12:00:00 | 1 0 0 100 |
| TOTAL | 1 | 6.05 | 6.05 | 19.718 | 1.97 | 1 day, 12:00:00 | 1 0 0 100 |
============================================================ ENTER TAG STATS ============================================================
| TAG | Entries | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % | Avg Duration | Win Draw Loss Win% |
|-------+-----------+----------------+----------------+-------------------+----------------+------------------+-------------------------|
| TOTAL | 33 | 0.48 | 15.90 | 6.963 | 0.70 | 18 days, 6:11:00 | 17 11 5 51.5 |
===================================================== EXIT REASON STATS =====================================================
| Exit Reason | Exits | Win Draws Loss Win% | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % |
|---------------+---------+--------------------------+----------------+----------------+-------------------+----------------|
| roi | 27 | 16 11 0 100 | 6.78 | 183.18 | 549.238 | 61.06 |
| stop_loss | 5 | 0 0 5 0 | -34.67 | -173.33 | -561.993 | -57.78 |
| force_exit | 1 | 1 0 0 100 | 6.05 | 6.05 | 19.718 | 2.02 |
================== SUMMARY METRICS ==================
| Metric | Value |
|-----------------------------+---------------------|
| Backtesting from | 2023-01-25 00:00:00 |
| Backtesting to | 2024-01-25 00:00:00 |
| Max open trades | 3 |
| | |
| Total/Daily Avg Trades | 33 / 0.09 |
| Starting balance | 1000 USDT |
| Final balance | 1006.963 USDT |
| Absolute profit | 6.963 USDT |
| Total profit % | 0.70% |
| CAGR % | 0.70% |
| Sortino | 0.03 |
| Sharpe | 0.01 |
| Calmar | 0.14 |
| Profit factor | 1.01 |
| Expectancy (Ratio) | 0.21 (-0.33) |
| Trades per day | 0.09 |
| Avg. daily profit % | 0.00% |
| Avg. stake amount | 304.215 USDT |
| Total trade volume | 10039.101 USDT |
| | |
| Best Pair | HBAR/USDT 38.28% |
| Worst Pair | GALA/USDT -22.38% |
| Best trade | GALA/USDT 21.25% |
| Worst trade | GALA/USDT -34.68% |
| Best day | 70.207 USDT |
| Worst day | -127.699 USDT |
| Days win/draw/lose | 17 / 340 / 5 |
| Avg. Duration Winners | 6 days, 1:25:00 |
| Avg. Duration Loser | 29 days, 16:48:00 |
| Max Consecutive Wins / Loss | 3 / 3 |
| Rejected Entry signals | 0 |
| Entry/Exit Timeouts | 0 / 0 |
| | |
| Min balance | 794.226 USDT |
| Max balance | 1114.944 USDT |
| Max % of account underwater | 25.79% |
| Absolute Drawdown (Account) | 25.79% |
| Absolute Drawdown | 275.981 USDT |
| Drawdown high | 70.207 USDT |
| Drawdown low | -205.774 USDT |
| Drawdown Start | 2023-01-29 00:00:00 |
| Drawdown End | 2023-06-10 00:00:00 |
| Market change | 12.55% |
=====================================================
Backtested 2023-01-25 00:00:00 -> 2024-01-25 00:00:00 | Max open trades : 3
========================================================================== STRATEGY SUMMARY =========================================================================
| Strategy | Entries | Avg Profit % | Cum Profit % | Tot Profit USDT | Tot Profit % | Avg Duration | Win Draw Loss Win% | Drawdown |
|------------+-----------+----------------+----------------+-------------------+----------------+------------------+-------------------------+----------------------|
| GodStra | 33 | 0.48 | 15.90 | 6.963 | 0.70 | 18 days, 6:11:00 | 17 11 5 51.5 | 275.981 USDT 25.79% |
=====================================================================================================================================================================
For more details, please look at the detail tables aboveAnd as you can see, backtesting the strategy works as well here as well as dry-run trading. As you can see next:
docker-compose run --rm freqtrade trade --config user_data/config.json --strategy GodStra
Creating ft_userdata_freqtrade_run ... done
2024-01-25 19:43:00,844 - freqtrade - INFO - freqtrade 2023.12
2024-01-25 19:43:01,474 - freqtrade.worker - INFO - Starting worker 2023.12
2024-01-25 19:43:01,474 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-01-25 19:43:01,475 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-25 19:43:01,476 - freqtrade.configuration.configuration - INFO - Runmode set to dry_run.
2024-01-25 19:43:01,476 - freqtrade.configuration.configuration - INFO - Dry run is enabled
2024-01-25 19:43:01,476 - freqtrade.configuration.configuration - INFO - Using DB: "sqlite:///tradesv3.dryrun.sqlite"
2024-01-25 19:43:01,476 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2024-01-25 19:43:01,535 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2024-01-25 19:43:01,535 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2024-01-25 19:43:01,539 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-25 19:43:01,558 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-25 19:43:01,559 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2024-01-25 19:43:01,591 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy GodStra from '/freqtrade/user_data/strategies/GodStra.py'...
2024-01-25 19:43:01,591 - freqtrade.strategy.hyper - INFO - Found no parameter file.
2024-01-25 19:43:01,591 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2024-01-25 19:43:01,591 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: unlimited.
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}.
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'max_open_trades' with value in config file: 3.
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.3556, '4818': 0.21275, '6395': 0.09024, '22372': 0}
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 12h
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.34549
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.22673
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.2684
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: True
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2024-01-25 19:43:01,592 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: unlimited
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using protections: []
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 0
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2024-01-25 19:43:01,593 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_open_trades: 3
2024-01-25 19:43:01,593 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-25 19:43:01,598 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-01-25 19:43:01,598 - freqtrade.exchange.exchange - INFO - Using CCXT 4.1.98
2024-01-25 19:43:01,622 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-01-25 19:43:08,372 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2024-01-25 19:43:08,512 - freqtrade.wallets - INFO - Wallets synced.
2024-01-25 19:43:08,516 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
<snip>
2024-01-25 19:43:28,782 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:29,103 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=1, pair=GALA/USDT, amount=14758.49731664, is_short=False, leverage=1.0, open_rate=0.02236000, open_since=2024-01-25 19:43:11)
2024-01-25 19:43:29,117 - freqtrade.freqtradebot - INFO - Fee for Trade Trade(id=1, pair=GALA/USDT, amount=14758.49731664, is_short=False, leverage=1.0, open_rate=0.02236000, open_since=2024-01-25 19:43:11) [buy]: 0.32998888 USDT - rate: 0.001
2024-01-25 19:43:29,118 - freqtrade.persistence.trade_model - INFO - Updating trade (id=1) ...
2024-01-25 19:43:29,118 - freqtrade.persistence.trade_model - INFO - LIMIT_BUY has been fulfilled for Trade(id=1, pair=GALA/USDT, amount=14758.00000000, is_short=False, leverage=1.0, open_rate=0.02236000, open_since=2024-01-25 19:43:11).
2024-01-25 19:43:29,140 - freqtrade.wallets - INFO - Wallets synced.
2024-01-25 19:43:29,144 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'trade_id': 1, 'type': entry_fill, 'buy_tag': None, 'enter_tag': None, 'exchange': 'Binance', 'pair': 'GALA/USDT', 'leverage': 1.0, 'direction': 'Long', 'limit': 0.02236, 'open_rate': 0.02236, 'order_type': 'limit', 'stake_amount': 329.98888, 'stake_currency': 'USDT', 'base_currency': 'GALA', 'fiat_currency': 'USD', 'amount': 14758.0, 'open_date': datetime.datetime(2024, 1, 25, 19, 43, 11, 695663, tzinfo=datetime.timezone.utc), 'current_rate': 0.02236, 'sub_trade': False}
2024-01-25 19:43:33,782 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:38,783 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:43,784 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:48,784 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:53,785 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
2024-01-25 19:43:58,785 - freqtrade.worker - INFO - Bot heartbeat. PID=1, version='2023.12', state='RUNNING'
^C2024-01-25 19:44:00,866 - freqtrade.commands.trade_commands - INFO - SIGINT received, aborting ...
2024-01-25 19:44:00,867 - freqtrade.commands.trade_commands - INFO - worker found ... calling exit
2024-01-25 19:44:00,867 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': status, 'status': 'process died'}
2024-01-25 19:44:00,867 - freqtrade.freqtradebot - INFO - Cleaning up modules ...
2024-01-25 19:44:00,874 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': warning, 'status': "1 open trades active.\n\nHandle these trades manually on Binance, or '/start' the bot again and use '/stopentry' to handle open trades gracefully. \nNote: Trades are simulated (dry run)."}
2024-01-25 19:44:00,875 - freqtrade.rpc.rpc_manager - INFO - Cleaning up rpc modules ...Finish
And with this we are at the end of this post. I hope this was informative and you are now able to run strategies that require more exotic, not by default, installed python modules in the Docker container.
Thanks for reading and being my Patron and see you in the next post!
Goodbye!
Files
The full docker-compose.yml file
---
version: '3'
services:
freqtrade:
image: freqtrade_custom
build:
context: .
dockerfile: "./Dockerfile.custom"
restart: unless-stopped
container_name: freqtrade
volumes:
- "./user_data:/freqtrade/user_data"
ports:
- "127.0.0.1:8080:8080"
command: >
trade
--logfile /freqtrade/user_data/logs/freqtrade.log
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite
--config /freqtrade/user_data/config.json
--strategy SampleStrategyThe full Dockerfile.custom file
FROM freqtradeorg/freqtrade:stable
RUN pip install --user ta finta