High Frequency Trading Tutorial — Install Your First Bot

on

High frequency trading means using machine and algorithms to trade. There are some obvious upsides like trading in your sleep and not being conditioned by emotions. On the other hand you have to know what you are doing, you are trusting a machine with your money.

What You Will Need

In this quick tutorial you will install your first trading bot. Don’t worry, you will be able to do a dry run without any money. You will need an account on bittrex.com though. Just go on the website and create your account, it won’t take long. Other than this we are using Telegram. Telegram is like WhatsApp but better: for once, it allows us to create a chatbot. We will use this as a textual interface to interact with our trade bot.

Install the Dependencies

This bot is written in Python 3.6. It will use SQLite to store data, TA-Lib for technical analysis of the market. If you are on macOS you can install everything with brew:

Otherwise you should go to their respective web pages and follow the instructions for your operating system: TA-Lib, Python, SQLite.

High Frequency Trading Bot

We are going to use https://github.com/gcarq/freqtrade as a bot.

  1. On a command line clone the repository with git clone [email protected]:gcarq/freqtrade.git
  2. Optional: if you want to work on the same commit at the time of writing do git checkout 72432c1
  3. Go inside the directory you just cloned with cd freqtrade and copy the configuration file with
  4. Open the config.json file with your favourite editor
  5. We are now going to insert in this file your personal bittrex account:
    1. You will need to instert your bittrex account data in the following snippet

      Go in your bittrex Settings page and choose the API Keys tab
    2. Add a new key with all the privileges except for withdraw
    3. Copy and paste the key and the secret in the configuration file
  6. Next we need to create a Telegram bot:
    1. Start a conversation with the BotFather in your Telegram
    2. Type /newbot to create your new bot, you will be asked to give it a name
    3. Take note of the token you receive, you will need it for the config file
    4. You will need you Telegram id, start a conversation with get id
    5. Type /start and it will tell you your chat id, take note for this too
  7. Back in the configuration file fill in the information you just got in the following lines
  8. In the configuration file you have the ability to set a dry run variable, if you set it to true the bot will simulate trades but it will actually not move any money. It’s highly suggested to set it to true.
  9. Once you’ve done this, in the freqtrade directory you can type the following commands to launch your bot.

Trying Out Your High Frequency Trading Bot

Once your bot starts you should see something similar to this in your Telegram client.

High Frequency Trading bot starting up with two trades

The bot will pick up on buy and sell cues and will trade for you. The command /status will list the active trades. The bot will buy on a bull signal and sell after some time if there is some profit. Otherwise it won’t to anything with a stop loss at 10%. This means that the bot will always sell if you are losing too much. You can however tweak all these parameters, more information in the README file.

(Visited 1,985 times, 8 visits today)

4 thoughts on “High Frequency Trading Tutorial — Install Your First Bot

    1. A buy signal is given based several technical analysis indicators. TA-libs provides those indicators. One of them is MACD.

  1. Thank you for the post!

    All things goes OK until that –>

    $ source .env/bin/activate
    bash: .env/bin/activate: No such file or directory

    What can it be?

  2. Think you are missing some dependencies.
    Don’t use a script, manually do the following steps to troubleshoot:

    1.) Virtual Python environement
    python3 -m venv .env

    2.) Configure and check the environment
    source .env/bin/activate

     

    Make sure you have virualenv and source installed

     

Leave a Reply

Your email address will not be published. Required fields are marked *