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
|
#include "Solver03.h"
#include "Margrabe.h"
#include <iostream>
#include <cmath>
using namespace std;
class Intermediary: public EurCall
{
private:
double Si, r, qi;
public:
Intermediary( double Si_, double r_, double T_, double Ki_, double qi_)
: EurCall(T_, Ki_) {Si=Si_; r=r_; qi=qi_;}
double Value(double sigma)
{
return BSFormula(Si, sigma, r, qi);
}
};
int main()
{
double Si=95;
double r=0.06;
double T=0.5;
double Ki=95;
double qi=0.03;
Intermediary Call(Si, r, T, Ki, qi);
double Acc=0.001;
double LEnd=0.01, REnd=1.0;
double Tgt=9.1206;
cout << "Implied vol by bisect: "
<<SolveByBisect(&Call, Tgt, LEnd, REnd, Acc)
<<endl;
return 0;
}
|