Back to case studies
Case study · Finance & Investing

An autonomous trading agent. No human in the loop.

300+ trades
Executed unattended

At a glance

Industry
Finance & Investing
Build type
Agent
Tech stack
Pythondiscord.pyAlpaca APIRailwaySQLite
What it does
  • Watches a designated Discord channel for one signal author
  • Parses BOUGHT and SOLD signals, including multi-line batches
  • Sizes positions against a strict risk policy (5% / 8–10% caps)
  • Applies special sizing rules for "lotto"-style follow-on trades
  • Reconciles edited Discord messages without double-trading
  • Submits market orders through Alpaca; tracks P&L and exposure in real time
The work

A retail options trader was trading from a paid Discord alerts channel — every signal came in as a text line like "BOUGHT SPY 4/11 520C @ 1.50" and had to be acted on fast, before the underlying moved and the contract repriced. That meant sitting at the screen during market hours, copy-pasting strikes and expiries into a broker, and hoping the manual entry didn’t slip. The trader was the bottleneck — slow when distracted, gone at lunch, and prone to break the sizing rules under excitement. Missed alerts were lost edge. Wrong sizing was lost discipline.

We built an autonomous trading agent that runs the full perceive–decide–act loop without the trader. It listens to one specific author in one Discord channel, parses every BOUGHT and SOLD line the moment it lands, applies the trader’s risk policy (max 5% of equity per trade, 8–10% portfolio exposure cap, special sizing for lotto-style follow-on trades) — including the decision to skip a trade when exposure is maxed or the policy can’t justify it — then submits a market order through Alpaca. Edited Discord messages get reconciled in real time without double-trading. Partial sells ("1/4 position", "ALL OUT") translate cleanly to contract counts. The trader is no longer in the loop; the agent runs it.

Over 300 trades have now run through the agent end-to-end — every alert parsed, sized against policy, and submitted in seconds, with zero manual entry. The trader is off the screen. The discipline is enforced in code, not willpower. And no signal goes unseen because someone was on a call.

Engineering challenges
01

Handling edited Discord messages without double-trading

Each successfully executed signal is keyed by action, ticker, strike, and option type and stored per message ID. When a message gets edited, only signals that haven’t already succeeded re-execute — corrections flow through, dupes get blocked.

02

Risk decisions ready the millisecond a signal lands

A background task refreshes account equity, buying power, and current exposure every 60 seconds. When a signal arrives, the sizing math runs against pre-warmed state instead of waiting on a slow API round-trip.

03

Sizing "lotto" follow-on trades against prior profits

Realized P&L is tracked per ticker as positions close. When a "lotto" or "roll up" signal arrives, the agent looks up the most recent closed trade’s profit for that ticker and caps the new position at 35% of it — never more than 5% of equity.

Ready to build?

15 minutes. No pitch deck. Just a conversation about what you’re trying to solve.

Book an intro
Or send a note

Or email ops@dualitylabs.ai