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

Support for Implicitly defined functions #301

Open
rcalxrc08 opened this issue Jun 4, 2022 · 2 comments
Open

Support for Implicitly defined functions #301

rcalxrc08 opened this issue Jun 4, 2022 · 2 comments

Comments

@rcalxrc08
Copy link

First thank you very much for the amazing package.

Second, let me explain the issue:
assume I have a function g returning x such that f(x,p)=0. I would be interested in computing the derivatives of x with respect to p but I am struggling to do that using the current APIs.

For example in case of ForwardDiff.jl (sorry for not perfect comparison) I can just define the rules on how to compute the first derivative and all of the other orders are automatically determined by successfully applying the chain rule (I guess).

Do you think it makes sense to implement an API in order to do this?
I even was looking at this but there is no support for TaylorSeries.jl.

@lbenet
Copy link
Member

lbenet commented Jun 4, 2022

Hi, and thanks for reaching us!

We currently do not have an API implemented to do that. But since the chain rule works, I guess we can do something, at least in some sense related to approximations with polynomials. Do you have a concrete example to begin playing with?

@rcalxrc08
Copy link
Author

In my package called FinancialToolbox there is a function called blsimpv. It is nothing else then the inverse of Black Scholes Formula (called blsprice in the package) with respect to parameter sigma keeping everything else as a constant.
image.

For float numbers I simply invert the function using the Brent method, in order to do that I do the following:
I define a function f(x,S0,K,r,T,d,price)=blsprice(S0,K,r,T,x,d)-price.
Unfortunately blsprice is using erf for AbstractSeries but there is a tweak for the implementation of that inside FinancialToolbox.jl #285.
First I am interested in finding sigma (in the world of floats let's say) st: f(sigma,S0,K,r,T,d,price)=0.0 (it exists unique if parameters are feasible).
Brent method (or bisection, or newton..) will return give me back the value sigma that solves that.

But when it comes to derivatives (superior to first order) everything is more challenging because of this minima relation.
In case of Dual and Hyper Dual I was able to specialize the function in order to return the derivatives as well, but those functions are far from support TaylorSeries.jl as well and they are far from being that general in order to differentiate in an agnostic way with respect to any of those parameters (S0,K,r,T,d,price).

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