Adding a payoff function

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding a payoff function

Nicolas Magnette
Hi,
 
I need to add a very special payoff function for an
exotic index option. I simply added it in
Instruments\payoff.hpp, but am unable to compile files
which use it. I always get a undefined reference to
vtable for Quantlib::Mypayoff. I tried to recompile
the whole library with my modified payoffs.hpp, but
this did not help. Does anyone have an idea how I
could make this work?
 
Thanks,
 
Nicolas Magnette


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Xavier.Abulker




Have you changed the quantlib.hpp file to include your payoff.hpp?
Xavier


                                                                                                                                 
                    Nicolas Magnette                                                                                            
                    <[hidden email]>       To:     [hidden email]                          
                    Sent by:                               cc:                                                                  
                    [hidden email]       Subject:     [Quantlib-users] Adding a payoff function                
                    eforge.net                                                                                                  
                                                                                                                                 
                                                                                                                                 
                    19/05/2004 10:19                                                                                            
                    Please respond to nmagnett                                                                                  
                                                                                                                                 
                                                                                                                                 




Hi,

I need to add a very special payoff function for an
exotic index option. I simply added it in
Instruments\payoff.hpp, but am unable to compile files
which use it. I always get a undefined reference to
vtable for Quantlib::Mypayoff. I tried to recompile
the whole library with my modified payoffs.hpp, but
this did not help. Does anyone have an idea how I
could make this work?

Thanks,

Nicolas Magnette


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users





*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La FIMAT et ses filiales declinent toute responsabilite au titre de ce
message s'il a ete altere, deforme ou falsifie.
                                          ********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither FIMATnor any of its subsidiaries or affiliates shall be liable for
the message if altered, changed or falsified.



Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Luigi Ballabio-2
In reply to this post by Nicolas Magnette
On 2004.05.19 10:19, Nicolas Magnette wrote:
> I need to add a very special payoff function for an
> exotic index option. I simply added it in
> Instruments\payoff.hpp, but am unable to compile files
> which use it. I always get a undefined reference to
> vtable for Quantlib::Mypayoff. I tried to recompile
> the whole library with my modified payoffs.hpp, but
> this did not help. Does anyone have an idea how I
> could make this work?

Nicolas,
        can you show the code of the payoff class you added? Of course  
you can hide the actual math if that is proprietary. But I'd like to  
see the signature of the class.

Later,
        Luigi


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Nicolas Magnette
Thanks a lot for your help.

Here is my modified payoff. I had to add a
funstion "eval" as I need the calculation of the
payoff to take more than one argument and this is
impossible with the operator which is standard for all
payoffs.


    class MyPayoff : public StrikedTypePayoff {
    public:
        MyPayoff(Option::Type type,
                         double strike1,
                         double strike2,
                         double strike3,
                         double premium1, double
premium2,
                         double rate1, double rate2,
                         int elapseddays)
        : StrikedTypePayoff(type, strike1),
elapseddays_(elapseddays), strike2_(strike2), \
                                strike3_(strike3),
premium1_(premium1), \
                                premium2_(premium2),
rate1_(rate1), rate2_(rate2) {}
        double operator()(double price) const;
        double eval(double price, Time time_elapsed)
const;
        double strike2() const { return strike2_; };
        double strike3() const { return strike3_; };
        double premium1() const { return premium1_; };
        double premium2() const { return premium2_; };
        double rate1() const { return rate1_; };
  double rate2() const { return rate2_; };
        int elapseddays() const { return
elapseddays_; };
     private:
        double strike2_;
        double strike3_;
        double premium1_;
        double premium2_;
        double rate1_;
        double rate2_;
        int elapseddays_;
    };

    inline double MyPayoff::eval(double price, Time
time_elapsed) const {
        //int time_elapsed = 100;
        switch (type_) {
          case Option::Call:
              return -1.0;
          case Option::Put:
                     ....      
          case Option::Straddle:
              return -1.0;
          default:
            throw Error("Unknown/Illegal option type");
        }
}


Sincerely,

Nicolas

En réponse à Luigi Ballabio
<[hidden email]>:

> On 2004.05.19 10:19, Nicolas Magnette wrote:
> > I need to add a very special payoff function for an
> > exotic index option. I simply added it in
> > Instruments\payoff.hpp, but am unable to compile
files
> > which use it. I always get a undefined reference to
> > vtable for Quantlib::Mypayoff. I tried to recompile
> > the whole library with my modified payoffs.hpp, but
> > this did not help. Does anyone have an idea how I
> > could make this work?
>
> Nicolas,
> can you show the code of the payoff class you
added? Of course  
> you can hide the actual math if that is proprietary.
But I'd like to  
> see the signature of the class.
>
> Later,
> Luigi
>
>
> -----------------------------------------------------
--
> This SF.Net email is sponsored by: SourceForge.net
Broadband
> Sign-up now for SourceForge Broadband and get the
fastest
> 6.0/768 connection for only $19.95/mo for the first
3 months!
> http://ads.osdn.com/?
ad_id=2562&alloc_id=6184&op=click
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-
users
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Luigi Ballabio-2
On 2004.05.19 11:20, Nicolas Magnette wrote:

> Here is my modified payoff. I had to add a
> funstion "eval" as I need the calculation of the
> payoff to take more than one argument and this is
> impossible with the operator which is standard for all
> payoffs.
>
>     class MyPayoff : public StrikedTypePayoff {
>     public:
>         MyPayoff(...)
>         : ...  {}
>         double operator()(double price) const;
>         double eval(double price, Time time_elapsed) const;
>         ...
>      private:
>          ...
>     };
>
>     inline double MyPayoff::eval(double price, Time
> time_elapsed) const {
> ...
> }

Nicolas,
        besides declaring it, did you actually define operator()  
somewhere?

Later,
        Luigi


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Nicolas Magnette
Actually not as I do not have any use for it.

En réponse à Luigi Ballabio
<[hidden email]>:

> On 2004.05.19 11:20, Nicolas Magnette wrote:
> > Here is my modified payoff. I had to add a
> > funstion "eval" as I need the calculation of the
> > payoff to take more than one argument and this is
> > impossible with the operator which is standard for
all
> > payoffs.
> >
> >     class MyPayoff : public StrikedTypePayoff {
> >     public:
> >         MyPayoff(...)
> >         : ...  {}
> >         double operator()(double price) const;
> >         double eval(double price, Time
time_elapsed) const;

> >         ...
> >      private:
> >          ...
> >     };
> >
> >     inline double MyPayoff::eval(double price, Time
> > time_elapsed) const {
> > ...
> > }
>
> Nicolas,
> besides declaring it, did you actually define
operator()
> somewhere?
>
> Later,
> Luigi
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Luigi Ballabio-2
On 2004.05.19 11:57, Nicolas Magnette wrote:
> > besides declaring it, did you actually define operator()
> > somewhere?
>
> Actually not as I do not have any use for it.

Nicolas,
        you don't, but the compiler does :)
Add a trivial body to the method and your problem should disappear.

Later,
        Luigi



Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Nicolas Magnette
Luigi,

You got it right! Thanks a lot.

Sincerely,

Nicolas

En réponse à Luigi Ballabio
<[hidden email]>:

> On 2004.05.19 11:57, Nicolas Magnette wrote:
> > > besides declaring it, did you actually define
operator()
> > > somewhere?
> >
> > Actually not as I do not have any use for it.
>
> Nicolas,
> you don't, but the compiler does :)
> Add a trivial body to the method and your problem
should disappear.
>
> Later,
> Luigi
>
>


Reply | Threaded
Open this post in threaded view
|

RE: Adding a payoff function

cuchulainn
In reply to this post by Nicolas Magnette
Hi
A small remark about the code. The switch statement in the MyPayoff::eval() function can be replaced by a GOF Strategy pattern so that you add new types without having to reedit. It results in more flexible code and is very flexible.

regards

Daniel J. Duffy


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf
> Of Nicolas
> Magnette
> Sent: 19 May 2004 11:20
> To: [hidden email]; Luigi Ballabio
> Cc: [hidden email];
> [hidden email]
> Subject: Re: [Quantlib-users] Adding a payoff function
>
>
> Thanks a lot for your help.
>
> Here is my modified payoff. I had to add a
> funstion "eval" as I need the calculation of the
> payoff to take more than one argument and this is
> impossible with the operator which is standard for all
> payoffs.
>
>
>     class MyPayoff : public StrikedTypePayoff {
>     public:
>         MyPayoff(Option::Type type,
>                          double strike1,
>                          double strike2,
> double strike3,
> double premium1, double
> premium2,
> double rate1, double rate2,
> int elapseddays)
>         : StrikedTypePayoff(type, strike1),
> elapseddays_(elapseddays), strike2_(strike2), \
> strike3_(strike3),
> premium1_(premium1), \
> premium2_(premium2),
> rate1_(rate1), rate2_(rate2) {}
>         double operator()(double price) const;
> double eval(double price, Time time_elapsed)
> const;
> double strike2() const { return strike2_; };
> double strike3() const { return strike3_; };
> double premium1() const { return premium1_; };
> double premium2() const { return premium2_; };
> double rate1() const { return rate1_; };
>   double rate2() const { return rate2_; };
> int elapseddays() const { return
> elapseddays_; };
>      private:
> double strike2_;
> double strike3_;
>         double premium1_;
>         double premium2_;
>         double rate1_;
>         double rate2_;
> int elapseddays_;
>     };
>
>     inline double MyPayoff::eval(double price, Time
> time_elapsed) const {
> //int time_elapsed = 100;
>         switch (type_) {
>           case Option::Call:
>               return -1.0;
>           case Option::Put:
>     ....      
>           case Option::Straddle:
>               return -1.0;
>           default:
>             throw Error("Unknown/Illegal option type");
>         }
> }
>
>
> Sincerely,
>
> Nicolas
>
> En réponse à Luigi Ballabio
> <[hidden email]>:
>
> > On 2004.05.19 10:19, Nicolas Magnette wrote:
> > > I need to add a very special payoff function for an
> > > exotic index option. I simply added it in
> > > Instruments\payoff.hpp, but am unable to compile
> files
> > > which use it. I always get a undefined reference to
> > > vtable for Quantlib::Mypayoff. I tried to recompile
> > > the whole library with my modified payoffs.hpp, but
> > > this did not help. Does anyone have an idea how I
> > > could make this work?
> >
> > Nicolas,
> > can you show the code of the payoff class you
> added? Of course  
> > you can hide the actual math if that is proprietary.
> But I'd like to  
> > see the signature of the class.
> >
> > Later,
> > Luigi
> >
> >
> > -----------------------------------------------------
> --
> > This SF.Net email is sponsored by: SourceForge.net
> Broadband
> > Sign-up now for SourceForge Broadband and get the
> fastest
> > 6.0/768 connection for only $19.95/mo for the first
> 3 months!
> > http://ads.osdn.com/?
> ad_id=2562&alloc_id=6184&op=click
> > _______________________________________________
> > Quantlib-users mailing list
> > [hidden email]
> >
> https://lists.sourceforge.net/lists/listinfo/quantlib-
> users
> >
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: SourceForge.net Broadband
> Sign-up now for SourceForge Broadband and get the fastest
> 6.0/768 connection for only $19.95/mo for the first 3 months!
> http://ads.osdn.com/?ad_id%62&alloc_ida84&op=ick
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Wujiang Lou
In reply to this post by Luigi Ballabio-2
A more general and extensible payoff class would need implementation of concept of State or Path, instead of one argument or two arguments.
Your operator() then has two signatures, one taking in a State while the other takes in a Path for Path dependent payoffs.
-wujiang

Luigi Ballabio wrote:

On 2004.05.19 11:20, Nicolas Magnette wrote:
> Here is my modified payoff. I had to add a
> funstion "eval" as I need the calculation of the
> payoff to take more than one argument and this is
> impossible with the operator which is standard for all
> payoffs.
>
>     class MyPayoff : public StrikedTypePayoff {
>     public:
>         MyPayoff(...)
>         : ...  {}
>         double operator()(double price) const;
>         double eval(double price, Time time_elapsed) const;
>         ...
>      private:
>          ...
>     };
>
>     inline double MyPayoff::eval(double price, Time
> time_elapsed) const {
>       ...
> }

Nicolas,
        besides declaring it, did you actually define operator()
somewhere?

Later,
        Luigi

-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

--
This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation.  Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers.  This may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this.  Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com.  You should not use email to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions.  We cannot guarantee that any such requests received via email will be processed in a timely manner.  This communication is solely for the addressee(s) and may contain confidential information.  We do not waive confidentiality by mistransmission.  Contact me if you do not wish to receive these communications.  In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules).
 

Reply | Threaded
Open this post in threaded view
|

RE: Adding a payoff function

cuchulainn
In reply to this post by Nicolas Magnette
Maybe, but the State is for modelling Dynamic attributes ( e.g. enum status {ON, OFF}) while Strategy is for modelling algorithms, and the current switch problem falls into this category it would seem.
 
I am not familiar with pattern Path; it is not a GOF pattern.
 
regards

Daniel
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Wujiang Lou
Sent: 19 May 2004 14:38
To: [hidden email]
Cc: [hidden email]; [hidden email]
Subject: Re: [Quantlib-users] Adding a payoff function

A more general and extensible payoff class would need implementation of concept of State or Path, instead of one argument or two arguments.
Your operator() then has two signatures, one taking in a State while the other takes in a Path for Path dependent payoffs.
-wujiang

Luigi Ballabio wrote:

On 2004.05.19 11:20, Nicolas Magnette wrote:

> Here is my modified payoff. I had to add a
> funstion "eval" as I need the calculation of the
> payoff to take more than one argument and this is
> impossible with the operator which is standard for all
> payoffs.
>
>     class MyPayoff : public StrikedTypePayoff {
>     public:
>         MyPayoff(...)
>         : ...  {}
>         double operator()(double price) const;
>         double eval(double price, Time time_elapsed) const;
>         ...
>      private:
>          ...
>     };
>
>     inline double MyPayoff::eval(double price, Time
> time_elapsed) const {
>       ...
> }

Nicolas,

        besides declaring it, did you actually define operator()
somewhere?

Later,
        Luigi

-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

--
This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation.  Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers.  This may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this.  Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com.  You should not use email to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions.  We cannot guarantee that any such requests received via email will be processed in a timely manner.  This communication is solely for the addressee(s) and may contain confidential information.  We do not waive confidentiality by mistransmission.  Contact me if you do not wish to receive these communications.  In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules).
 

Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Luigi Ballabio-2
On 2004.05.19 14:50, Daniel J. Duffy wrote:
> I am not familiar with pattern Path; it is not a GOF pattern.

Hi,
        I think he meant that since payoffs can be path-dependent,  
Payoff::operator() should be allowed to take a path, too.
At ths time, our take is that e.g., instead of writing

AveragePricePayoff payoff(Call, strike);
p = payoff(path);

one is probably better off writing

PlainVanillaPayoff payoff(Call, strike);
p = payoff(averagePrice(path));

which has the merit of separating the two concerns of averaging and  
calculating the payoff.

The fact that a payoff could be intrinsically dependent on time is  
another matter, though. Maybe we should augment the signature of  
Payoff::operator() to take a time argument as well...

Later,
        Luigi


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of
> Wujiang Lou
> Sent: 19 May 2004 14:38
> To: [hidden email]
> Cc: [hidden email];
> [hidden email]
> Subject: Re: [Quantlib-users] Adding a payoff function
>
>
> A more general and extensible payoff class would need implementation
> of concept of State or Path, instead of one argument or two  
> arguments.
>
> Your operator() then has two signatures, one taking in a State while
> the other takes in a Path for Path dependent payoffs.
> -wujiang
>
> Luigi Ballabio wrote:
>
>
> On 2004.05.19 11:20, Nicolas Magnette wrote:
> > Here is my modified payoff. I had to add a
> > funstion "eval" as I need the calculation of the
> > payoff to take more than one argument and this is
> > impossible with the operator which is standard for all
> > payoffs.
> >
> >     class MyPayoff : public StrikedTypePayoff {
> >     public:
> >         MyPayoff(...)
> >         : ...  {}
> >         double operator()(double price) const;
> >         double eval(double price, Time time_elapsed) const;
> >         ...
> >      private:
> >          ...
> >     };
> >
> >     inline double MyPayoff::eval(double price, Time
> > time_elapsed) const {
> >       ...
> > }
>
> Nicolas,
>         besides declaring it, did you actually define operator()
> somewhere?
>
>
> Later,
>         Luigi
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: SourceForge.net Broadband
> Sign-up now for SourceForge Broadband and get the fastest
> 6.0/768 connection for only $19.95/mo for the first 3 months!
> http://ads.osdn.com/?ad_id=2562 
> <http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click>
> &alloc_id=6184&op=click
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> --
> This is not an offer (or solicitation of an offer) to buy/sell the
> securities/instruments mentioned or an official confirmation.  Morgan
> Stanley may deal as principal in or own or act as market maker for
> securities/instruments mentioned or may advise the issuers.  This may
> refer to a research analyst/research report. Unless indicated, these
> views are the author's and may differ from those of Morgan Stanley
> research or others in the Firm. We do not represent this is accurate
> or complete and we may not update this.  Past performance is not
> indicative of future returns. For additional information, research
> reports and important disclosures, contact me or see
> https://secure.ms.com.  You should not use email to request,  
> authorize
> or effect the purchase or sale of any security or instrument, to send
> transfer instructions, or to effect any other transactions.  We  
> cannot
> guarantee that any such requests received via email will be processed
> in a timely manner.  This communication is solely for the addressee
> (s)
> and may contain confidential information.  We do not waive
> confidentiality by mistransmission.  Contact me if you do not wish to
> receive these communications.  In the UK, this communication is
> directed in the UK to those persons who are market counterparties or
> intermediate customers (as defined in the UK Financial Services
> Authority's rules).
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Nicolas Magnette
Luigi,

this is exactly what I applied to solve my problem. I
calculate the average in a separate function of my
pricing engine, which is certainly not the best to do.

Changin the signature of the () operator could be
nice, as my payoff is not the only one that uses a
time argument.

Sincerely,

Nicolas

En réponse à Luigi Ballabio
<[hidden email]>:

> On 2004.05.19 14:50, Daniel J. Duffy wrote:
> > I am not familiar with pattern Path; it is not a
GOF pattern.
>
> Hi,
> I think he meant that since payoffs can be
path-dependent,  
> Payoff::operator() should be allowed to take a path,
too.
> At ths time, our take is that e.g., instead of
writing

>
> AveragePricePayoff payoff(Call, strike);
> p = payoff(path);
>
> one is probably better off writing
>
> PlainVanillaPayoff payoff(Call, strike);
> p = payoff(averagePrice(path));
>
> which has the merit of separating the two concerns
of averaging and  
> calculating the payoff.
>
> The fact that a payoff could be intrinsically
dependent on time is  
> another matter, though. Maybe we should augment the
signature of  
> Payoff::operator() to take a time argument as well...
>
> Later,
> Luigi
>
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]]
On Behalf Of
> > Wujiang Lou
> > Sent: 19 May 2004 14:38
> > To: [hidden email]
> > Cc: [hidden email];
> > [hidden email]
> > Subject: Re: [Quantlib-users] Adding a payoff
function
> >
> >
> > A more general and extensible payoff class would
need implementation
> > of concept of State or Path, instead of one
argument or two  
> > arguments.
> >
> > Your operator() then has two signatures, one
taking in a State while
> > the other takes in a Path for Path dependent
payoffs.

> > -wujiang
> >
> > Luigi Ballabio wrote:
> >
> >
> > On 2004.05.19 11:20, Nicolas Magnette wrote:
> > > Here is my modified payoff. I had to add a
> > > funstion "eval" as I need the calculation of the
> > > payoff to take more than one argument and this is
> > > impossible with the operator which is standard
for all
> > > payoffs.
> > >
> > >     class MyPayoff : public StrikedTypePayoff {
> > >     public:
> > >         MyPayoff(...)
> > >         : ...  {}
> > >         double operator()(double price) const;
> > >         double eval(double price, Time
time_elapsed) const;
> > >         ...
> > >      private:
> > >          ...
> > >     };
> > >
> > >     inline double MyPayoff::eval(double price,
Time
> > > time_elapsed) const {
> > >       ...
> > > }
> >
> > Nicolas,
> >         besides declaring it, did you actually
define operator()
> > somewhere?
> >
> >
> > Later,
> >         Luigi
> >
> >
> > ---------------------------------------------------
----
> > This SF.Net email is sponsored by: SourceForge.net
Broadband
> > Sign-up now for SourceForge Broadband and get the
fastest
> > 6.0/768 connection for only $19.95/mo for the
first 3 months!
> > http://ads.osdn.com/?ad_id=2562 
> > <http://ads.osdn.com/?
ad_id=2562&alloc_id=6184&op=click>
> > &alloc_id=6184&op=click
> > _______________________________________________
> > Quantlib-users mailing list
> > [hidden email]
> >
https://lists.sourceforge.net/lists/listinfo/quantlib-
users
> >
> > --
> > This is not an offer (or solicitation of an offer)
to buy/sell the
> > securities/instruments mentioned or an official
confirmation.  Morgan
> > Stanley may deal as principal in or own or act as
market maker for
> > securities/instruments mentioned or may advise the
issuers.  This may
> > refer to a research analyst/research report.
Unless indicated, these
> > views are the author's and may differ from those
of Morgan Stanley
> > research or others in the Firm. We do not
represent this is accurate
> > or complete and we may not update this.  Past
performance is not
> > indicative of future returns. For additional
information, research
> > reports and important disclosures, contact me or
see
> > https://secure.ms.com.  You should not use email
to request,  
> > authorize
> > or effect the purchase or sale of any security or
instrument, to send
> > transfer instructions, or to effect any other
transactions.  We  
> > cannot
> > guarantee that any such requests received via
email will be processed
> > in a timely manner.  This communication is solely
for the addressee
> > (s)
> > and may contain confidential information.  We do
not waive
> > confidentiality by mistransmission.  Contact me if
you do not wish to
> > receive these communications.  In the UK, this
communication is
> > directed in the UK to those persons who are market
counterparties or
> > intermediate customers (as defined in the UK
Financial Services
> > Authority's rules).
> >
> >
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Neil P Firth
In reply to this post by Luigi Ballabio-2
On Wed, 26 May 2004, Luigi Ballabio wrote:

> On 2004.05.19 14:50, Daniel J. Duffy wrote:
> > I am not familiar with pattern Path; it is not a GOF pattern.
>
On the subject of patterns I'd recommend Pattern-Oriented Software
Architecture vols I and II and www.eaipatterns.com is worth a look too.

> Hi,
> I think he meant that since payoffs can be path-dependent,
> Payoff::operator() should be allowed to take a path, too.
> At ths time, our take is that e.g., instead of writing
>
> AveragePricePayoff payoff(Call, strike);
> p = payoff(path);
>
> one is probably better off writing
>
> PlainVanillaPayoff payoff(Call, strike);
> p = payoff(averagePrice(path));
>
> which has the merit of separating the two concerns of averaging and
> calculating the payoff.
>
This is what I have been doing in the basket option payoffs that I have
been working on.

> The fact that a payoff could be intrinsically dependent on time is
> another matter, though. Maybe we should augment the signature of
> Payoff::operator() to take a time argument as well...
>
In Monte Carlo regression methods to calculate American option prices it
is necessary to regress on time dependent basis functions. e.g.
\psi_{i} (X_i) where i indicates time, X_i represents the d asset
prices at time i, and \psi_{i} is a function from R^d -> R.

One thing that I have been thinking about is how to cleanly design MC
algorithms that follow the pattern:

: Generate paths forward through time
: Regress rolling backwards through time (e.g. LSMC estimator)
: Generate independent paths
: Generate low and high biased estimates proceeding forwards through time

Any ideas welcome!

Neil


Reply | Threaded
Open this post in threaded view
|

RE: Adding a payoff function

cuchulainn
In reply to this post by Nicolas Magnette
At the risk of selling my new book C++ and patterns, where we apply POSA and GOF patterns in pricing apps


http://www.datasim-component.com/financial.asp?section=books

ciao

Daniel

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Neil P
> Firth
> Sent: 26 May 2004 12:01
> To: [hidden email]
> Subject: Re: [Quantlib-users] Adding a payoff function
>
>
>
> On Wed, 26 May 2004, Luigi Ballabio wrote:
>
> > On 2004.05.19 14:50, Daniel J. Duffy wrote:
> > > I am not familiar with pattern Path; it is not a GOF pattern.
> >
> On the subject of patterns I'd recommend Pattern-Oriented Software
> Architecture vols I and II and www.eaipatterns.com is worth a
> look too.
>
> > Hi,
> > I think he meant that since payoffs can be path-dependent,
> > Payoff::operator() should be allowed to take a path, too.
> > At ths time, our take is that e.g., instead of writing
> >
> > AveragePricePayoff payoff(Call, strike);
> > p = payoff(path);
> >
> > one is probably better off writing
> >
> > PlainVanillaPayoff payoff(Call, strike);
> > p = payoff(averagePrice(path));
> >
> > which has the merit of separating the two concerns of averaging and
> > calculating the payoff.
> >
> This is what I have been doing in the basket option payoffs
> that I have
> been working on.
>
> > The fact that a payoff could be intrinsically dependent on time is
> > another matter, though. Maybe we should augment the signature of
> > Payoff::operator() to take a time argument as well...
> >
> In Monte Carlo regression methods to calculate American
> option prices it
> is necessary to regress on time dependent basis functions. e.g.
> \psi_{i} (X_i) where i indicates time, X_i represents the d asset
> prices at time i, and \psi_{i} is a function from R^d -> R.
>
> One thing that I have been thinking about is how to cleanly design MC
> algorithms that follow the pattern:
>
> : Generate paths forward through time
> : Regress rolling backwards through time (e.g. LSMC estimator)
> : Generate independent paths
> : Generate low and high biased estimates proceeding forwards
> through time
>
> Any ideas welcome!
>
> Neil
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market...
> Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


Reply | Threaded
Open this post in threaded view
|

Re: Adding a payoff function

Wujiang Lou
In reply to this post by Nicolas Magnette
An example to the point: some energy/commodity contracts use last n days' average as exercise price vs a fixed strike. Here your payoff is path  and t dependent. So an operator (or function) like averagePrice(Path) needs to be overloaded with (Path, t, n) where n is indeed a fixed number more like an attribute. Things can get more complicated as we need to know how often State is sampled in time... It's probably better just to put them in a class instead of writing separate functions.
Another point is Path could be of number of states, like 2 states in an outperformance or spread option (s1-k*s2).  (template could certainly help.)
But conceptually a sig of operator(Path, t) should be general enough, leaving other details to payoff object.
Things could get dirty like a default payoff with stochastic recovery rate on a market value of no-default... But nonetheless we could treat both recovery rate and the market value of the no-default instrument as additional states to be included in the Path.
A more realistic exercise is bond option in either MC and lattice setting.

Nicolas Magnette wrote:

Luigi,

this is exactly what I applied to solve my problem. I
calculate the average in a separate function of my
pricing engine, which is certainly not the best to do.

Changin the signature of the () operator could be
nice, as my payoff is not the only one that uses a
time argument.

Sincerely,

Nicolas

En réponse à Luigi Ballabio
<[hidden email]>:

> On 2004.05.19 14:50, Daniel J. Duffy wrote:
> > I am not familiar with pattern Path; it is not a
GOF pattern.
>
> Hi,
>       I think he meant that since payoffs can be
path-dependent,
> Payoff::operator() should be allowed to take a path,
too.
> At ths time, our take is that e.g., instead of
writing
>
> AveragePricePayoff payoff(Call, strike);
> p = payoff(path);
>
> one is probably better off writing
>
> PlainVanillaPayoff payoff(Call, strike);
> p = payoff(averagePrice(path));
>
> which has the merit of separating the two concerns
of averaging and
> calculating the payoff.
>
> The fact that a payoff could be intrinsically
dependent on time is
> another matter, though. Maybe we should augment the
signature of
> Payoff::operator() to take a time argument as well...
>
> Later,
>       Luigi
>
>
> > -----Original Message-----
> > From: [hidden email]
> > [[hidden email]]
On Behalf Of
> > Wujiang Lou
> > Sent: 19 May 2004 14:38
> > To: [hidden email]
> > Cc: [hidden email];
> > [hidden email]
> > Subject: Re: [Quantlib-users] Adding a payoff
function
> >
> >
> > A more general and extensible payoff class would
need implementation
> > of concept of State or Path, instead of one
argument or two
> > arguments.
> >
> > Your operator() then has two signatures, one
taking in a State while
> > the other takes in a Path for Path dependent
payoffs.
> > -wujiang
> >
> > Luigi Ballabio wrote:
> >
> >
> > On 2004.05.19 11:20, Nicolas Magnette wrote:
> > > Here is my modified payoff. I had to add a
> > > funstion "eval" as I need the calculation of the
> > > payoff to take more than one argument and this is
> > > impossible with the operator which is standard
for all
> > > payoffs.
> > >
> > >     class MyPayoff : public StrikedTypePayoff {
> > >     public:
> > >         MyPayoff(...)
> > >         : ...  {}
> > >         double operator()(double price) const;
> > >         double eval(double price, Time
time_elapsed) const;
> > >         ...
> > >      private:
> > >          ...
> > >     };
> > >
> > >     inline double MyPayoff::eval(double price,
Time
> > > time_elapsed) const {
> > >       ...
> > > }
> >
> > Nicolas,
> >         besides declaring it, did you actually
define operator()
> > somewhere?
> >
> >
> > Later,
> >         Luigi
> >
> >
> > ---------------------------------------------------
----
> > This SF.Net email is sponsored by: SourceForge.net
Broadband
> > Sign-up now for SourceForge Broadband and get the
fastest
> > 6.0/768 connection for only $19.95/mo for the
first 3 months!
> > http://ads.osdn.com/?ad_id=2562
> > <http://ads.osdn.com/?
ad_id=2562&alloc_id=6184&op=click>
> > &alloc_id=6184&op=click
> > _______________________________________________
> > Quantlib-users mailing list
> > [hidden email]
> >
https://lists.sourceforge.net/lists/listinfo/quantlib-
users
> >
> > --
> > This is not an offer (or solicitation of an offer)
to buy/sell the
> > securities/instruments mentioned or an official
confirmation.  Morgan
> > Stanley may deal as principal in or own or act as
market maker for
> > securities/instruments mentioned or may advise the
issuers.  This may
> > refer to a research analyst/research report.
Unless indicated, these
> > views are the author's and may differ from those
of Morgan Stanley
> > research or others in the Firm. We do not
represent this is accurate
> > or complete and we may not update this.  Past
performance is not
> > indicative of future returns. For additional
information, research
> > reports and important disclosures, contact me or
see
> > https://secure.ms.com.  You should not use email
to request,
> > authorize
> > or effect the purchase or sale of any security or
instrument, to send
> > transfer instructions, or to effect any other
transactions.  We
> > cannot
> > guarantee that any such requests received via
email will be processed
> > in a timely manner.  This communication is solely
for the addressee
> > (s)
> > and may contain confidential information.  We do
not waive
> > confidentiality by mistransmission.  Contact me if
you do not wish to
> > receive these communications.  In the UK, this
communication is
> > directed in the UK to those persons who are market
counterparties or
> > intermediate customers (as defined in the UK
Financial Services
> > Authority's rules).
> >
> >
> >
>

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
<a href="http://ads.osdn.com/?ad_id149&alloc_id66&op=click">http://ads.osdn.com/?ad_id149&alloc_id66&op=click
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

--
This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation.  Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers.  This may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this.  Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com.  You should not use email to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions.  We cannot guarantee that any such requests received via email will be processed in a timely manner.  This communication is solely for the addressee(s) and may contain confidential information.  We do not waive confidentiality by mistransmission.  Contact me if you do not wish to receive these communications.  In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules).