# Generating Greeks with American Options

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!

1. Is RF Rate your interest rate on treasuries? Basically your no risk competing return?
2. How much will dividends influence the greeks? It is additional data I might not have access to?
3. 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


• Re Point 3. Option Theory involves Differential Equations, where time flows continuously. For the purpose of solving these on a computer they are often approximated by finite difference equations where time flows in "steps". For ex. there might be 10 points in time between now and expiration where you consider whether an American option should be exercised or not. This is what setting time_steps to 10 means. The more steps the more accurate the solution but also the slower the calculations. HTH. Oct 23 '21 at 12:28
• Risk free is usually not treasury but SOFR (curve) nowadays. Dividends will play a role. I recommend looking at closed form solutions for Greeks of European vanilla black scholes to get and idea how sensitive Greeks are with regards to dividends. Oct 25 '21 at 19:04
• @AKdemy gotcha this is so informative. I had heard about LIBOR but didn't know they moved away to SOFR. I realized that I don't know what the Spot parameter is referencing... it looks like SOFR right now is 0.05 so I would put that as rf_rate but the spot? Oct 30 '21 at 4:13
• This may be helpful. For interest rates, it is customary to use stripped interest rate curves. These used to be Libor 3m based but are now mainly SOFR curves, which are fundamentally built in a similar way. Oct 31 '21 at 5:21