Crypto News

Crypto trading bot: DCA bot for Binance

Before we jump into the crypto trading DCA bot, let’s briefly cover what DCA is, and how can this trading strategy be automated.

What is DCA?

DCA or Dollar Cost Averaging is a trading strategy that is supposed to minimise the risk associated with trading volatile assets (such as cryptocurrencies), by averaging out your buy price over a prolonged period of time. By doing so, a DCA strategy aims to remove the need to time the market, which is typically an import part of a BTD or Buy The Dip strategy.

Therefore, DCA for cryptocurrency is a good strategy for traders with lower risk tolerance, or simply, investors who lack the time and/or patience to time the market (Investopedia, 2021).

A DCA strategy could be as simple as buying a certain cryptocurrency every week. Doing so consistently you will average out in the long run.

For an deep-dive into the actual code and process of writing this bot, watch my latest video here:

The DCA trading bot for Binance

If you’re already familiar with DCA and its benefits, and have tried it for a while, you will have probably come across one of the limitations that come with executing your DCA strategy on an exchange like Binance. Binance, long with other exchanges seem to lack a very basic reporting metric, the total cumulative average of your buys for any given coin. This makes it difficult to keep track of your average DCA cost, and reduces your ability to observe and potentially improve your DCA strategy.

The DCA trading bot that I’m about to share with you aims to solve two problems currently associated with DCA-ing through an exchange such as Binance:

  • It will automate your DCA strategy, making it a set and forget approach
  • It will provide much better reporting on your DCA performance
  • It will notify you via e-mail one your periodical DCA has been completed

Getting started with the DCA trading bot:

Here is everything you need to get this dca bot running:

  • A Binance account
  • Python 3.7+
  • Some Python knowledge
  • A Raspberry Pi / A VPS / Willingness to let your computer run 24/7

1. Generate API Keys

The first requirement is a Binance account, if you don’t have one, or would like to create a separate account to run the bot on, go ahead and create one here. You can use my referral link to get 5% off your trading fees. With a Binance account created, we’re going to Generate some API Keys.

To get your mainnet keys, navigate over your account, and click on API management.

On the API management page, give a label to your API key and click create API.

Once your key and secret have been generated make sure to save these, as you will only be shown the secret once. You’ll need to regenerate your keys if you haven’t saved the secret.

Now let’s give it the permissions that we require to run the bot on it. We’re only going to do Spot trading, so we only need to select Enable Reading and Enable Spot & Margin Trading. For security reasons, we will NOT enable Withdrawals.

2. Download the source code

Once that’s all set up and ready to go, head over to the GitHub Repository for the DCA trading bot and download the source code. You can do this by using the following command, or by downloading the zip file manually. The option below is the preferred way, as it creates a link between your local copy and the origin of the code on GitHub.

3. Install dependencies for the DCA bot

This is a relatively lightweight project, but you will still  need to install some dependencies in order to get the the code running. Make sure you have pip installed on your machine, and then run the following command inside your project’s root directory:

4. Configure the DCA bot

Once all the dependencies have been installed, you will need to configure your crypto DCA bot so that it runs according to your specifications:

  • Open the auth/auth.example.yml file and paste your Binance API key and secret that you have generated and rename the file to auth.yml
  • Open the config/config.example.yml file and paste your email address and password you wish to receive e-mail notifications to and rename the file to config.yml. This needs to be a gmail address otherwise it won’t work. Feel free to create a burner address if you don’t want to use your main.

Now let’s take a deeper look at the config file, as this essentially tells the DCA bot what to do:

  • QUANTITY refers to the amount of unit to buy in the PAIRING coin of your choice. If pairing is USDT, you will DCA 15 USDT worth of any coin you choose.
  • PAIRING is the pairing asset connected to the base asset. For example, if PAIRING is USDT, all your DCAs will happen in COIN_USDT
  • DCA_EVERY represents how often to DCA, in days. DCA_EVERY: 7 means the bot will DCA every 7 days.
  • TEST enables test mode. While TEST is True the algorithm will papertrade, and not place real trades using your Binance funds.
  • SEND_NOTIFICATIONS enables or disables the option to receive e-mails once a DCA is complete.
  • EMAIL_ADDRESS and EMAIL_PASSWORD are the credentials where you will receive notifications to.

Now that your DCA bot is all configured, there is one last step needed before you can algorithmically DCA you way to the moon.

5. Select Assets to DCA

Open the config/coins.example.yml and add the assets you want to DCA and then rename the file to be coins.yml. Make sure you follow the exact structure as below:

6. Remove reporting examples

Inside of the trades/dca-tracker folder you will find a few examples reports on how the DCA bot will report back to you. Make sure you remove these before starting the bot.

Performance reporting for the DCA bot

Assuming you’ve followed all of the above steps, your DCA trading bot should now be fully operational. All that’s left to do is run main.py from the root directory.

Now let’s take a look at how this crypto trading bot will report back to you. Every time the bot DCAs, it will create a series of images, named after each asset that you are DCAing. So according to the example above, the bot will create the following files: BTC.png, ETH.png, DOT.png, SOL.png, XLM.png.

These images will update each time a new trade is being placed, allowing you to accurately track and graph the performance of your DCA strategy. In addition to that, it will always report its average DCA performance at the top of the chart. 

 

 

Did you enjoy this article? Here’s what to do next…

Sponsor my work and get access to exclusive discord channels  by buying a subscription.
If  you’re looking for a custom-built cryptocurrency trading algorithm, shoot me a message and let’s talk
Subscribe to the newsletter for more awesome content!

The post Crypto trading bot: DCA bot for Binance appeared first on Automated Cryptocurrency Trading.

Read more: https://www.cryptomaton.org/2021/12/22/dca-crypto-trading-bot-binance/

Text source: Automated Cryptocurrency Trading

Disclaimer: Financial information and news are not financial advice, read the disclaimer.
Buy & sell Crypto in minutes

Join BINANCE!

The world's largest crypto exchange

You're just steps away from receiving your reward.

The most complete Crypto News Center.

Search Stories:

Latest top stories