ib: handle commodity-contract trade records

ib_py311_fixes
Tyler Goodlet 2023-08-18 17:29:51 -04:00
parent 2b8cd031e8
commit e9517cdb02
1 changed files with 17 additions and 1 deletions

View File

@ -32,8 +32,9 @@ from typing import (
from bidict import bidict from bidict import bidict
import pendulum import pendulum
from ib_insync.objects import ( from ib_insync import (
Contract, Contract,
Commodity,
Fill, Fill,
Execution, Execution,
CommissionReport, CommissionReport,
@ -237,6 +238,21 @@ def norm_trade(
name=symbol.lower(), name=symbol.lower(),
atype='option', atype='option',
tx_tick=Decimal('1'), tx_tick=Decimal('1'),
# TODO: we should probably always cast to the
# `Contract` instance then dict-serialize that for
# the `.info` field!
# info=asdict(Option()),
)
case 'CMDTY':
from .symbols import _adhoc_symbol_map
con_kwargs, _ = _adhoc_symbol_map[symbol.upper()]
dst = Asset(
name=symbol.lower(),
atype='commodity',
tx_tick=Decimal('1'),
info=asdict(Commodity(**con_kwargs)),
) )
# try to build out piker fqme from record. # try to build out piker fqme from record.