def run_takeout_by_expiry(): event = TakeoutEvent('NBIX', 1) option_type = 'Call' option_type_2 = 'Put' strike = 1.0 expiries = [ dt.date(2018, 4, 20), dt.date(2018, 7, 20), dt.date(2018, 10, 20), dt.date(2019, 1, 20), dt.date(2019, 4, 20) ] # Preliminary Print Statements print("Ann. Takeout Prob: {:.1f}%, Premium: {:.1f}%".format( event.takeout_prob * 100, event.takeout_premium * 100)) for expiry in expiries: option = Option(option_type, strike, expiry) option2 = Option(option_type_2, strike, expiry) distribution = event.get_distribution(expiry) price = OptionPrice(distribution, option) price2 = OptionPrice(distribution, option2) straddle = price + price2 print( "T.O. by {:%m/%d/%Y}: {:.1f}%".format( expiry, distribution.distribution_df.loc["Takeout", "Prob"] * 100), "\n" * 0) print("Mean Move: {:.1f}%".format(distribution.mean_move * 100)) print("Straddle: {:.1f}%".format(straddle * 100), "\n" * 1)
def get_option_prices(mc_distribution): strikes = np.arange(.5, 1.55, .05) option_prices = [] implied_vols = [] for strike in strikes: if strike >= 1.0: option_type = 'Call' else: option_type = 'Put' option = Option(option_type, strike, expiry) option_price = OptionPriceMC(option, mc_distribution) implied_vol = get_implied_volatility(option, 1.0, option_price) option_prices.append(option_price) implied_vols.append(implied_vol) prices_info = { 'Strikes': strikes, 'Prices': option_prices, 'IVs': implied_vols } prices_df = pd.DataFrame(prices_info).round(3) prices_df.set_index('Strikes', inplace=True) #prices_df.rename_axis(name, inplace=True) return prices_df
def get_option_prices(name, mc_distribution): strikes = np.arange(.5, 1.55, .05) prices = [] for strike in strikes: if strike >= 1.0: option_type = 'Call' else: option_type = 'Put' option = Option(option_type, strike, expiry) prices.append(OptionPriceMC(option, mc_distribution)) prices_info = {'Strikes': strikes, 'Prices': prices} prices_df = pd.DataFrame(prices_info).round(3) prices_df.set_index('Strikes', inplace=True) #prices_df.rename_axis(name, inplace=True) return prices_df