Skip to content

M001/S02/T04: Build async price scanner for limit/stop order evaluation #355

Description

@Alinsaba-99

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

  • python3 -c "from src.paper.scanner import PaperOrderScanner; print('scanner module loads ok')"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions