Inspiration

95% of retail traders fail from poor risk management, not bad signals. Traditional bots use fixed stop losses causing slow capital erosion while cutting winners short. I built MaliBot to solve this with adaptive exits that protect capital and let profits run.

What it does

MaliBot monitors 8 synthetic indices across 6 timeframes simultaneously. It uses 4-tier adaptive trailing stops: +8% profit locks 4% gain, +15% widens to 6% trail, +25% allows 8% room, +50% gives 15% swing space. A 90-second kill switch exits stagnant losers. Global position lock allows one active trade at a time across all assets. Minimum 1:2.5 risk/reward enforced on every trade.

How we built it

FastAPI backend with Supabase authentication and Redis caching. Four-layer architecture: Bot orchestrator (multi-asset coordination), Trading core (strategy engine, risk manager, trade executor, data fetcher), API layer (JWT auth, WebSocket broadcasting), Storage layer (Redis cache with Supabase persistence). WebSocket integration with Deriv API for real-time trade execution. Multi-tenant design with isolated bot instances per user using ContextVar state management.

Challenges we ran into

Deriv API requires dollar amounts for stops, but the strategy generates price levels. Solved with conversion formula: TP Amount = |(TP Price - Entry Spot) / Entry Spot × Stake × Multiplier|. Race conditions in multi-asset scanning solved via sequential evaluation with immediate breaks. WebSocket reliability required exponential backoff reconnection (5 max attempts). Cache invalidation after trades to prevent stale data. Multi-user state isolation without cross-contamination.

Accomplishments that we're proud of

Production-ready multi-tenant SaaS architecture deployable on Render and Railway. Adaptive risk engine that mathematically optimizes stop distances as profit grows. Successfully isolated 8-asset simultaneous scanning with zero overexposure risk. Real-time WebSocket broadcasting with per-user event filtering. Graceful degradation when Redis fails.

What we learned

Exit strategy determines profitability more than entry signals. Multi-tenancy requires rigorous state isolation patterns. Real-time systems expose edge cases backtesting never reveals. Configuration-driven architecture enables zero-downtime parameter adjustments. WebSocket resilience needs proactive connection validation, not reactive error handling.

What's next for Deriv Multi-Asset Trading Bot

GPT-4 integration for natural language trade explanations. News sentiment analysis as signal filter. Reinforcement learning to auto-optimize trailing stop thresholds. LSTM price forecasting for confluence validation. Expansion to forex and commodities beyond synthetic indices.

Built With

Share this project:

Updates