How to Setup a High Frequency Trading Bot
A detailed guide showing you how to setup a high frequency trading bot that can be used on the Bittrex exchange.
Note the bot used in this guide is —
https://github.com/gcarq/freqtrade/
Support can be found in their Slack channel.
More in depth documentation can be found here.
TL;DR Requirements —
A Vultr or Digital Ocean VPS
A Bittrex Account with API enabled (this requires Google Authenticator)
A Telegram Account
A Botfather API key
Your Telegram Chat ID
Step 1
1a. Create or login to your existing Bittrex Account. To operate, the tradebot will require an API key for your Bittrex account. To setup API keys, you will need to enable 2FA first. Go to Settings > Two-Factor Authentication
Open the Google Authenticator app and scan in the QR code provided on the screen.
Make sure you write down your secret key and store it in a safe place. This can be used to recover a lost 2FA!
Once you add the account to the app, a random 6-digit code will be generated every 30 seconds. Enter this code in the Authenticator Code field and click Enable 2FA.
Bittrex will now send you en email to verify your 2FA. Open the email account you used to register your Bittrex account and click on the link in this email. This will take you to the final confirmation screen to confirm your 2FA settings.
Enter the code from your 2FA device and click on Enable Two-Factor Authentication — you have now enabled 2FA on your account!
1b. Now 2FA is enabled, you can setup your API keys. Go to Settings > API Keys in your Bittrex account.
Click on Add new key… and give the key the following permissions. Click Save when done.
You will be prompted for your Google Authenticator code. Enter this in and click Confirm. You will now see Key and Secret codes generated. Note these down in a safe place. These keys allow access to your Bittrex account!
Step 2
2a. Open your Telegram account and send a DM to @BotFather. Type /start and then /newbot. Follow the steps to generate an API key. Note down this API key.
2b. Open your Telegram and send a DM to @userinfobot. Type /start. The userinfobot will output your Id. Note this down.
Step 3
3a. Login to your VPS as root and run the following command
git clone https://github.com/gcarq/freqtrade && cd freqtrade && ./setup.sh --install
This will clone the freqtrade github repo and run the initial setup script. You will need to hit Enter and Y a couple of times.
The freqtrade setup script will ask for the following —
Max open trades
Stake amount
Stake currency
Fiat currency
For the sake of this guide, we will use the defaults.
You will also need to enter in your —
Bittrex Key
Bittrex Secret
Bot Father API Key
Telegram Chat ID
Once all these details are entered, the bot setup will then complete.
3b. The config file for the bot is stored in ./config.json
Open this file by running the following command.
nano ./config.json
This is the default layout of the config file. Full details on each option can be found here — https://github.com/gcarq/freqtrade/blob/develop/docs/configuration.md
{
"max_open_trades": 3,
"stake_currency": "BTC",
"stake_amount": 0.05,
"fiat_display_currency": "USD",
"dry_run": true,
"unfilledtimeout": 600,
"bid_strategy": {
"ask_last_balance": 0.0
},
"exchange": {
"name": "bittrex",
"key": "",
"secret": "",
"pair_whitelist": [
"BTC_ETH",
"BTC_LTC",
"BTC_ETC",
"BTC_DASH",
"BTC_ZEC",
"BTC_XLM",
"BTC_NXT",
"BTC_POWR",
"BTC_ADA",
"BTC_XMR"
],
"pair_blacklist": [
"BTC_DOGE"
]
},
"experimental": {
"use_sell_signal": false,
"sell_profit_only": false
},
"telegram": {
"enabled": true,
"token": "",
"chat_id": ""
},
"initial_state": "running",
"internals": {
"process_throttle_secs": 5
}
}
When dry_run is set to true, the bot will only simulate trades. It is recommended you leave this on while testing and setting up a trading strategy.
We need to add in a few extra lines to this config file to make it functional. These extra config lines define the base trading strategy for the bot. Add these extra lines in and save the file using Ctrl+X.
{
"max_open_trades": 3,
"stake_currency": "BTC",
"stake_amount": 0.05,
"fiat_display_currency": "USD",
"dry_run": true,
"unfilledtimeout": 600,
"ticker_interval": 5,
"minimal_roi": {
"40": 0.0,
"30": 0.01,
"20": 0.02,
"0": 0.04
},
"stoploss": -0.10,
"bid_strategy": {
"ask_last_balance": 0.0
},
"exchange": {
"name": "bittrex",
"key": "",
"secret": "",
"pair_whitelist": [
"BTC_ETH",
"BTC_LTC",
"BTC_ETC",
"BTC_DASH",
"BTC_ZEC",
"BTC_XLM",
"BTC_NXT",
"BTC_POWR",
"BTC_ADA",
"BTC_XMR"
],
"pair_blacklist": [
"BTC_DOGE"
]
},
"experimental": {
"use_sell_signal": false,
"sell_profit_only": false
},
"telegram": {
"enabled": true,
"token": "",
"chat_id": ""
},
"initial_state": "running",
"internals": {
"process_throttle_secs": 5
}
}
minimal_roi sets the duration in minutes and the ROI in percent. The exmaple used above breaks down to —
"minimal_roi": {
"40": 0.0, # Sell after 40 minutes if the profit is not negative
"30": 0.01, # Sell after 30 minutes if there is at least 1% profit
"20": 0.02, # Sell after 20 minutes if there is at least 2% profit
"0": 0.04 # Sell immediately if there is at least 4% profit
},
You can easily run a customised strategy by following this documentation — https://github.com/gcarq/freqtrade/blob/develop/docs/bot-optimization.md
A strategy file contains all the information needed to build a good strategy. You can also add in more indicators here.
- Buy strategy rules
- Sell strategy rules
- Minimal ROI recommended
- Stoploss recommended
- Hyperopt parameter
The default strategy file the bot operates off can be found here —
https://github.com/gcarq/freqtrade/blob/develop/freqtrade/strategy/default_strategy.py
3c. Now our config file is setup, the bot can be run for the first time. Start the bot from your VPS by running the following command —
source .env/bin/activate; python3 freqtrade/main.py
If you have setup everything correctly your VPS should now display output similar to the following
You Telegram client should now also have access to the bot.
As you can see from the above screenshot, the bot can be controlled via your Telegram client. However if you would like to adjust coin pairs or strategies, you will need to stop the bot and edit the relevant files on the VPS.
You can use a different config file by starting the bot using a command like this —
source .env/bin/activate; python3 ./freqtrade/main.py -c path/far/far/away/config.json
You can use a different strategy file by starting the bot using a command like this —
source .env/bin/activate; python3 ./freqtrade/main.py --strategy AwesomeStrategy --strategy-path /some/folder
You can use a dynamic whitelist (trades top 20 coin pairs based off BaseVolume) by starting the bot using a command like this —
source .env/bin/activate; python3 ./freqtrade/main.py --dynamic-whitelist
Wolf Crypto Resources
Public Group: https://t.me/WolfCryptoPub
News Channel: https://t.me/WolfCryptoAnnounce
Twitter: https://twitter.com/WolfCryptoGroup