How to do dollar cost averaging with BuyCoins

Ire Aderinokun
Helicarrier
4 min readDec 28, 2020

--

As you may have noticed, the price of Bitcoin has been steadily rising over the last few weeks. We broke the previous highest price of ~$19,997 in December 2017, and, at the time of writing, the price is now $26,931.31 (over ₦13m)!

When is the best time to invest in Bitcoin?

A lot of people tend to think that you need to invest a large amount of your money in one go, preferably at a “dip”, so you can then sell at a “peak”. But a more strategic method is what is called “dollar cost averaging”.

DCA is “is an investment strategy that aims to reduce the impact of volatility on large purchases of financial assets such as equities.

By dividing the total sum to be invested in the market (e.g., $100,000) into equal amounts put into the market at regular intervals (e.g., $1,000 per week over 100 weeks), DCA seeks to reduce the risk of incurring a substantial loss resulting from investing the entire lump sum just before a fall in the market.”

So, by buying a small amount of Bitcoin daily/weekly/monthly, you can average out the cost of your investment to benefit from the “dips” but also protect from the “peaks”.

How to do DCA with Bitcoin

We created a small, open-source, project, to automate the process of applying the concept of DCA with Bitcoin. Right now, this is a project that may require some technical know-how to setup. That said, the instructions below are thorough and we believe anyone can get it setup!

If you’re interested in this being added to the app, please let us know! Tweet us @buycoins_africa or send us an email at support@buycoins.africa .

What you’ll need

Step 1 — Get access to the BuyCoins API

You’ll need access to the BuyCoins API in order to make automatic purchases. To apply for access, send an email to support@buycoins.africa with the email address attached to your BuyCoins and a link to this article.

Once you have access, go to your API Settings page. Generate and copy your public and secret keys. These keys will be used as the BUYCOINS_API_PUBLIC and BUYCOINS_API_SECRET environment variables on Heroku. Store them in a safe place until we get to step 4.

Step 2 — Create a Fauna database

Sign up for an account with Fauna DB and create a database (you can name it anything you want).

Under your database security settings, create a new Key with the admin role and copy your generated secret key. This key will be used as the FAUNA_DB_SECRET environment variable on Heroku so store it in a safe place until we get to step 4.

Step 3 — Decide on your daily/weekly/monthly spend

Next, you’ll need to specify how often you want to buy Bitcoin, and how much you want to spend on each purchase. You do this by setting the following environment variables on Heroku:

BUY_FREQUENCY

  • DAILY - if you want to buy every day
  • WEEKLY_[1–7] — if you want to buy once a week. e.g. WEEKLY_1 to buy every Monday
  • MONTHLY_[1–29] — if you want to buy once a month. e.g. MONTHLY_5 to buy on the 5th day of each month

BUY_AMOUNT
The amount (in Naira) you want to purchase at each frequency.

Need more help? Click here — https://buycoins-recurring-buy.herokuapp.com/setup

Step 4 — Deploy to Heroku and add environment variables

Click here to deploy to Heroku

When deploying, you’ll need to add the environment variables from the previous steps to your new app.

Step 5 — Setup Heroku Scheduler

Finally, go to your Heroku project “Resources” section and click the Heroku Scheduler Add-on. Next, create a new job using the following settings:

  • Schedule: Every day at... (any time of your choosing)
  • Run Command: recurringBuy

Note: Make sure the job is set to run every day, regardless of your BUY_FREQUENCY.

Once everything is setup, the application will make purchases on your behalf from your BuyCoins account. Make sure you have enough NGNT in your account to make your purchases! Go to the Deposit Naira page to get NGNT.

You’ll also be able to see a summary of your purchases at the deployed domain of your Heroku application.

This project is available open-source at https://github.com/buycoinsafrica/recurring-buy . Feel free to fork the project or submit an issue if you want more features included.

--

--