For the past 20 month or so, I’ve been building a quantitative trading algorithm in Python by myself. It’s been quite a journey, and here are the main steps and learnings.
Introduction
I started coding in Python in June 2020 by having to do some web scraping while in an internship in a marketing tech company called NextUser. I got introduced to the basics of Python with pandas and numpy, dataframe manipulation, beautifulsoup, webdrivers and proxis etc. Following that introduction to Python, and because I remain a Finance oriented guy, came to me the idea of building my own trading algorithm.
The project
Firstly, I had to choose the asset I wanted to trade. I thought cryptocurrencies would be the easiest asset available for trading through an API, and I knew someone who had already tried to build such a program with this kind of asset, so I decided to focus on Bitcoin.
Then, I had to choose a broker, and after comparing the fees and the API’s of some of them, I chose Coinbase. At that time I started getting used to the API by sending a few basic requests such as account detail, spot prices, etc. I quickly managed to get the OHLC data and volumes, which I needed to start building a quant model.
Finally, I started back-testing a really simple model with a 2 moving average signal, and even tried 3 MA signals. For example, trading would be allowed when the price comes above first MA, then following the remaining 2 MA traditional signals where it should be a long position when the shorter MA is above higher MA, and inversely.