fix(snaptrade): support option contracts and prioritize option_symbol

Merged
NA
2mo ago
+1311-12

Problem

When syncing investment activities from SnapTrade, option trades (such as from Robinhood or Fidelity) were either skipped or misidentified as common stock because ActivitiesProcessor only inspected the symbol payload. In SnapTrade's API, option contracts place their OCC ticker, strike price, and expiration date inside a distinct option_symbol object while leaving symbol populated with the underlying equity or nil.

Solution

  • Option Symbol Prioritization: Prioritized option_symbol over symbol in ActivitiesProcessor trade and cash resolution to identify option contract trades and tickers.
  • Contract Name Formatting: Added option contract name formatting in SnaptradeAccount::DataHelpers (e.g. TQQQ $51 CALL (2026-02-20)) while falling back to underlying exchange and currency metadata.
  • Ticker Normalization: Preserved raw tickers without titleize mutation when descriptions are absent or generic.

Testing Done

  • Added unit tests covering real-world option brokerage trades imported into sure by snaptrade with OCC option ticker resolution and descriptive naming.
  • Added unit tests verifying in-place trade updates and Transaction-to-Trade reclassification during resync.

Summary by CodeRabbit

  • Bug Fixes
    • Improved option trade processing so contract tickers and details are retained when they differ from the underlying security.
    • Improved option trade amount and missing-price calculations using the appropriate contract multiplier, including for mini options.
    • Improved option security names to include available contract details, while preserving tickers when descriptions are generic or incomplete.
    • Improved cash activity descriptions and exchange and country information when details are available from the underlying security.