|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
Adding new functions to blackcalculatorHi everyone. I'm new to this list. I'm thinking about adding new functions to the blackcalculator, which are in particular needed in the FX area. In particular, I'd like to add: - premium adjusted black scholes deltas (spot and forward) - functions, which return the strike for a given black scholes delta or ATM quotation This would be a relatively small contribution and a small enough project to get me started with contributing to QuantLib and learn how to contribute code etc. Would that be useful? Best regards, Dima ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorHi Dimitri
> I'm new to this list. I'm thinking about adding new functions > to the blackcalculator, which are in particular needed in the > FX area. In particular, I'd like to add: > > - premium adjusted black scholes deltas (spot and forward) > - functions, which return the strike for a given black scholes delta or ATM > quotation this would be very much appreciated! I've been thinking about tackling the last issue it's long time now, but never had the occasion. BTW I've noticed that an algorithm is provided in the last version of Haug Fomulas book, anyway i don't know if it is the most efficient algorithm available As for premium adjusted black scholes deltas I'm not familiar with FX, but just go ahead and document the features. And while there, anyone willing to provide Vanna-Volga interpolation? ciao -- Nando ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
|
|
|
Re: Adding new functions to blackcalculatorOk, thanks a lot for your replies! After thinking about it I'd suggest
to code the delta calculations in a new class called BlackDeltaCalculator with a similar constructor as the BlackCalculator class. This might look like overkill (an own class for Delta calculation) on first sight, but my reasons are as follows: - we'll have to deal with 4 deltas, which could be conveniently coded in an enumeration which could be passed to the constructor. - we'll need 4 different functions to return a strike for a given delta. 2 of them will include a zero root search algorithm (premium adjusted ones). This could be all handled by one function strike(). - We will need at least two functions, which return the strike for an ATM convention (e.g. atm forward or atm delta neutral straddle). Delta neutral straddle strike depends again on the 4 delta conventions. So, to summarize: if we would try to build that in the current BlackCalculator class, this would mess things up a lot, since many delta specific functions would be needed, which are mostly used in FX. I'm very open to other suggestions. What do you think? Regards, Dima 2008/11/13 Ferdinando Ametrano <nando@...> On Thu, Nov 13, 2008 at 12:42 PM, Dima <dimathematician@...> wrote: ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorOn Thu, Nov 13, 2008 at 8:33 PM, Dima <dimathematician@...> wrote:
> After thinking about it I'd suggest > to code the delta calculations in a new class called BlackDeltaCalculator > with a similar constructor as the BlackCalculator class. This might look > like > overkill (an own class for Delta calculation) on first sight, but my reasons > are > as follows: [...] Not sure I agree, anyway it could be the right way to start: code it the way it best suits you, provide unit tests (!!!!!), we quickly add it to the experimental folder, gather feedback, and then maybe later refactor the code ciao -- Nando ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorQuestion:
In the BlackCalculator constructor we have if (stdDev_>=QL_EPSILON) { ... } else{ if (forward>strike_) { cum_d1_ = 1.0; cum_d2_= 1.0;
} else { cum_d1_ = 0.0; cum_d2_= 0.0; } } I wonder if that's 100% right or if I've overlooked something. But if forward==strike,
then we have log(f/K)=0, so, if vol is not zero, we should rather have cum_d1=N (0*5*stdDev_) which would be approximately 0.5 for very small vols. Opinions?
2008/11/14 Ferdinando Ametrano <nando@...>
------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorHi Dima
> I plan to add some new FX machinery to QuantLib. if applicable please consider adding generic formulas to ql/pricingengines/blackformula.hpp > In the BlackCalculator constructor we have > if (stdDev_>=QL_EPSILON) { > ... > } > else{ > if (forward>strike_) { > cum_d1_ = 1.0; > cum_d2_= 1.0; > } else { > cum_d1_ = 0.0; > cum_d2_= 0.0; > } > } > I wonder if that's 100% right or if I've overlooked something. But if > forward==strike, > then we have log(f/K)=0, > so, if vol is not zero, we should rather have > cum_d1=N (0*5*stdDev_) > which would be approximately 0.5 for very small vols. Opinions? yeah, you're right. It should be patched as below, isn't it? if (stdDev_>=QL_EPSILON) { if (close(strike_, 0.0)) { cum_d1_ = 1.0; cum_d2_ = 1.0; n_d1_ = 0.0; n_d2_ = 0.0; } else { D1_ = std::log(forward/strike_)/stdDev_ + 0.5*stdDev_; D2_ = D1_-stdDev_; CumulativeNormalDistribution f; cum_d1_ = f(D1_); cum_d2_ = f(D2_); n_d1_ = f.derivative(D1_); n_d2_ = f.derivative(D2_); } } else { if (close(forward, strike_)) { cum_d1_ = 0.5; cum_d2_ = 0.5; n_d1_ = M_SQRT_2 * M_1_SQRTPI; n_d2_ = M_SQRT_2 * M_1_SQRTPI; } else if (forward>strike_) { cum_d1_ = 1.0; cum_d2_ = 1.0; n_d1_ = 0.0; n_d2_ = 0.0; } else { cum_d1_ = 0.0; cum_d2_ = 0.0; n_d1_ = 0.0; n_d2_ = 0.0; } } ciao -- Nando ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorNando, I think the modification should be ok for the blackcalculator. I've uploaded
my current working version of the deltacalculator including a testsuite(your recent change not incl.). You can get it here: longvega.com/DeltaEngine.zip Now as you see its not really incorporated into blackcalculator and lets see how we might be able to join the concepts. My reasons were the following: 1) First of all, we have 4 deltas to take care of and even more atm quotes, which are rather FX specific, since we have 2 numeraires. So I have enums, which basically have only FX specific types, don't know if that should go into a general blackcalculator. 2) I needed functions such as Real deltaFromStrike(const Real &strike) const; Real strikeFromDelta(const Real &delta) const; since they will be later called very often in some numerical procedures in the smile setup. Again, its FX specific to quote vols again deltas from which we can extract strikes. And again, the functions return different values for different deltas. It would be a bit incoherent from my point of view to return a strike different from the one given in the constructor, as would be the case for the blackcalc. Here functions are generic, in a blackcalculator I might need to setup 8 new functions? The bigger problem for me was, that the strike in blackcalc is in the payoff, and I need it to change very often. So I've created a parsimonious constructor which doesn't need a strike nor a delta. If you look into strikeFromDelta, you'll see numerical procedures for premium adjusted stuff, so I can't really make use of cached data anyways and it doesn't have to do a lot with the standard black formulas anymore. Btw: I'd appreciate a function which returns d1 and d2 in blackcalc, which I need for other functions I'm working on as well. If that would be possible, I'd setup a blackcalc in my class and the whole class would be basically based on the blackcalc. I'm open to discussion. Whats your oppinion? Thanks 2009/4/20 Ferdinando Ametrano <nando@...> Hi Dima ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorWhile I'm still waiting for feedback, I continue coding and have VannaVolga and
Malz ready, testing included. Can I ask for a simple feature which I need in these implementations? I'd need smilesection.hpp to return the reference date. Is this possible? Thanks 2009/4/21 Dima <dimathematician@...> Nando, I think the modification should be ok for the blackcalculator. I've uploaded ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorOn Mon, Apr 27, 2009 at 11:03 AM, Dima <dimathematician@...> wrote:
> While I'm still waiting for feedback I've just committed your fix for the (stdDev<QL_EPSILON, fwd==strike) case > I'd need smilesection.hpp to return the reference date. Is this possible? just done. > I continue coding and have VannaVolga and > Malz ready, testing included. share them as a patch whenever you're comfortable with them ciao -- Nando ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
|
|
Re: Adding new functions to blackcalculatorThanks a lot. Did you have the chance to look at the black calculator that I posted?
Sorry for annoying, but since I'm using it intensively in all of my current classes I'm just afraid that the discussion will start later and I have to go back and change everything in all of the classes :) 2009/4/27 Ferdinando Ametrano <nando@...>
------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ QuantLib-dev mailing list QuantLib-dev@... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
| Free embeddable forum powered by Nabble | Forum Help |