Building a Crypto Trading Bot

auto-manage your portfolio with RESTful APIs

Mark Cleverley
6 min readSep 27, 2020

Last week I built a simple trading algorithm that buys or sells based on temporal AI-generated Bitcoin price predictions. It delivered 9% average returns in 90 days, which was quite fun to see.

However, it was a dreadfully basic implementation, for several reasons:
It didn’t simulate “noise” such as slippage or various exchange fees that a portfolio will face in the real world.

It also, quite importantly, wasn’t the present real world. I’m happy to boast of great success on historical data, but if the bot hasn’t made any real cash as of yet, many would understandably restrain their enthusiasm.

Past behavior is the best predictor of future behavior — right up until it isn’t. That moment can be quite painful for investors who inadvertently run into it, so let’s set about rebuilding a backtesting algorithm into a true trading bot.

There’s two things to take care of before that cute little bot is ready to sail:

  1. Connect it to an API for output + websocket for input
  2. Built a more nuanced algorithm

The latter part is quite interesting, and will delve somewhat into economic theory and risk management. But we won’t get anywhere…

--

--

Mark Cleverley

data scientist, machine learning engineer. passionate about ecology, biotech and AI. https://www.linkedin.com/in/mark-s-cleverley/