domokane / FinancePy

A Python Finance Library that focuses on the pricing and risk-management of Financial Derivatives, including fixed-income, equity, FX and credit derivatives.
GNU General Public License v3.0
2.16k stars 322 forks source link

argument type issue - FXVanillaOption with SABR model #178

Closed Mattyuan98 closed 1 year ago

Mattyuan98 commented 1 year ago

Hello Professor,

I found some slight issues when I tried to use SABR volatility in the valuation of FX vanilla option. After investigation, the input argument type in SABR model in the fx_vanilla_option scipt seems wrong:

fx_vanilla_option.py: ... 300 elif type(model) == SABR: 301 volatility = vol_function_sabr(model.alpha, 302 model.beta, 303 model.rho, 304 model.nu, 305 F0T, K, tdel) ...

vol_function_sabr(params, f, k, t) actually takes only 4 arguments and the first params is supposed to be an array while we see 7 arguments in the scipt above. Also, the attributes of model should be 'model._alpha' i/o 'model.alpha' according to what I see from the SABR module.

I changed the script into below and works on my side:

elif type(model) == SABR: sabr_params = np.array([model._alpha,model._beta,model._rho,model._nu]) volatility = vol_function_sabr(sabr_params,F0T, K, tdel)

Could you please kindly confirm if such issue exists?

Thanks and regards, Puen YUAN

domokane commented 1 year ago

Thanks. I will look at this later today or at the weekend. D

domokane commented 1 year ago

Hi - I fixed it - it was wrong as you said. I will push a new version over the weekend. Thanks. If you use it can you add a test case to TestFinFXVanillaOption.py under golden. That would be very helpful. D

Mattyuan98 commented 1 year ago

Thank you professor. I will take time to look at the script and add a test case afterwards.

Best, Puen