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