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
}
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
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:
- Data Collection: Fetch latest candlestick data from Gate.io
- Indicator Calculation: Compute all 11 technical indicators
- Score Assignment: Each indicator contributes a weighted score based on bullish/bearish conditions
- Signal Generation: Aggregate scores determine final BUY/SELL/NEUTRAL signal
- 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"
}
π³ 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
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
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:
- Democratize trading technology - Anyone can learn and use professional-grade tools
- Foster education - Developers can study real-world implementations
- Build community - Collaborative improvement benefits everyone
- 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)