I've programmed a crypto currency trading bot. This article introduces the idea, some programming details and the documentation.
Trading assets can be a full-time job. If one doesn't want to spend the time, one can just buy in regular intervals for fixed amounts of money and realize the dollar cost average effect. Developing this idea a little further leads to buying when the prices drop to obtain more assets for the same money spent. In order to do it automatically, Chris and I have implemented a cryptocurrency buying bot: Vigilant Crypto Snatch.
The program started out really simple, as a single file Python script. It would use the Bitstamp API to query the current market price of Bitcoin. Then it would take the Cryptocompare API to query the market price a specified time earlier. If the prices had dropped a given percentage, it would send a buy order via the Bitstamp API. Time delay, drop percentage and amount of money to spend have to be set by hand, and in the first iteration by guess.
Early 2021 Chris has taken his business from Bitstamp to Kraken and wanted to update the bot. I looked at the code which did not age so well. So taking all the knowledge and motivation from reading Clean Code, I started to refactor the whole program. The marketplace got hidden behind an interface and then it was easy to implement the market price query and buy order submission for Kraken as well. Now one can dynamically choose between the two marketplaces at startup. Similarly I have generalized the trigger logic to now support arbitrary triggers.
At work I learned about Streamlit and started an evaluation interface with that. Now you have a web interface where you can make a few selections and simulate strategies on historical data. It gives summary tables and interactive plots such that strategies can be compared easily.
I've written some more documentation and by now there is a Telegram group with 45 people, which means that the documentation was sufficiently well written for people to use it. It is a really nice hobby project where I can try out clean code style, refactorings and have some programming fun.
And who knows, perhaps the strategy will pay out in the end. Or Bitcoin will just become yet another burst bubble. We'll see eventually.