ib: handle commodity-contract trade records
parent
2b8cd031e8
commit
e9517cdb02
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue