/* This class extends euro_opt_params which constains the * parameters of european options on bonds. This class has * embedded a diff_BDT class */ /** * * @author horacio aliaga */ #include "diff_BDT.cpp" #include "euro_opt_params.cpp" #include "Point.cpp" #include "Curve.cpp" #include "Spline.cpp" #include "SdeIntegrator.h" #include #include #include #include #include #include #define max(a,b) (((a)>(b))?(a):(b)) using namespace std; class euro_option_diff_BDT : public euro_opt_params{ public: //euro_opt_params p; diff_BDT bond; /** * Creates a new instance of euro_option_diff_BDT */ public: euro_option_diff_BDT() { //bond = new diff_BDT(); //p = new euro_opt_params(); } /** * Creates a new instance of euro_option_diff_BDT */ public: euro_option_diff_BDT(double _m,double _p,double _s) { //bond = new diff_BDT(); //p = new euro_opt_params(); set_O_maturity( _m); set_face(_p); set_strike(_s); } public: euro_option_diff_BDT(double _maturity,double _face,double _stk, double _time,double _mu,double _alpha, double _sigma,double _r) { //bond = new diff_BDT(_time,_mu,_alpha,_sigma,_r); //p = new euro_opt_params(); set_O_maturity(_maturity); set_face(_face); set_strike(_stk); } public: void set_euro_option_diff_BDT( double _maturity,double _face,double _stk, double _time,double _mu,double _alpha, double _sigma,double _r) { //bond = new diff_BDT(_time,_mu,_alpha,_sigma,_r); set_O_maturity(_maturity); set_face(_face); set_strike(_stk); } public: double calculate_call_aver(int n_sim,int n_points){ TwoCurve data; double call=0; for (int i=0;iget_x(); r_aver_bond = r_aver_bond + point->get_y(); if(t<=get_O_maturity()){ r_aver_option = r_aver_option + point->get_y(); } } r_aver_bond=r_aver_bond/n_points; r_aver_option=r_aver_option/n_points/get_O_maturity()*bond.get_B_maturity(); call=max(+exp(-r_aver_bond*bond.get_B_maturity())*get_face() -exp(-r_aver_option*get_O_maturity())*get_strike(),0); return call; } public: double calculate_put_aver(int n_sim,int n_points){ TwoCurve data; double put=0; for (int i=0;iget_x(); r_aver_bond = r_aver_bond + point->get_y(); if(t<=get_O_maturity()){ r_aver_option = r_aver_option + point->get_y(); } } r_aver_bond=r_aver_bond/n_points; r_aver_option=r_aver_option/n_points/get_O_maturity()*bond.get_B_maturity(); put=max(-exp(-r_aver_bond*bond.get_B_maturity())*get_face() +exp(-r_aver_option*get_O_maturity())*get_strike(),0); return put; } }; /*void main() { vector time; time.push_back(0.);time.push_back(0.12);time.push_back(0.25);time.push_back(0.37); vectorfrwd; frwd.push_back(0.106);frwd.push_back(0.160);frwd.push_back(0.170);frwd.push_back(0.1835); Spline s; double* yout = s.spline_array(time,frwd,5,1.0); }*/