def computeImpliedVolatilitySpread(self): if self.avaiableIV: mean = weightedAvg(self.data['IV_spread'], self.weights) std = weightedStd(self.data['IV_spread'], self.weights) else: mean = None std = None return namedtuple('OPS', ['mean', 'std'])(**{"mean": mean, "std": std})
alpha=.3)[0]) axs[2].legend(lines, [l.get_label() for l in lines], loc=0) plt.figtext(.9, 0.02, "{} | {}".format(optionChain.getChainDate(), optionChain.getChainExpiration()), ha="right", fontsize=10, bbox={ "facecolor": "orange", "alpha": 0.2, "pad": 8 }) plt.show() summary = { 'Mean': weightedAvg(data['spreadSummary'], data['weights']), 'Std': weightedStd(data['spreadSummary'], data['weights']) } print('Summary: {}'.format(summary)) # ----------------------[EXPORT BLOCK]-------------------------------- path = '../Export/[{}]_({})'.format(ticker.ticker, ticker_info.longName) if not os.path.exists(path): os.makedirs(path) fig.savefig('{}/optionPriceSpread_[{}].png'.format(path, exp)) # ----------------------[EXPORT BLOCK]--------------------------------
alpha=.3)[0]) axs[2].legend(lines, [l.get_label() for l in lines], loc=0) plt.figtext(.9, 0.02, "{} | {}".format(optionChain.getChainDate(), optionChain.getChainExpiration()), ha="right", fontsize=10, bbox={ "facecolor": "orange", "alpha": 0.2, "pad": 8 }) plt.show() summary = { 'Mean': weightedAvg(data['openInterestRatio'], data['weights']), 'Std': weightedStd(data['openInterestRatio'], data['weights']) } print('Summary: {}'.format(summary)) # ----------------------[EXPORT BLOCK]-------------------------------- path = '../Export/[{}]_({})'.format(ticker.ticker, ticker_info.longName) if not os.path.exists(path): os.makedirs(path) fig.savefig('{}/optionPriceSpread_[{}].png'.format(path, exp)) # ----------------------[EXPORT BLOCK]--------------------------------
alpha=.3)[0]) axs[2].legend(lines, [l.get_label() for l in lines], loc=0) plt.figtext(.9, 0.02, "{} | {}".format(optionChain.getChainDate(), optionChain.getChainExpiration()), ha="right", fontsize=10, bbox={ "facecolor": "orange", "alpha": 0.2, "pad": 8 }) plt.show() summary = { 'Mean': weightedAvg(data['IV_spread'], data['weights']), 'Std': weightedStd(data['IV_spread'], data['weights']) } print('Summary: {}'.format(summary)) # ----------------------[EXPORT BLOCK]-------------------------------- path = '../Export/[{}]_({})'.format(ticker.ticker, ticker_info.longName) if not os.path.exists(path): os.makedirs(path) fig.savefig('{}/impliedVolatilitySpread_[{}].png'.format(path, exp)) # ----------------------[EXPORT BLOCK]--------------------------------
def computeOpenInterestRatio(self): mean = weightedAvg(self.data['openInterestRatio'], self.weights) std = weightedStd(self.data['openInterestRatio'], self.weights) return namedtuple('OIR', ['mean', 'std'])(**{"mean": mean, "std": std})
def computeOptionPriceSpread(self): mean = weightedAvg(self.data['spreadSummary'], self.weights) std = weightedStd(self.data['spreadSummary'], self.weights) return namedtuple('OPS', ['mean', 'std'])(**{"mean": mean, "std": std})