Number of parameters

Course Name: Systematic Options Trading, Section No: 12, Unit No: 6, Unit type: Notebook

function created "get_pop_empirical" in section 11 unit 7 takes 3 parameters but in this section the same funtion is called with 4 inputs? 

 

Hello Bharat Sharma,



You are right. There is a difference between the parameters accepted in the two notebooks. Thanks for pointing it out and we will update the notebook in section 11 unit 7 with the function which can be found in the "options_util_quantra.py" file present in the downloadable zip file of the last section, ie section 30 unit 4. 



The function takes 4 parameters and is as follows:



def get_pop_empirical(futures_data, current_price, days_to_expiry, price_range):

    # Calculate empirical POP

    trading_days_to_expiry = round(days_to_expiry * (5 / 7))

    futures_data['percent_change_in_price'] = futures_data.futures_close.pct_change(trading_days_to_expiry)

    forecasted_prices = (1 + futures_data['percent_change_in_price']) * current_price

    histogram = np.histogram(forecasted_prices.dropna(), bins=30)

    hist_dist = rv_histogram(histogram)



    payoff = pd.DataFrame(index=price_range)

    payoff['probability_empirical'] = hist_dist.cdf(x=price_range)

    payoff['probability_empirical'] = payoff['probability_empirical'].diff()

    return payoff