-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPayoff.h
56 lines (42 loc) · 1.19 KB
/
Payoff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __PayoffNew__
#define __Payoffnew__
#include "OptionVanilla.h"
class Payoff
{
public:
Payoff(){};
virtual bool operator()(double spot) const=0;
virtual double GetStrike() const =0;
virtual OptionVanilla::Type GetType() const =0;
virtual ~Payoff(){}
};
// abstract class for Payoff with Call/Put Type
class PayoffWithType : public Payoff
{
public:
// constructor
PayoffWithType(OptionVanilla::Type type):type_(type){};
// set and get type
void SetType(OptionVanilla::Type type) { type_ = type; }
OptionVanilla::Type GetType() const {return type_; }
protected:
// member type
OptionVanilla::Type type_;
};
// class for Vanilla Payoff with Call/Put Type and Fixed Strike
class PayoffVanilla : public PayoffWithType
{
public:
// constructor
PayoffVanilla(OptionVanilla::Type type,double strike);
// set and get strike
void SetStrike(double strike) { strike_ = strike; }
double GetStrike() const {return strike_;}
// payoff function
virtual bool operator()(double spot) const;
// virtual double operator()(bool type) const;
protected:
// member strike
double strike_;
};
#endif /* defined(__lab1_3__Payoff__) */