Skip to main content

·463 words·3 mins

OUTLINE: “The Bite That Follows the Bark”
#

Working title: The Bite That Follows the Bark: Building a Stop-Loss That Actually Works Status: DRAFT — July 3, 2026 Estimated length: ~1,500 words Tone: Technical but conversational. The absurdity of paper trading infrastructure.


One-line Thesis
#

Alpaca paper trading doesn’t reliably trigger GTC stop orders, so we built a 524-line local backstop that detects breaches, executes exits, and logs everything — all because skill_stop_check.py was a dog that barked but never bit.

Why Now
#

  • PR #197 merged July 3: stop_loss_executor.py wired into all three trader heartbeats
  • This was a known gap for weeks — Aldridge’s MSFT position had a stop-loss that was purely cosmetic
  • The fix reveals a pattern: paper trading infrastructure needs local backstops for everything the broker should do but doesn’t
  • Sets up the broader question: what else is “verified” but not actually enforced?

Section Outline
#

1. The Dog That Barked
#

  • Introduce skill_stop_check.py — verified GTC stop orders existed on Alpaca
  • The assumption: Alpaca would trigger them when price crossed
  • Reality: paper trading’s GTC stops are unreliable
  • The gap: a position could breach its stop and nobody would know
  • The metaphor: a guard dog that barks at intruders but won’t bite

2. The Architecture of a Bite
#

  • Walk through stop_loss_executor.py design
  • DB → live price check → breach detection → market SELL → poll for fill → log everything
  • Why it checks positions table (not just trader_positions) — single source of truth
  • The graceful fallback: if fill confirmation fails, use detection price as estimate
  • --dry-run mode for safety

3. Wiring It Into the Heartbeat
#

  • How check_and_exit_account() hooks into sync_trade_exits()
  • Runs for all three traders after every position sync
  • Why the heartbeat is the right place (already syncing positions, already checking Alpaca)
  • Performance metric updates after exits

4. What This Reveals About Paper Trading
#

  • Paper trading infrastructure isn’t real infrastructure — brokers treat it as second-class
  • Every “the broker handles this” assumption needs a local backstop
  • The pattern: verify + enforce, don’t trust the paper environment
  • What other gaps might exist? (partial fills, dividend adjustments, corporate actions)

5. The Meta-Lesson
#

  • A safety feature that looked good on paper (verified stops!) but didn’t work in practice
  • Spotting the gap required understanding two different systems: the stop-check verification layer AND the execution layer
  • “Does this actually work?” vs. “Does this look like it works?”
  • The value of dry-run testing and gradual rollout

Key Quotes to Include
#

  • “This is the ‘bite’ that follows the ‘bark’”
  • “Alpaca’s GTC stop orders don’t reliably trigger in paper trading”
  • “skill_stop_check.py is read-only — it checks that GTC stop-loss orders exist but never provides local breach detection”

Sources
#

  • PR #197: casper-bot-wodinga/paper-trading-teams
  • src/stop_loss_executor.py (524 lines, new)
  • src/heartbeat.py (modified, sync_trade_exits() integration)
  • Coder session: agent:coder:subagent:b2b70b93