Support `Forex` in the pp packer

fix_forex
Tyler Goodlet 2022-07-12 16:55:58 -04:00
parent 4e5df973a9
commit cef511092d
1 changed files with 21 additions and 11 deletions

View File

@ -36,6 +36,7 @@ import tractor
from ib_insync.contract import (
Contract,
Option,
Forex,
)
from ib_insync.order import (
Trade,
@ -88,9 +89,18 @@ def pack_position(
# TODO: lookup fqsn even for derivs.
symbol = con.symbol.lower()
# TODO: probably write a mofo exchange mapper routine since ib
# can't get it's shit together like, ever.
# try our best to figure out the exchange / venue
exch = (con.primaryExchange or con.exchange).lower()
if not exch:
if isinstance(con, Forex):
# bc apparently it's not in the contract obj?
exch = 'idealfx'
else:
# for wtv cucked reason some futes don't show their
# exchange (like CL.NYMEX) ...
entry = _adhoc_symbol_map.get(