Investor and Software Engineer but very new to quant finance here...
I have the below code (which I'm sure will be helpful for some) and have some questions regarding the function parameters!
- Is RF Rate your interest rate on treasuries? Basically your no risk competing return?
- How much will dividends influence the greeks? It is additional data I might not have access to?
- What are the time steps? I don't understand the wording...
def create_american_process(valuation_date, rf_rate, spot, ivol):
#set calendar & day count
calendar = ql.UnitedStates()
day_counter = ql.ActualActual()
#set evaluation date
ql.Settings.instance().evaluationDate = valuation_date
#set rate & vol curves
rate_ts = ql.FlatForward(valuation_date, ql.QuoteHandle(rf_rate),
day_counter)
vol_ts = ql.BlackConstantVol(valuation_date, calendar,
ql.QuoteHandle(ivol), day_counter)
#create process
process = ql.BlackScholesProcess(ql.QuoteHandle(spot),
ql.YieldTermStructureHandle(rate_ts),
ql.BlackVolTermStructureHandle(vol_ts))
return process
def american_px_greeks(valuation_date, expiry, call_or_put, strike, div_dates,
div_values, time_steps, process):
#create instance as call or put
if call_or_put.lower() == 'call':
option_type = ql.Option.Call
elif call_or_put.lower() == 'put':
option_type = ql.Option.Put
else:
raise ValueError("The call_or_put value must be call or put.")
#set exercise and payoff
exercise = ql.AmericanExercise(valuation_date, expiry)
payoff = ql.PlainVanillaPayoff(option_type, strike)
#create option instance
option = ql.DividendVanillaOption(payoff, exercise, div_dates, div_values)
#set mesh size for finite difference engine
grid_points = time_steps - 1
#create engine
engine = ql.FDDividendAmericanEngine(process, time_steps, grid_points)
option.setPricingEngine(engine)
return option