Back to Built

Crypto trading platform

A Ruby microservice system for simulated crypto trading strategies.

Table of Contents

Context

This personal crypto trading system is made of five Ruby microservices: exchange, indicators, trading, storage, and charts. They share a core gem and use PostgreSQL, RabbitMQ, Docker, and Kubernetes.

Problem

Trading rules, monetary values, order execution, wallet changes, and position changes need explicit state and message boundaries. The system also needed simulated execution rather than a claim of live trading behavior.

Approach

  • Route messages through RabbitMQ topic exchanges.
  • Use a wallet state machine with freeze and commit states.
  • Model position lifecycle with a separate state machine.
  • Store monetary values with money-rails in cents.
  • Simulate order execution with a 0.1% fee.
  • Compile trading strategies from a DSL rule compiler.
flowchart LR
  I[Indicators] --> Q[RabbitMQ topics]
  Q --> T[Trading]
  T --> E[Exchange simulation]
  T --> S[Storage]
  S --> C[Charts]

Outcome

The project separates exchange, indicator, trading, storage, and chart concerns into Ruby services while retaining shared core behavior. Explicit wallet and position state machines, cent-based money handling, and fee-bearing simulated execution define the system’s stated trading boundaries.

The project lives in a private repository for now. The workflow is available on request, feel free to ask.