I’ve been pretty fascinated about trading and crypto from years ago, money just loses it’s value, automated algorithmic trading offers a way your computer work as your personal money manager, just under your orders, crypto promises a world with cheap and secure transaction fees, and a shield for inflation.
As i´m not the only one that thinks about this stuff, there are already some very interesting open source projects that aim to automatize crypto trading.
UPDATE DIC 2020: There is now a new post comparing all of the open source crypto trading bots available
** WARNING: This document has no intention of persuade nobody to invest money in anything. It’s just a informative about how running a program already available. I am not responsible in any way for any money you invest, only your ability creating algorithms is. **
About open source crypto trading bots
What is a crypto bot?
In brief: It’s a program made to execute automated orders in a cryptocurrency exchange.
What this means? With this tools we can make a computer locally, or on the cloud buy and sell cryptos based on our strategies.
Most of them also have integrated more tools to develop our strategies like backtracking, plotting the data, or optimize our strategy using some kind of AI.
The money we can earn or loose depends on our strategy, and this is the hard part.
For this guide i’ll using freqtrade and will show how to test your own strategies under windows 10 OS.
Why Freqtrade?
Paid alternatives are getting more and more exposure each day, but in the open-sorce space there are 3 mayor alternatives Zenbot,Freqtrade,Crypto-trading-bot and jess-AI. The last twoo looked like newer options and not so stable yet, but resolve some of the other frameworks problems, will be checking their updates for future posts.
I tried to use Zenbot, but Docker install under Windows was not possible at the moment, It’s made in Node.js and looks like a nice program, but i just wanted to run test while i work on my Windows OS so i discarded this option.
In the other hand, i already had used freqtade for some months now on a cloud server with dry run and has not given any problem.
It’s Python 3 based and well mantained, satble, and each time i get to the github page, has more features, i hadn’t found any serious bugs. This plus tha ability to run your tests from Windows make it the best alternative.
The only two thing i miss is a good graphical representation, but there has been lately a lot of improvements in this way, using Jupyter notebooks for some analysis, and some experimental WebUI to control it. There’s also the limitation of the bot of just being able to open one position at a time on each pair.
You can find more about it in project github page or docs.
The docs are very well documented and contain a larger but better starter guide, this post is not trying to replace them, just offers a quick start guide to test it under windows.
The third one, Crypt-trading-bot looks like a newer player in the game, it’s JS based and has a pretty interface
Freqtrade local setup
Initial requeriments
Updated Windows 10 or Windows 10 Home OS with git already installed Some knowledge aout the command line A brain interested in algorithms
Setting up our Docker enviroment on Win 10
We need first to set up a docker enviroment on Windows 10. If you have Home edition OS, you will need to install WSL 2 or Windows susbsistem for Linux. Before this you need to have your OS updated to the last version to avoid problems.
If you are lucky, you can directly install Docker install Full Guide
Installing our bot docker container
Basic install
Once we got our Docker Desktop program installed, we need to setup our Docker container, for this we need to move to a folder using the windows terminal. In my case ill move to C:/Users/yourusername/Onedrive/docker, so i have a backup of everithing on onedrive.
Once there We need to create a folder, in my case called freqtrade, weneed to create the user and file structure, instructions copied from oficial docs
Download technical framework
To use all the possibilities qe need to add to the dockerfile the technical framework, for this, we need to add the library to the Dockerfile, in docker-compose.yml edit and add:
Create a newfile called Dockerfile.technical and add the following lines:
After this, next time we run a docker-compose command it will rebuild the Docker image with added dependencies.
Basic configuration
Our config has been created in previous step, but we need to configure it to our needs. All the base/default config for our bot is in the file /user_data/config.json Specially we need to change the “pair_whitelist” list of currencies. This is the pair list we are going to use download the historic data and run our backtests with.
Remember all the pairs should have in the right side your stake_currency.
Also take a look at the others options, as you can change them for each test.
Downloading example bot configurations
There are a growing number of strategies developed by the community for freqtrade available at github.
You can download them using git, or you can just download as a zip and copy them inside of your /userdata/strategies folder.
First Backtesting
Download data for backtesting
To download our data to resolve our backtesting, we need to use the following command:
This will download the data for the last 100 days, in 5 minute candlesticks, of all the pairs in our whitelist. This command has many options and is very complete, so please refer to full documentation for updated info.
Testing all the available example strategies on our data
To test all the example strategies and take a fast look for ones are the most profitable in our downloaded data (in my case, the last 100 days) from all our whitelist pairs in 5m candlesticks.
This is updated in August 2020, check the strategies list to see if there are any news or changes.
This test are just an example, some of the strategies perform better in other timeframes and test here is for nothing, but it will give us a start point and show us which was the best strategy with given condition.
The backtesting tool is also a very powerfull one with a lot of options, giving us the ability to save our results in different file formats. It also doesnt include the reinforced or smooth variant ones. Check the full docs for more and updated info.
General Result
In my case i get this results:
I can see from all testes strategies my more profitable ones where:
- Quickie with an impressive 232%
- BbandRsi with a impressive 200%
- BinHV27 with a nice 130%
- MACDStrategy_crossed with also 126%
This are just orientative results, backtesting is not exactly the same as running in live mode or dry-run.
Looking closer to each strategy
Testing multiple strategies at multiple coins can be good to have a big idea of them, but we can take a better look one by one. By using the –export trades option, we had created a number of json files under user_data/backtest_results/backtest-result-
My results look like this for Quickie:
Recap
If you followed this guide, you should be able to continue testing yout crypto strategies. Now its your time to try other pairs/timeframes and crush your head thinking about profitable strategies. Good luck
Acknowledgement
This quick intall guide is based on documentation available on freqtrade docs and is way more extensive, and as i said very well documented.
Cheers for all developers maintaining and upgrading this nice program, if this tutorial feel usefull for you feel free to donate them