INNER CODE UNIT · Python

get_chain_iv

ldt9/PyOptionTrader · models/futures/short_strangle.py:290

    def get_chain_iv(self, nearestDTE):

        '''
        Get the IV of the option with the given strike
        :param nearestDTE: expiration date of the chain
        '''

        try:
            # Create an ATM call contract to get the current IV of the chain
            atmCall = Option(self.underlying.symbol, nearestDTE, int(np.ceil(self.df.close.iloc[-1] / 5)) * 5, 'C',
                             'SMART')
            self.ib.qualifyContracts(atmCall)
            atmCallPrices = self.ib.reqHistoricalData(atmCall,
                                                      endDateTime='',
                                                      durationStr='60 s',
                                                      barSizeSetting='1 secs',
                                                      whatToShow='MIDPOINT',
                                                      useRTH=False,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…