Posted by
Nicolas Magnette on
URL: http://quantlib.414.s1.nabble.com/Adding-a-payoff-function-tp2939p2947.html
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
>