Building a Syariah-Compliant Crypto Swing Bot with an LLM Brain
Spot only. No leverage. 3:1 minimum reward-to-risk. A rules-based swing strategy across BTC, ETH and BNB — with an LLM making the final entry call. Here's what 9 years of backtests taught us and what the live bot looks like.

Building a Syariah-Compliant Crypto Swing Bot with an LLM Brain
Date: 2026-04-24 Series: AI & Automation Difficulty: Intermediate Read time: 8 minutes
The Starting Point
I've been watching crypto markets for a while. Not with the intention of day trading — that's a full-time job and statistically, most people lose. What I wanted was a swing strategy: hold for days to weeks, catch meaningful moves, stay out when conditions don't align.
The harder constraint was Syariah compliance. No leverage. No futures. No derivatives. Spot only. This rules out a lot of "popular" crypto strategies that depend on leveraged positions or perpetual contracts. What remained was actually a cleaner set of rules — buy the asset outright, define your risk before entry, take profit when the math works out.
The question was: can a rules-based algorithm do this consistently, and can an LLM make it smarter at the entry point?
The Objective
Three goals shaped everything:
Capital preservation first. The bot should never enter a trade it can't define the risk on. No "I think it'll go up" trades — every entry needs a stop loss and a take profit, with at minimum a 3:1 reward-to-risk ratio. If those numbers don't work out, the bot skips.
Asymmetric entries only. The strategy targets daily swing setups — ADX above 25 (trending market), EMA200 slope positive (bullish structure). Only enter when the regime is confirmed bull. Sit flat otherwise.
Syariah compliant. Spot only. The bot never touches futures, leverage, or any derivative product.
Why an LLM?
The rule-based system handles the hard gates — regime filter, stop placement, R:R minimum. But the LLM adds judgment at the margin. Given the same technical picture, should we enter an asset that's sitting 2% below its 52-week high, or skip and wait for a pullback? Should we hold through a Fear & Greed reading of 12 (Extreme Fear) when the thesis is still intact?
These aren't questions with clear rule-based answers. They're contextual. The LLM receives the full market snapshot — EMAs, RSI, MACD, ADX, Bollinger Band position, volume ratio — and makes the call. It also gets the Fear & Greed Index as context. Not as a hard gate, but as information. Market sentiment flavors the rationale, not the rules.
The architecture ended up as two layers: rules first (hard filters that can't be overridden), LLM second (judgment within the space the rules allow).
The 9-Year Backtest Question
Before deploying anything live, we needed to know if the strategy actually worked historically. We ran a 9-year backtest across five coins: BTC, ETH, BNB, BCH, and LTC.
The results were revealing. BTC stood out — 71 trades over 9 years, 50.7% win rate, profit factor of 3.0, and a total return of +357%. The strategy is genuinely BTC-shaped. The win rate sounds modest until you understand the 3:1 R:R rule — you can be wrong 50% of the time and still make money because your winners are three times larger than your losers.
ETH and BNB were profitable. BCH was a clear loser — negative profit factor, excluded from the live universe. LTC sits in a watch-only category for now.
We also tested the LLM layer against the rules-only baseline. The honest finding: the LLM improved performance marginally — around 1 percentage point on win rate, slightly better average trade. Not dramatic. But it also never made things worse, and its rationale logging has real value for understanding why a trade was taken.
One test we ran was whether Fear & Greed gating (blocking entries during extreme fear or extreme greed) improved results. It didn't. In every variant, the gated version underperformed the ungated one. That's why F&G ended up as context-only — the LLM can weigh it, but it can't block an entry by itself.
The Live Setup
The bot runs as a Docker stack: the strategy engine, MongoDB for trade persistence, and a Flask web dashboard. Entry scans fire three times a day (10:00, 18:00, 02:00 UTC). Between scans, position checks run every 5 minutes — if a stop loss is hit, a price move triggers re-evaluation, or the holding period expires, the LLM reassesses the position.
The dashboard has two views. The admin view (private, Basic Auth) shows everything — open positions, stop losses, entry prices, all analytics, full equity curve. The public view is exactly what it sounds like: no auth, no sensitive data, just aggregate performance stats and charts.
The public view shows equity progression, win rate, profit factor, monthly P&L bars, a win/loss donut chart, per-coin cumulative P&L lines, and a live Fear & Greed gauge pulled from the alternative.me API. Anyone can see how the bot is performing without seeing position details.
What We're Watching
The bot is live on Binance testnet now. Starting capital is $1,000, with $200 maximum per position — conservative sizing while we validate real-world behavior matches the backtest.
The expansion plan is milestone-based: at $1,050 equity, position size moves to $225. At $1,100, to $250. The idea is the bot earns larger allocation through consistent performance rather than starting at full size.
The next entry scan happens at 18:00 MYT. If BTC, ETH, or BNB shows a confirmed bull regime with a valid setup, the bot will ask the LLM to evaluate it. If the LLM says ENTER, the trade goes live. If it says SKIP, the rationale gets logged and we move on.
The Honest Part
A 9-year backtest with good numbers doesn't guarantee future results. Markets change. The strategy is BTC-centric — if BTC enters a prolonged bear regime, the bot will mostly sit flat. That's by design (the regime filter exists for this reason), but it means real-money performance over a 6-month window will look very different from a 9-year average.
What gives me confidence is the structure of the strategy — not the numbers. Capital preservation first. Defined risk on every trade. Minimum 3:1 R:R. Spot only. These aren't arbitrary choices; they're the constraints that keep the strategy from blowing up even when the win rate dips.
The public dashboard is at crypto-trading-bot.amirmuz.com. No login needed. Come back in a few weeks and the charts will have actual data in them.