DEV Community

Cover image for HyperTrade - Distributed cryptocurrency trading bot
Karan Pratap Singh
Karan Pratap Singh

Posted on

HyperTrade - Distributed cryptocurrency trading bot

Hi everyone, I wanted to share a recent weekend project of mine. HyperTrade, a ready to deploy, distributed cryptocurrency trading bot. I had a lot of fun building this and recently opensourced it.

Note: use this software at your own risk. The author assumes no liability for your trading outcomes

💡 Motivation

A few months ago I got into the crypto market. It was all new and fascinating to me. The idea of this project originally came from a script I used to automate buying and selling of fiat assets.

I was curious and wanted to scale it into a real system which can execute trades for me. I had a lot of fun building this. I got to play with lots of different technologies while growing my financial knowledge.

Feel free to reach out to me if you have any additional questions. There are lots of fixes and features to be done!

It is important to note that this project is under active development and was developed as an experiment. Currently, only Binance is supported but contributions are welcome!

🔍 Overview

Here's a short overview of the project.
overview

📷 Screenshots

Here are some screenshots from the web interface.

charts

dataframe

https://user-images.githubusercontent.com/29705703/160771120-d114a872-22e5-4636-a49d-f6cad69e7675.png

https://user-images.githubusercontent.com/29705703/160771097-99820002-bc18-4975-90ce-c73ae5648c32.png

https://user-images.githubusercontent.com/29705703/160771117-a1cc31eb-e96b-4f15-9ca9-ec7b6e5a7742.png

https://user-images.githubusercontent.com/29705703/160771686-3513b071-9ee6-4ce0-98f0-27df2778de5c.png

https://user-images.githubusercontent.com/29705703/160771663-41d44210-7f1a-4dca-a8cb-7c3b9b48e6f7.png

✨ Features

This system has lots of features such as:

  • Web UI: Real-time access for charts, technical indicators, and portfolio.
  • Configurable: Supports assets and strategies customization easily without touching any code!
  • Portable: Export your trades and real-time data frame to CSV.
  • Multiple Assets: Trade multiple crypto assets simultaneously!
  • Telegram Support: On the move? Use Telegram bot to receive real-time notifications and much more.
  • Ready to deploy: Comes with Infrastructure as Code which is ready to deploy to Digital Ocean.
  • Easy to upgrade: Modify the system easily to your needs.

⚡️ Technologies

https://user-images.githubusercontent.com/29705703/160770691-f4b73985-7c6a-4a7c-b370-dc6d6481fcc2.png

🏭 Architecture

It's a microservices based architecture with event driven approach for decoupling. It uses distributed streams and messaging which keeps the system simple yet robust to make sure it can grow in future.

https://user-images.githubusercontent.com/29705703/160770666-5fd144f2-623b-4e30-9037-6e93c49d7b2f.png

https://user-images.githubusercontent.com/29705703/160770680-39efcb84-48a9-4841-85ac-d25f658d1f0c.png

Note: Kubernetes diagram was generated using Lens - The Kubernetes IDE

Why so many technologies?

This started as an all Go project, but then I decided to add Python to the mix as it has a really good ecosystem for technical indicators and mathematical use cases.

For the web, I used React as it's easy and TypeScript provides some sanity to JavaScript projects!

Nginx and Postgres fit right in as the use case grew. As always, use what's right for the project!

Why event driven?

Originally I made this using HTTP REST, but systems like this are event driven by nature. Plus this approach helps to decouple services even more.

How do services communicate?

All the messaging infrastructure use cases are handled by NATS. Inter-service communications are mainly via publish-subscribe and request-reply patterns. Essentially, NATS acts as our service mesh!

We also use JetStream for real-time, persisted data streams.

https://user-images.githubusercontent.com/29705703/156038663-61d9c242-de32-41da-9a59-a2452a0ead11.png

https://user-images.githubusercontent.com/29705703/156039685-bb32987e-a11f-4246-a6fa-1d74f6388119.png

Read more about Distributed communication patterns with NATS

💬 Conclusion

Hope you liked the idea! Feel free to reachout to me if you have any questions. Getting started and the deployment guide for this project can be found in this repository.

Top comments (0)