Cryptocurrency bot to automate trading based on technical indicators.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
- About the Project
- Getting Started
- Usage
- Roadmap
- Contributing
- Disclaimer
- License
- Contact
- Acknowledgements
This project started with the motivation of automating an existing hobby I had, cryptocurrency trading. After a bit of research I found this python package that could be programed to follow techincal indicators and place orders for me using Binance's API and Telegram for commands.
The strategy I use is base on Bollinger Bands (BB) and Relative Strength Index (RSI). More information on these indicators can be found here:
I used hyperparameter optimization for the strategy by backtesting the data on close prices from February 2019 to February 2020. The hyperopt yielded the following results:
- BUY ORDER: Place a buy order when closing price is below the lower BB (1 standard deviation) and RSI higher than 7.
- SELL ORDER: Place a sell order when closing price is above the upper BB (1 standard deviation) and RSI higher than 74.
- STOP LOSS: 6.49% loss
- TRAILING STOP: True
- TICKER INTERVAL: 1H
The hyperparameter optimization took about 19 hours to complete, and all of the parameters are already set in the strategy provided. I used a daily Sharpe ratio ratio as objective for the optimization, since a profit maximization strategy was too volatile and riskier. It yielded in average around $1300/month with a starting capital of $7500 (in backtest). Of course I expect this to have a lower monthly return when trading with real money due to slippages, volatility and liquidity of certain coins.
The strategy is set to have 15 trades open at all time, allocating 99% of the total capital between them.
The quote currency for all trades is USDT and the list of base currencies can be found (and modified) in the config.json
file.
For my strategy I used a static pair list for control, but if needed a dynamic list can be set based on current trading volume.
To get a local copy up and running follow these simple steps.
- Docker
- Telegram account
- Binance account
-
Clone the repo
$ git clone https://github.com/lhandal/crypto-trading-bot.git
-
Create a blank Telegram bot with BotFather
This step is very simple to do, just go to the link above, talk to the botfather bot and follow the stps. More info and detailed steps in this Medium article
-
Get your Telegram Chat ID
There is a bot that echoes your chat id upon starting a conversation. Just search for @chatid_echo_bot and tap /start. It will echo your chat id.
-
Copy your chat ID and the token provided by your new bot into the config.json file (lines 188 and 189).
-
Create and get your Binance API keys.
To do this just follow this guide!
-
Copy the API key and secret into the config.json file (lines 34 and 35).
And you're all done! Ready to run the bot!
To start the bot inside a docker container just run:
$ docker-compose run --rm freqtrade trade -s BB_RSI
To see a list of all available commands such as:
- Downloading price data
- Hyperparameter tuning
- Running the bot with different settings
- Plotting
Visit freqtrade's documentation.
See the open issues for a list of proposed features (and known issues).
- Download more data and keep back-testing.
- Create separate strategies for bearish, bullish and sideways markets.
- Test the bot with other indicators and currency pairs.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is for informational purposes only, you should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained here constitutes a solicitation, recommendation, endorsement, or offer by me or any third party service provider to buy or sell any securities or other financial instruments in this or in in any other jurisdiction in which such solicitation or offer would be unlawful under the securities laws of such jurisdiction.
Please only use the dry-run
mode (paper money).
If you plan to use real money USE AT YOUR OWN RISK.
Under no circumstances will I be held responsible or liable in any way for any claims, damages, losses, expenses, costs or liabilities whatsoever including, without limitation, any direct or indirect damages for loss of profits.
Distributed under the MIT License. See LICENSE
for more information.
- Email: lhandalb@gmail.com
- LinkedIn: lhandal
- Twitter: @lhandalb
- Instagram: @lhandal
Project Link: https://github.com/lhandal/crypto-trading-bot