Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRS Delta #76

Open
rajflume opened this issue Aug 20, 2022 · 1 comment
Open

IRS Delta #76

rajflume opened this issue Aug 20, 2022 · 1 comment

Comments

@rajflume
Copy link
Contributor

rajflume commented Aug 20, 2022

In
https://github.com/google/tf-quant-finance/tree/master/tf_quant_finance/experimental/pricing_platform/framework/rate_instruments/interest_rate_swap/interest_rate_swap_impl.py

under def ir_delta it says
raise NotImplementedError("Coming soon.")

In ir_delta_parallel_leg, I see that:
if shock_size is None:
bump = tf.constant(0, dtype=self._dtype,
name="bump")
return tff_math.fwd_gradient(price_fn, bump)

So when no shocks are supplied - its just fwd_gradient. Isn't that the AAD equiv of the bump and reval change in PV?

But when a shock size is supplied, you bump the base curve (as a parallel bump) and then:
price_no_bump = leg.price(processed_market_data)
price_with_bump = price_fn(shock_size)
delta = (price_with_bump - price_no_bump) / shock_size
return delta

So in effect, ir_delta_parallel has the potential to supply both delta's? (AAD equiv and parallel shocked

@cyrilchim
Copy link
Contributor

Hi Raj,

You can use tff.math.gradient to compute deltas. Note these are then aggregated for each instrument. If you want delta for each instrument, you should use tff.math.jacobian. I have extended the example colab to demonstrate the point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants