google / tf-quant-finance

High-performance TensorFlow library for quantitative finance.
Apache License 2.0
4.55k stars 576 forks source link

Approximate European option price under SABR model #8

Open cyrilchim opened 5 years ago

cyrilchim commented 5 years ago

SABR model has accurate density approximations (see, e.g., here). It is of interest to use the approximations to estimate European option prices.

The module implementing this method should live under tf_quant_finance/volatility/sabr_approximation.py. It should support both European puts and calls approximations. Tests should be in sabr_approximation_test.py in the same folder.

joybh98 commented 5 years ago

Can I work on this issue?

cyrilchim commented 5 years ago

Hi Joy!

Thanks for your interest! I've assigned the issue to you. Please follow Google Python and TensorFlow Probability Style Guides. Will update with the internal one once it is published.

In case you are new to TensorFlow, we have create a training you might find useful

As a guidance, please familiarize yourself with option_price and binary_price implementations so that it is easier for you to get started.

Please reach out if you have any issues.

joybh98 commented 5 years ago

Sure, will do.

saxena-ashish-g commented 4 years ago

@joybh98

Hi Joy, Are you still working on this issue? If you aren't could you please let us know?

-Ashish

joybh98 commented 4 years ago

@saxena-ashish-g I'm not working on this issue. Whoever wants to take this please go ahead.

Rish001 commented 4 years ago

@cyrilchim I didnt come across any folder named volatility under tf_quant_finance. Can you please point me to the file?

cyrilchim commented 4 years ago

@Rish001 It has been refactored. This has to go to models/sabr/approximations/european_option.py (similarly to heston structure)

Rish001 commented 4 years ago

Do you want this approximation of SABR model to be implemented?

image

cyrilchim commented 4 years ago

Yes, Rishav, that is the approximation. One could use it for calibration purposes as described in the paper

Rish001 commented 4 years ago

What are the possible test cases that my implementation needs to be tested against?

cyrilchim commented 4 years ago

Hi Rishav,

You can find different estimated European option prices under the SABR model here http://ta.twi.tudelft.nl/mf/users/oosterle/oosterlee/SABRMC.pdf. Your approximation should lead to similar results. Please let me know if you have any further questions. I am happy to help you debug the code if you get stuck.

Best, Cyril

On Thu, Jul 30, 2020 at 2:19 PM RISHAV DUTTA notifications@github.com wrote:

What are the possible test cases that my implementation needs to be tested against?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/tf-quant-finance/issues/8#issuecomment-666359382, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMX3DXUGCQ4CPDDD2GENZTR6FXMZANCNFSM4IVSNTLA .

Rish001 commented 4 years ago

How are these integrations working? are these integrations nested in one inside the other? image It would help me if you can give me a clue how this integral would look like for tenor T2 and beyond. And, from where can I obtain the value of B(t,T_N)? And, while numerically evaluating the integral how should I set up the grid? the domain of integration is (0,infinity)^2 source : Wu

Also, in the same paper, data has been collected in the following manner:

image and model has been calibrated in the following manner:

image

summary statistics of data:

image

and that of residuals errors of model calibration:

image

my question is, for the purpose of calibration, are volatility values of two option tenors say 3M(10.81,10.22,...) and 6M(10.99,10.32...) are being considered? if so, then what are the option tenors T1 and T2 that are mentioned in residual error summary?

cyrilchim commented 4 years ago

@Rish001 The approximation p(t, ... ) is the forward transition density of the SABR process. Computing option prices could be done by creating a uniform grid of points in (F, A) space and computing the average in the formula (2.6) from the original paper. B is a zero-coupon bond price which is a standard notion. In case of a constant interest rate r it is a discount factor exp(-r * (T - t)). (see, e.g., here)

I think the best way to get started is to implement the approximation first. It seems that the original paper is self-contained in terms of notations.

By the time this is implemented, we will have the SABR model in the module and you will be able to use Monte Carlo method to get option prices and get your implementation tested. Does this sound good?

Rish001 commented 4 years ago

As the mentioned integral is unbounded, I think Monte Carlo integration is to be applied. Do you think there is any other way to compute the integral?

Rish001 commented 4 years ago

@cyrilchim I have built a minimal viable code for determining option price for option tenor T1. But i am encountering overflow error which I am unable to remove. I would really appreciate it if you can provide me some helpful direction. image Please find the link to code in google colab

cyrilchim commented 4 years ago

@Rish001 Could you please give me access to the colab? As for the integration boundaries, make them function arguments and give them some sensible values for the tests. We will figure out appropriate default values later (e.g., based on the analytical approximations to implied vol)

Rish001 commented 4 years ago

@cyrilchim I have given the access. Please check it out

cyrilchim commented 4 years ago

@Rish001 You need to write unit tests for the functions. There is clearly a bug somewhere as it seems your values overflow. At this point this is not a TF problem but this is an issue with the numpy code you have written. Try rerunning monte carlo with fewer iterations and maybe use pdb tool to debug the code (see colab usage here)

Rish001 commented 4 years ago

Just to leave you an update. I have mostly finished debugging and will be submitting shortly

Rish001 commented 3 years ago

@cyrilchim could you give me a set of test cases to test my implementation against? I need a number of combinations of alpha, beta,rho, nu,forwards,strikes and time to maturity and corresponding implied volatility values so that I can test my SABR implied vol calculation

cyrilchim commented 3 years ago

Hi Rishav,

We do not have explicit tests but you should be able to use current SABR model to sample trajectories and estimate European option price (put or call). Your approximation should give similar results. For parameters use similar values to what we have in tests