T04: Build async price scanner for limit/stop order evaluation
Why: Limit and stop orders need continuous price monitoring to trigger fills. Do: Create src/paper/scanner.py with PaperOrderScanner asyncio class. Background polling task that scans all portfolios with open/partially_filled orders, fetches current prices for their symbols via pricing module, and calls evaluate_orders() to trigger fills when conditions met. Poll interval configurable via PAPER_SCANNER_INTERVAL env var (default 5s). Integrated into API server via app.on_event('startup') and app.on_event('shutdown'), following existing _run_startup_preflight pattern. Thread-safe start/stop via asyncio event. Logs poll activity at DEBUG level. Handles price fetch failures gracefully (log and continue, don't crash loop). Done-when: Scanner class imports cleanly; startup/shutdown integration in api_server.py verified by syntax check.
Files
agent/src/paper/scanner.py
Verification
T04: Build async price scanner for limit/stop order evaluation
Why: Limit and stop orders need continuous price monitoring to trigger fills. Do: Create src/paper/scanner.py with PaperOrderScanner asyncio class. Background polling task that scans all portfolios with open/partially_filled orders, fetches current prices for their symbols via pricing module, and calls evaluate_orders() to trigger fills when conditions met. Poll interval configurable via PAPER_SCANNER_INTERVAL env var (default 5s). Integrated into API server via app.on_event('startup') and app.on_event('shutdown'), following existing _run_startup_preflight pattern. Thread-safe start/stop via asyncio event. Logs poll activity at DEBUG level. Handles price fetch failures gracefully (log and continue, don't crash loop). Done-when: Scanner class imports cleanly; startup/shutdown integration in api_server.py verified by syntax check.
Files
agent/src/paper/scanner.pyVerification