https://github.com/mmontes11/crypto-trade
Cryptocurrency trading PoC
https://github.com/mmontes11/crypto-trade
clickhouse crypto cryptocurrency docker github-actions go golang helm helm-charts kubernetes nats trading
Last synced: 9 months ago
JSON representation
Cryptocurrency trading PoC
- Host: GitHub
- URL: https://github.com/mmontes11/crypto-trade
- Owner: mmontes11
- License: mit
- Created: 2020-12-14T17:11:49.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2023-02-23T17:43:54.000Z (over 3 years ago)
- Last Synced: 2025-01-31T16:46:24.310Z (over 1 year ago)
- Topics: clickhouse, crypto, cryptocurrency, docker, github-actions, go, golang, helm, helm-charts, kubernetes, nats, trading
- Language: Go
- Homepage: https://crypto-trade.mmontes-dev.duckdns.org
- Size: 103 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crypto-trade
[](https://github.com/mmontes11/crypto-trade/actions?query=workflow%3ALint)
[](https://github.com/mmontes11/crypto-trade/actions?query=workflow%3ABuild)
[](https://github.com/mmontes11/crypto-trade/actions?query=workflow%3ATest)
[](https://github.com/mmontes11/crypto-trade/actions?query=workflow%3ARelease)
[](https://github.com/mmontes11/crypto-trade/actions?query=workflow%3ADeploy)
[](https://artifacthub.io/packages/search?repo=mmontes)
[](https://goreportcard.com/report/github.com/mmontes11/crypto-trade)
[](https://pkg.go.dev/github.com/mmontes11/crypto-trade)
Simulates real time cryptocurrency tradings in a microservice ecosystem.
---
- [Tech stack](#tech-stack)
- [How it works](#how-it-works)
- [Installation](#installation)
- [API](#api)
- [Production environment](#production-environment)
---
## Tech stack
- [Go](https://golang.org/)
- [Nats](https://nats.io/)
- [ClickHouse](https://clickhouse.tech/)
- [Docker](https://www.docker.com/)
- [Kubernetes](https://kubernetes.io/)
- [Helm](https://helm.sh/)
- [GitHub actions](https://github.com/features/actions)
## How it works
It contists in 3 microservices:
- **publisher**: Generates random trades and sends them to Nats.
- **subscriber**: Receives trades and stores them in ClickHouse.
- **api**: Exposes a REST API with the trades from ClickHouse.
## Installation
###### Local
1. Set up Nats and ClickHouse:
```bash
$ docker-compose -f docker-compose.services.yml up -d
```
2. Start each microservice in a different tab by manually running:
```bash
$ make run
```
###### Local + Tmux
Install [tmux](https://github.com/tmux/tmux) and then:
```bash
$ ./scripts/run-dev.sh
```
###### Docker
```bash
$ ./scripts/run-docker.sh
```
## API
[](https://app.getpostman.com/run-collection/155f5c6f3ba941caed61#?env%5Bcrypto-trade%20PRO%5D=W3sia2V5IjoidXJsIiwidmFsdWUiOiJodHRwczovL2NyeXB0by10cmFkZS5tbW9udGVzLWRldi5kdWNrZG5zLm9yZyIsImVuYWJsZWQiOnRydWV9XQ==)
###### GET /health
Indicate the service is up and running.
Responses:
- **200 OK**
###### GET /api/trades
Retrieves real time cryptocurrency trades.
Query params:
- **groupBy**: second | minute | hour
- **crypto**: btc | eth
- **currency**: eur | usd
- **fromDate**: 1970-01-01T00:00:00Z
- **toDate**: 2050-01-01T00:00:00Z
- **limit**: 100
Responses:
- **200 OK**
- **404 Not Found**
Body:
- Array of trades
## Production environment
[https://crypto-trade.mmontes-dev.duckdns.org/api/trades?groupBy=hour&crypto=btc¤cy=eur&fromDate=2021-01-01T00:00:00Z](https://crypto-trade.mmontes-dev.duckdns.org/api/trades?groupBy=hour&crypto=btc¤cy=eur&fromDate=2021-01-01T00:00:00Z)