Handle "adjusted contract" chains per root
parent
fb876f3770
commit
dc581d0bdc
|
@ -315,16 +315,27 @@ class Client:
|
||||||
contracts.items(),
|
contracts.items(),
|
||||||
key=lambda item: item[0].expiry
|
key=lambda item: item[0].expiry
|
||||||
):
|
):
|
||||||
|
for chain in byroot['chainPerRoot']:
|
||||||
|
optroot = chain['optionRoot']
|
||||||
|
suffix = ''
|
||||||
|
|
||||||
|
# handle QTs "adjusted contracts" (aka adjusted for
|
||||||
|
# the underlying in some way; usually has a '(1)' in
|
||||||
|
# the expiry key in their UI)
|
||||||
|
adjusted_contracts = optroot != key.symbol
|
||||||
|
if adjusted_contracts:
|
||||||
|
suffix = '(' + optroot[len(key.symbol):] + ')'
|
||||||
|
|
||||||
by_key[
|
by_key[
|
||||||
ContractsKey(
|
ContractsKey(
|
||||||
key.symbol,
|
key.symbol + suffix,
|
||||||
key.id,
|
key.id,
|
||||||
# converting back - maybe just do this initially?
|
# converting back - maybe just do this initially?
|
||||||
key.expiry.isoformat(timespec='microseconds'),
|
key.expiry.isoformat(timespec='microseconds'),
|
||||||
)
|
)
|
||||||
] = {
|
] = {
|
||||||
item['strikePrice']: item for item in
|
item['strikePrice']: item for item in
|
||||||
byroot['chainPerRoot'][0]['chainPerStrikePrice']
|
chain['chainPerStrikePrice']
|
||||||
}
|
}
|
||||||
|
|
||||||
# fill out contract id to strike expiry map
|
# fill out contract id to strike expiry map
|
||||||
|
|
Loading…
Reference in New Issue