strategies/trend_following_ls.py
Trend-Following L/S
Long when the 50-SMA clears the 200-SMA and RSI dips under 30. Short the mirror image: 50 below 200, RSI over 70. Bracket orders protect both sides.
// NYSE + 5 CRYPTO EXCHANGES · IBKR PAPER ACCOUNT · STATUS: LIVE-LIKE
IrieTrade is a fully automated, risk-managed trading bot built from scratch in Python. It trades NYSE equities through Interactive Brokers and crypto pairs across five exchanges, sizes every position by the book, and never once asks how it feels about a trade.
01 / THE MACHINE
No SaaS dashboard, no drag-and-drop bot builder. Every module, the hybrid data pipeline, the signal resolver, the broker layer, the risk manager, is hand-written Python. Dependency injection wires them together so any piece swaps out or gets unit-tested on its own.
Broker interface, with an NSE stub waiting on Nairobi's exchange to ship a public API.BTC/USDT) straight to the exchange via ccxt./setup writes .env and settings.yaml for you and tests each broker connection live, no manual YAML editing required.
fig. 01 · the brain, before the cloud had one
02 / HOW IT THINKS
Every strategy votes on every symbol. The resolver only acts on votes that make sense given the current position, and clears an existing position before it ever opens the opposite side. A Donchian-channel breakout module is next on the list.
strategies/trend_following_ls.py
Long when the 50-SMA clears the 200-SMA and RSI dips under 30. Short the mirror image: 50 below 200, RSI over 70. Bracket orders protect both sides.
strategies/trend_following_long_only.py
Same crossover logic as the L/S version, minus the short side. Built for cash accounts and crypto exchanges that can't borrow to sell.
strategies/mean_revisions.py
Bollinger Bands paired with RSI. Buys the fear when price snaps below the lower band with RSI under 30, sells the euphoria above the upper band with RSI over 70.
strategies/orb.py
Marks the high and low of the first 30 minutes of trade. A volume-confirmed break of either side triggers an entry in that direction.
strategies/vwap_revisions.py
Anchors to the session VWAP and watches ±2 standard-deviation bands. RSI confirms the fade at either extreme before the bot commits.
strategies/resolver logic
Flat: a lone ENTER_LONG or ENTER_SHORT opens the position. Long: EXIT_LONG closes it, ENTER_SHORT closes it first and waits for the next bar. Both signals firing at once cancels out, no trade.
Backtested with a loop-based engine that runs the exact same strategy classes and resolver as the live bot. Any parameter change clears a 5-year backtest before it touches paper capital. See Rulebook §5.
03 / WHERE IT TRADES
Every platform speaks through the same Broker interface. The engine keeps a separate risk manager, position tracker, symbol list and strategy list per broker, so a small crypto account and a large equities account never share a single risk budget.
| Platform | Integration | Bracket orders | Shorting |
|---|---|---|---|
| Interactive Brokers | ib_async | Yes | Margin accounts only |
| Binance | ccxt | No | No |
| OKX | ccxt | No | No |
| Coinbase | ccxt | No | No |
| Kraken | ccxt | No | No |
| KuCoin | ccxt, live-tested | No | No |
| NSE (Nairobi) | Stub, no API yet | Pending | Pending |
On IBKR the bot checks the account type before it ever shorts. Margin account: shorting stays on, subject to a live availability check. Cash account: shorting locks off automatically, no manual flag required.
04 / BUILT-IN RESTRAINT
Every rule below runs automatically, before a single order reaches a broker. Each one can be tuned per broker through risk_by_broker, so a small KuCoin account can carry looser limits than the account holding real equities.
Short-availability checks confirm shares actually exist to borrow. On IBKR the bot detects margin versus cash accounts and blocks shorting on cash accounts outright. An earnings blackout filter stops new entries near a print.
ATR-based stops sit on every position and trail as a trade works. A drawdown past 15% halves size automatically. Past 20%, the bot halts trading outright for a re-evaluation.
Half-Kelly position sizing off recent win/loss history, capped at 5% of equity per trade. Gross exposure caps at 1.5x equity, net exposure caps the long/short imbalance, and no single name exceeds 20% of the book.
05 / THE READOUT
The FastAPI dashboard aggregates every broker into one portfolio view: NAV, daily and unrealised P&L, a 30-day rolling Sharpe, an equity curve, open positions, and the last ten closed trades. It refreshes every 60 seconds on its own.
It also splits trading P&L from interest earned on idle cash, a distinction the audit below made non-negotiable.
/api/signals, /api/positions and /api/performance for anything you want to build on top later./setup: pick brokers, paste credentials, test the connection, save. No YAML by hand.06 / THE RULEBOOK
Seven standing rules keep the strategy honest before it ever sees live capital. They run on a calendar, not a mood.
fig. 02 · RULES.md, printed and dog-eared
07 / THE AUDIT
A $1M IBKR paper account has run since December 2025. The numbers below are what the reviews actually found, not the highlight reel.
max_position_pct coded and enforced going forward.NEXT UP
08 / SIGNAL RECEIVED
Every fill, every error, every risk-limit trip pushes out in real time across three independent channels. A dead webhook never means a blind spot.
01
Colour-coded embeds: green for a buy, red for a sell, plus dedicated error alerts through a webhook.
02
Plain-text trade alerts through a bot token and chat ID, for the moments Discord isn't in reach.
03
Branded HTML mail through Brevo's API as the primary transport. Gmail SMTP fills in if Brevo ever fails.
READ BEFORE YOU TRADE
IrieTrade is for learning, not financial advice. Past performance never guarantees future results, paper P&L isn't live P&L, and the rulebook exists precisely because the strategy hasn't earned real capital yet. See Rule 1 and Rule 7. Test thoroughly. Trade at your own risk.
fig. 03 · still faster than most support lines
09 / GET IN TOUCH
The bot doesn't take feature requests, but its builder does. Every issue and idea helps this project grow.