erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.81k stars 753 forks source link

Include class name while serializing NamedTuple #668

Open t1user opened 10 months ago

t1user commented 10 months ago

Before:

[...]
 'fills': [{'contract': {'Future': {'secType': 'FUT',
      'conId': 603558783,
      'symbol': 'YM',
      'lastTradeDateOrContractMonth': '20231215',
      'right': '?',
      'multiplier': '5',
[...]

After:

[...]
  'fills': [{'Fill': {'contract': {'Future': {'secType': 'FUT',
       'conId': 603558783,
       'symbol': 'YM',
       'lastTradeDateOrContractMonth': '20231215',
       'right': '?',
       'multiplier': '5',
       'exchange': 'CBOT',
       'currency': 'USD',
       'localSymbol': 'YM   DEC 23',
       'tradingClass': 'YM'}},
     'execution': {'Execution': {'execId': '0000e1a7.656fc43c.01.01',
       'time': '2023-12-06T09:48:35+00:00',
    [...]

It's much easier to de-serialize if class name is included.