0

The best strategy for simple investing in cryptocurrencies (part 2)

In the second part of this article, I will explain further how to dollar-cost average in the most simple and cost-effective way. The best way to invest in cryptocurrencies with dollar cost average strategy is to do it automatically, without manually buying, so this will be the focus of part 2 of this article.

Without further delay, let’s dig in. If you didn’t read the first part of the article, please do that before continuing.

You can dollar cost average in more than one way! Let’s go over the pros and cons of each.

Manually

Positive

  • Cheapest fees
  • Can be done on any exchange
  • All recurring intervals are supported, you just need to set your alarm clock 🙂

Negative

  • Inefective and slow way of buying
  • Depends 100% on you and your time
  • Your mood can affect how much and if you will make buy order

Set an alarm on certain days of week/month, maybe even a certain time of day, and log into the exchange. Manually set buy orders and buy the same dollar amount of the same predefined cryptocurrency.

Sounds easy, and it is. But the whole process depends 100% on you, your time, and your mood, so you’ll probably want to switch to one of the automatic buying options sooner rather than later.

If you decide manual buys are good enough for you, please check the list of reputable crypto exchanges I recommend.

Automatic recurring buys on crypto exchange

Positive

  • Fast and realiable way of buying
  • You need just few minutes to set it up

Negative

  • Fees are higher
  • Only some of recurring periods are available
  • Not all coins are supported
  • Higher minimum buy amount

This is a very fast and effective way of dollar-cost averaging your investments, but it has a few drawbacks. Most drawbacks, if not all, are crypto exchange dependent.

For example, some exchanges limit your minimum recurring buy to 50$ / coin / buy, which is too much if you decided you want to invest more often with smaller amounts. Some limit your recurring buys to once a week and there is no way to buy more often than once a week.

Let’s go into details for all recommended exchanges.

Bitpanda

Name – Savings plan
Available buying frequencies – daily, weekly (on the selected day), bi-weekly (every two weeks on the selected day), monthly (on the selected date)
Minimal buy size – 25€
Coins available for recurring buy – all exchange coins
Pay with – credit/debit card, SEPA Direct Debit
Fee – approx. 1,50%-3,30%

When you set up a plan, the first buy will be immediate, all other buys will be according to schedule. Bitpanda allows you to select the time of day when buys will occur in 15min intervals (10:00, 10:15, 10:30, etc.).

Link to websiteLink to review

Binance

Name – Recurring buy
Available buying frequencies – daily, weekly (on the selected day), bi-weekly (every two weeks on the selected day), monthly (on the selected date)
Minimal buy size – 15€
Coins available for recurring buy – 89 coins at the time of writing
Pay with – credit/debit card
Fee – approx. 3,50%

Binance has two types of recurring buys available.

Name – Auto-invest
Available buying frequencies – daily, weekly (on the selected day), bi-weekly (every two weeks on the selected day), monthly (on the selected date)
Minimal buy size – 10€, minimally 2 coins
Coins available for recurring buy – only 23 coins, a lot of high profile coins are not available
Pay with – spot balance of USDT or BUSD stablecoins
Fee – not 100% sure, but it seems like a market buy fee of 0,10%

When you set up a Recurring buy plan, the first buy will be immediate, all other buys will be according to schedule. In the Auto-invest plan, all buys will be according to schedule, with no immediate buys. Binance Recurring buy and Auto-invest allows you to select the time of day when buys will occur in 1h intervals (10:00, 11:00, 12:00, etc.).

The Auto-invest plan will automatically transfer all bought crypto to a flexible savings plan which will give you small interest on your crypto.

Link to websiteLink to review

Coinbase

Name – no special name, just part of the buy screen
Available buying frequencies – daily, weekly (on the day of the first buy), 1st and 15th of the month, monthly (on the date of the first buy)
Minimal buy size – 2€
Coins available for recurring buy – all exchange coins
Pay with – credit/debit card
Fee – depends on the size of buy, approx. 4,00% – 10,00%

When you set up a plan, the first buy will be immediate, all other buys will be according to schedule.

Link to websiteLink to review

Automatic recurring buys with your script

Positive

  • Cheapest fees
  • Can be done on almost any exchange
  • All recurring intervals are supported
  • Fast and realiable way of buying
  • All coins are available for buying
  • Lowest minimum buy amount

Negative

  • Tehnical background needed
  • Very basic script writing needed

This is absolutely the best way to automate your buys, but it’s also the most technical. I’m running my script on Synology NAS, which is Linux-based, but you can also run it on VPS (virtual private server) or even a regular Windows PC.

It will take a few hours to set up if you aren’t experienced in Node.js, much less if you are, but once it’s done, you can forget about it and it will keep buying until you turn it off.

You can use this method to automate your investing on any crypto exchange, so you aren’t dependent just on crypto exchanges that provide automatic investing. All you need from an exchange is access to the exchange API. Search your exchange support files to find out how to access API for a particular exchange.

What’s needed?

I’ll list in order what you need to set up to have a working environment and provide you with the script, but I will not go into details on how to do everything. If you are interested, you will need to Google how to do it yourself.

The machine on which the script will run.

Windows PC, Linux PC, Linux server of any kind, or VPS (virtual private server). I’m running my script on my Synology NAS which is Linux-based. If you have any kind of NAS, you can probably run it there.

The best choice is a Linux server or VPS just because they are on 24/7. If you decide to run it on your PC, be sure to have it running at the times your recurring buys will trigger. If your PC isn’t turned on, the script will not run.

VPS can be dirty cheap to rent, as cheap as 2-5$ / month, so if you don’t already have a machine that is on 24/7 that is probably the best way to run your scripts. I remember virmach.com offered some cheap VPS, but there are probably more companies that offer cheap VPS.

Node.js and CCXT

When you decide on which machine and OS you will run your script, you need to install Node.js first. Since I don’t know which combination of hardware and OS you will use, you need to search the Web on how to install Node.js.

After you’re done, you need to install CCXT (CryptoCurrency eXchange Trading Library). CCXT is an open-source library that helps standardize connecting to crypto exchange API so you don’t have to do everything alone.

Install instructions can be found here.

Edit and save buy script!

Copy my script, edit it to your liking and save it to a pick_something.js file in a folder where you installed Node.js and the CCXT library. Script has comments which will help you edit only parts that are needed. If you want to buy more than one coin pair, for example, if you want to buy BTC/USDT and ETH/USDT, you need to have a separate script for every pair.

If you are using Windows, the best way to edit the script is with Notepad++.

"use strict";

const ccxt = require ('ccxt')
	, exchange = new ccxt.ftx ({
    'apiKey': 'xxx', // replace ftx in line above with your exchange code (https://docs.ccxt.com/en/latest/exchange-markets.html), and xxx in this line with your exchange apiKey
    'secret': 'xxx',  // replace xxx with your exchange secret
    'enableRateLimit': true,  // required by the Manual: https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
})
	, symbol = 'BTC/USD' // replace with pair you want to trade
	, type = 'limit' // this script is made for limit orders, you can also use market, buy you need to change other parts of script also
	, side = 'buy' // buy or sell
	, params = {}
	, minKK = 2 // check your exchange trading interface, how many decimals in quantity of that coin is supported
	, minKC = -0.01 // how much higher or lower you want to place your bid from best bid
	, amountK = 15 // how much you want to spend on trade
	, since = exchange.milliseconds () // current exchange time at the time of script execution

// ----------------------------------------------------------------------------

const tryToCreateOrder = async function (exchange, symbol, type, side, amount, price, params) {

    try {

        const order = await exchange.createOrder (symbol, type, side, amount, price, params)
        return order

    } catch (e) {

        console.log (e.constructor.name, e.message)

        if (e instanceof ccxt.NetworkError) {

            // retry on networking errors
            return false

        } else {

            throw e // break on all other exceptions
        }
    }
}

// sleep function
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

// ----------------------------------------------------------------------------

;(async function main () {

    await exchange.loadMarkets ()
	
	await sleep(5000) // delays script execution for X ms (1000ms = 1 sec)
	while (true) {
		const ordersO = await exchange.fetchOpenOrders (symbol, since) // dohvaća otvorene naloge
		const ordersC = await exchange.fetchMyTrades (symbol, since) // dohvaća zatvorene naloge
		await sleep(2500) // give time to fetch open orders
		
		var count = ordersC.length
		var i = 0
		
		// if there is closed order, then trading is done
		if (count > 0) {
			console.log ("There is a closed order! Ending script.")
            break
        }
		
		// if there is an open order, then trading isn't done, we need to cancel order and open new
		if (ordersO.length > 0) {
			const orderID = ordersO[0]['id']
			await exchange.cancelOrder (orderID, symbol)
			console.log ("Open order detected! Canceling pen order:", orderID)
			await sleep(2000)
		}
		
		const orderbook = await exchange.fetchOrderBook (symbol) // fetch orderbook
		let bid = orderbook.bids.length ? orderbook.bids[0][0] : undefined // fetch best bid
		const price = bid + minKC // increase or decrease best bid for defined amount
		const amount = (amountK / price).toFixed(minKK) // calculate largest possible order size and rounding it to defined number of decimals
	
		// opening new order
		let order = false
		while (true) {
			order = await tryToCreateOrder (exchange, symbol, type, side, amount, price, params)
			await sleep(2000)
			if (order !== false) {
				break
			}
		}
		const orderID = order['id']
		console.log ("New order created: ID", orderID, "Price", price, "Quantity", amount, "Total", (price*amount).toFixed(8))
				
		await sleep(20000) // time is ms between checking if order if closed and opening new order (1000ms = 1s)
    }
})

()

Automate node.js script in Cronjob or Windows Task Scheduler

The last part of this not-so-hard setup is automating starting of your scripts so you don’t need to do it manually. This is accomplished via Cron (cron job) if you are using Unix-like OS, or Windows Task Scheduler if you are using Windows.

Synology Task
Synology task
Windows Task Scheduler
Windows Task Scheduler
Crontab
Crontab

You can see examples of Cron and Windows Task Scheduler in the above pictures. Since every system is different you will have to lurk the Web to find out how to set it up in your OS. The guide in this link looks good for Windows Task Scheduler, but I didn’t test it myself.

That’s all folks! Good luck in setting everything up and earning some money on those crypto investments!

Libertus Avatar
Libertus

Crypto enthusiast since February 2018 and apparently popular scriptwriter on Tradingview. :) Working in a senior management position in a company that has absolutely nothing to do with crypto or capital markets. This is my personal blog that aims to help people understand crypto and make it easier for them to make their own conclusions. Nothing I write here is an investment advice or advice to buy. Always do extensive research prior to buying or investing your hard-earned money in anything, especially cryptocurrencies. Cryptocurrency space is more than 90% scam, so losing money is very easy. Since I am not a native English speaker, forgive me for any spelling mistakes.

Leave a Reply

Your email address will not be published.