SkillAgentSearch skills...

HyperTrade

Ready to deploy, distributed cryptocurrency trading bot

Install / Use

/learn @karanpratapsingh/HyperTrade

README

<p align="center"> <img width="100px" src="./assets/logo.png"> <h1 align="center">HyperTrade</h1> <p align="center">Ready to deploy, distributed cryptocurrency trading bot.</p> </p> <p align="center"> <a href="https://www.buymeacoffee.com/karanps" target="_blank"><img height="30px" src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-1.svg" alt="Buy Me A Coffee" ></a> <img src="https://img.shields.io/github/workflow/status/karanpratapsingh/HyperTrade/Build?style=for-the-badge" /> <img src="https://img.shields.io/badge/License-GPL-red.svg?style=for-the-badge" /> <img alt="Twitter: karan_6864" src="https://img.shields.io/twitter/follow/karan_6864.svg?style=for-the-badge&logo=TWITTER&logoColor=FFFFFF&labelColor=00aced&logoWidth=20&color=00aced" target="_blank" /> <img height="29px" src="https://web-platforms.sfo2.digitaloceanspaces.com/WWW/Badge%203.svg" alt="DigitalOcean Referral Badge" /> <br /> <p align="center"> <b>USE THIS SOFTWARE AT YOUR OWN RISK. THE AUTHOR ASSUMES NO LIABILITY FOR YOUR TRADING OUTCOMES.</b> <br />

<img width="49.5%" src="./assets/screenshots/dashboard/charts.png" alt="charts" /> <img width="49.5%" src="./assets/screenshots/dashboard/dataframe.png" alt="dataframe" /> <img width="49.5%" src="./assets/screenshots/dashboard/portfolio.png" alt="portfolio" /> <img width="49.5%" src="./assets/screenshots/dashboard/config.png" alt="config" /> <img width="34%" src="./assets/screenshots/dashboard/config-strategy.png" alt="config-strategy" /> <img width="34%" src="./assets/screenshots/dashboard/charts-indicators.png" alt="charts-indicators" /> <img width="30.6%" src="./assets/screenshots/bot/telegram.png" alt="telegram" />

📖 Contents

🔍 Overview <a id="overview" />

Here's a short overview of the project.

overview

💡 Motivation <a id="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 that 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!

Please leave a ⭐ as motivation or support by donating if you liked the idea 😄

✨ Features <a id="features" />

This system has lots of features such as:

  • Web UI: Real-time access to 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 <a id="technologies" />

<img width="98%" src="./assets/diagrams/stack.png" alt="stack" />

❓ Working <a id="working" />

Here's a simple diagram illustrating how streams and events are published/subscribed in the system. We use NATS for messaging and streams, more about that in the architecture section.

Basically, The Exchange service publishes Kline/Candlestick data based on our configuration. Strategy service then subscribes to it and publishes a stream of dataframe which contains the indicators, buy/sell signals, and other metadata. The buy/sell signals are determined using the configuration as well, where we can customize our strategies given that they are supported.

Now, The Exchange service subscribes to the dataframe stream and executes trades on the signal using the Binance API. Any event such as order, trade, error, etc is published and then the Notification service can send a message to the user using the Telegram API.

Note: This only represents core events, there are more events for the Web and DB services.

<img src="./assets/diagrams/working.png" alt="working" />

🏭 Architecture <a id="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 the future.

<img width="60%" src="./assets/diagrams/architecture.png" alt="architecture" /> <img width="37.45%" src="./assets/diagrams/k8s.png" alt="k8s" />

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.

<img width="55%" src="https://user-images.githubusercontent.com/29705703/156038663-61d9c242-de32-41da-9a59-a2452a0ead11.png" alt="publish-subscribe" /> <img width="43.85%" src="https://user-images.githubusercontent.com/29705703/156039685-bb32987e-a11f-4246-a6fa-1d74f6388119.png" alt="request-reply" />

Read more about Distributed communication patterns with NATS

Why Kubernetes? Isn't it overkill?

I agree! Kubernetes can be bit overkill, especially for this project. But my goal here was to keep it cloud agnostic, even though it was very tempting to just spin up AWS lambdas with event bridge.

🍕 Getting Started <a id="getting-started" />

Here we will setup our development environment. But first, we will need to install the following tools.

Tools

Steps

  • Once all the tools are installed, execute make prepare to prepare the local environment.
  • Create a infrastructure/k8s/env.yaml to similar structure as infrastructure/k8s/env.example.yaml and follow this guide.
  • Review the configuration in services/exchange/config.json
  • Start development with make dev command.
  • Use make stop to stop the local minikube cluster.

🛠 Customization <a id="customization" />

We can customize trading strategies either via web app or services/exchange/config.json directly.

Currently, only few trading strategies like RSI and MACD are supported and I plan to add more soon.

<img width="60%" src="./assets/screenshots/dashboard/config-strategy.png" alt="config-strategy" />

📚 Usage <a id="usage" />

💬 Telegram <a id="telegram" />

Telegram bot helps us to interact with the system easily and receive real-time notifications.

Commands

The telegram bot supports the following commands:

<img src="./assets/screenshots/bot/telegram-commands.png" alt="telegram-commands" />
  • /configs: Get asset configurations.
  • /balance: Get current account balance.
  • /positions: Get actively held positions.
  • /stats: Get portfolio statistics.
  • /enable: Enable trading for a symbol.
  • /disable: Disable trading for a symbol.
  • /dump: Dump all the positions for a symbol.

Note: enable, disable and dump commands are symbol specific, and are executed as /cmd symbol. Example, /enable ETHUSDT

💻 Web <a id="web" />

Since this application deals with sensitive financial data, it is not recommended to expose it via ingress unless we have proper RBAC authorization in place. Hence, it is recommended to connect to it via port-forwarding on your local machine.

Steps

  • Connect to the application via port-forwarding using make connect command.

Note: Make sure doctl is authenticated, and we're using the correct k8s cluster name.

  • Open localhost:8080 to see the web interface.

  • Once done, use the `

View on GitHub
GitHub Stars294
CategoryDevelopment
Updated4d ago
Forks65

Languages

Go

Security Score

100/100

Audited on Apr 2, 2026

No findings