Skip to content

fix: streaming subscription enum type mismatch + correct field maps#5

Merged
rdemeritt merged 1 commit into
mainfrom
fix/streaming-field-enums
Jun 16, 2026
Merged

fix: streaming subscription enum type mismatch + correct field maps#5
rdemeritt merged 1 commit into
mainfrom
fix/streaming-field-enums

Conversation

@rdemeritt

Copy link
Copy Markdown
Member

Root cause

_send_subscription built fields from EQUITY_FIELD_MAP.keys() — plain ints. schwab-py's StreamClient requires LevelOneEquityFields / LevelOneOptionFields enum members and raises on type mismatch:

expected type "LevelOneEquityFields", got type "int". (initialize with enforce_enums=False to disable this checking)

Fix

  • Convert field keys to enum members at subscription time:
    fields = [sc.LevelOneEquityFields(k) for k in EQUITY_FIELD_MAP]
    fields = [sc.LevelOneOptionFields(k) for k in OPTIONS_FIELD_MAP]
  • Corrected both field maps: previous names were wrong (e.g. key 10 was labeled tradeTime but is HIGH_PRICE; keys 19-23 on options were mislabeled as greeks but are metadata fields)
  • Updated field selection to a sensible set for a quote proxy: bid/ask/last/size, OHLC, volume, mark, net change, timestamps; options add greeks (delta/gamma/theta/vega/rho), days-to-expiry, underlying price

Validated

All 44 field integer keys confirmed against LevelOneEquityFields and LevelOneOptionFields enums in schwab-py 1.5.1. 19/19 tests pass.

@rdemeritt rdemeritt merged commit e3b1052 into main Jun 16, 2026
4 checks passed
@rdemeritt rdemeritt deleted the fix/streaming-field-enums branch June 16, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant