DEV Community

Building a real-time crypto analysis engine with Go, MQTT and Laravel

Building a Real-Time Crypto Trading Platform with Go, MQTT, and Laravel

Have you ever wondered how professional trading platforms handle real-time data, execute orders in milliseconds, and provide seamless user experiences? Today, I'm excited to share OpenTradeWatch, an open-source automated trading platform I've built from the ground up using modern technologies and clean architecture principles.

🎯 The Problem

Most crypto trading automation solutions are either:

  • Expensive proprietary systems with monthly subscriptions
  • Closed-source "black boxes" where you can't verify what's happening
  • Limited to basic strategies without sophisticated technical analysis
  • Difficult to customize or extend

I wanted to create something different: a professional-grade, completely transparent, and fully customizable trading platform that anyone could use, learn from, and build upon.

πŸ—οΈ Architecture Overview

OpenTradeWatch uses a microservices-inspired architecture with three main components:

1. Go Engine - The Analysis Powerhouse

The backend is written in Go for maximum performance. It implements a sophisticated multi-indicator technical analysis system that processes:

  • 11 technical indicators (RSI, MACD, Bollinger Bands, OBV, MFI, EMA, ADX, LSR, VWAP, Keltner Channels, GARCH)
  • Weighted scoring system for signal generation
  • Automatic risk management with Stop Loss/Take Profit calculations
  • Real-time order execution via Gate.io API

Each indicator contributes a weighted score, and the system generates BUY/SELL/NEUTRAL signals with confidence levels ranging from 0-100%.

// Simplified example of how indicators are weighted
type IndicatorWeights struct {
    RSI            float64 // 30%
    MACD           float64 // 25%
    BollingerBands float64 // 15%
    OBV            float64 // 6%
    MFI            float64 // 5%
    // ... and 6 more indicators
}
Enter fullscreen mode Exit fullscreen mode

2. MQTT Messaging - Real-Time Communication

Instead of polling APIs or using websockets directly, I chose MQTT (Message Queue Telemetry Transport) using Mosquitto as the broker. This provides:

  • Low latency pub/sub messaging
  • Decoupled architecture - services communicate through topics
  • Reliable delivery with QoS levels
  • Scalability - easy to add new subscribers

Key MQTT topics:

trades/new          β†’ New trade signals
trades/update       β†’ Trade status updates
indicators/update   β†’ Technical indicator updates
alerts/trigger      β†’ Alert notifications
Enter fullscreen mode Exit fullscreen mode

3. Laravel + Livewire Dashboard - Modern Frontend

The dashboard is built with Laravel 12 and Livewire 4, providing:

  • Real-time updates without writing JavaScript
  • Reactive components for monitoring trades
  • Beautiful UI with TailwindCSS
  • Easy customization and extension

πŸ”¬ Technical Deep Dive: The Weighted Scoring System

The heart of OpenTradeWatch is its sophisticated signal generation algorithm. Here's how it works:

  1. Data Collection: Fetch latest candlestick data from Gate.io
  2. Indicator Calculation: Compute all 11 technical indicators
  3. Score Assignment: Each indicator contributes a weighted score based on bullish/bearish conditions
  4. Signal Generation: Aggregate scores determine final BUY/SELL/NEUTRAL signal
  5. Risk Assessment: Calculate stop loss, take profit, and position sizing

Example output for BTC/USDT:

{
  "signal": "BUY",
  "bullish_score": 78.5,
  "bearish_score": 21.5,
  "confidence": 85,
  "current_price": 45230.50,
  "target_price": 47890.25,
  "stop_loss": 43567.80,
  "risk_level": "MEDIUM",
  "position_size": "3% of capital"
}
Enter fullscreen mode Exit fullscreen mode

🐳 Deployment Made Easy

Everything runs in Docker containers, making deployment incredibly simple:

git clone https://github.com/CristianBernardes/open-trade-watch.git
cd open-trade-watch
docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

That's it! You now have:

  • βœ… PostgreSQL database
  • βœ… Redis cache
  • βœ… Mosquitto MQTT broker
  • βœ… Go analysis engine
  • βœ… Laravel dashboard

Access the dashboard at http://localhost:8888

πŸ“Š What Makes It Different?

1. Complete Transparency

Every line of code is open source. You can verify exactly what the system does, how it makes decisions, and where your API keys are used.

2. Production-Ready Performance

Go's concurrency model allows processing multiple currency pairs simultaneously without blocking. MQTT ensures sub-second message delivery.

3. Educational Value

The codebase demonstrates:

  • Clean architecture in Go
  • Laravel best practices
  • MQTT implementation
  • Technical analysis algorithms
  • Docker orchestration

4. Fully Customizable

Don't like my indicator weights? Adjust them. Want to add new indicators? The architecture makes it straightforward. Need different exchanges? The abstraction layer is ready.

πŸŽ“ Learning Opportunities

Whether you're interested in:

  • Financial technology: Learn how trading systems work
  • Go development: Study a real-world Go application
  • Laravel/Livewire: See modern PHP in action
  • MQTT: Understand pub/sub messaging patterns
  • Docker: Grasp microservices deployment
  • Technical analysis: Explore algorithmic trading concepts

This project has something for you.

πŸ—ΊοΈ Roadmap

Completed:

  • βœ… Complete Go analysis engine with 11 indicators
  • βœ… Gate.io API integration and order execution
  • βœ… MQTT communication layer
  • βœ… PostgreSQL data persistence
  • βœ… Docker environment

In Development:

  • 🚧 Interactive Livewire dashboard
  • 🚧 Real-time charts and visualizations
  • 🚧 Performance analytics
  • 🚧 Advanced alert system

πŸš€ Getting Started

Prerequisites:

  • Docker & Docker Compose (recommended)
  • OR: PHP 8.2+, Go 1.21+, PostgreSQL 14+, Node.js 18+

Quick Start:

# Clone repository
git clone https://github.com/CristianBernardes/open-trade-watch.git
cd open-trade-watch

# Configure environment
cp engine/.env.example engine/.env
# Add your Gate.io API credentials to engine/.env

# Start with Docker
docker-compose up -d

# Access dashboard
open http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Local Development:
Detailed instructions for Linux, macOS, and Windows are available in the README.

⚠️ Important Disclaimer

OpenTradeWatch is a professional technical tool for trading automation. It is:

  • ❌ NOT a promise of profit
  • ❌ NOT financial advice
  • ❌ NOT a guaranteed income system

Trading cryptocurrencies involves significant risk. You are solely responsible for your investment decisions. Always:

  • Start with small amounts
  • Test in sandbox/testnet first
  • Understand the strategies being used
  • Never invest more than you can afford to lose

🀝 Contributing

I welcome contributions of all kinds:

  • πŸ› Bug reports and fixes
  • ✨ New features and indicators
  • πŸ“š Documentation improvements
  • πŸ’‘ Architecture suggestions
  • 🎨 UI/UX enhancements

Check out the Contributing Guidelines to get started.

πŸ’­ Why Open Source?

I believe that knowledge should be accessible to everyone. The financial technology industry often hides behind paywalls and proprietary systems. By open-sourcing OpenTradeWatch, I hope to:

  1. Democratize trading technology - Anyone can learn and use professional-grade tools
  2. Foster education - Developers can study real-world implementations
  3. Build community - Collaborative improvement benefits everyone
  4. Ensure transparency - No hidden algorithms or "black box" decisions

This project represents hundreds of hours of research, development, and testing. It's my contribution to the developer community that has taught me so much over the years.

πŸ”— Links

  • GitHub: CristianBernardes/open-trade-watch
  • Documentation: See README for detailed setup instructions
  • API Reference: Postman collection included in repository
  • License: MIT (free for commercial use)

πŸ“’ Support the Project

If OpenTradeWatch has been valuable to youβ€”whether for learning, building your own trading system, or understanding complex architecturesβ€”please consider:

  • ⭐ Star the repository on GitHub
  • πŸ”€ Share with others who might find it useful
  • πŸ› Report bugs or suggest improvements
  • πŸ’» Contribute code or documentation
  • β˜• Support development if you're able (details in README)

Every bit of support helps me continue developing and maintaining this project while balancing family responsibilities.


🏁 Conclusion

Building OpenTradeWatch has been an incredible journey of combining financial analysis, modern web technologies, and distributed systems architecture. Whether you're a trader looking for automation tools, a developer wanting to learn new technologies, or someone curious about how trading platforms work, I hope you find value in this project.

The code is yours to explore, modify, and use. Let's build something amazing together!

Happy trading, and happy coding! πŸš€


What are your thoughts on using MQTT for real-time trading systems? Have you built similar projects? I'd love to hear your experiences in the comments below!

Top comments (0)