INNER CODE UNIT · Python
update_options_chains
ldt9/PyOptionTrader · models/futures/short_strangle.py:177
def update_options_chains(self):
'''
Update the options chain to get the latest expiration dates and strikes
:return: None
'''
try:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
print(f"{self.get_timestamp()} Updating Options Chains...")
# Get current options chain
self.chains = self.ib.reqSecDefOptParams(self.underlying.symbol, self.underlying.exchange, self.underlying.secType,
self.underlying.conId)
print(f"{self.get_timestamp()} Options Chains Updated.")
print(self.chains)
except Exception as e:
print(str(e))