-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinModel.cpp
More file actions
57 lines (45 loc) · 1.13 KB
/
Copy pathBinModel.cpp
File metadata and controls
57 lines (45 loc) · 1.13 KB
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
57
#include "BinModel.h"
#include <iostream>
#include <cmath>
using namespace std;
double BinModel::RiskNeutProb() {
return (R - D) / (U - D);
}
double BinModel::S(int n, int i) {
return S0 * pow(1 + U, i) * pow(1 + D, n - i);
}
int BinModel::GetInputData() {
// Entering data
cout << "Enter S0: "; cin >> S0;
cout << "Enter U: "; cin >> U;
cout << "Enter D: "; cin >> D;
cout << "Enter R: "; cin >> R;
cout << endl;
// Making sure that 0 < S0, -1 < D < U, -1 < R
if (S0 <= 0.0 || U <= -1.0 || D <= -1.0 || U <= D || R <= -1.0) {
cout << "Illegal data ranges" << endl;
cout << "Terminating program" << endl;
return 1;
}
// Checking for arbitrage
if (R >= U || R <= D) {
cout << "Arbitrage exists" << endl;
cout << "Terminating program" << endl;
return 1;
}
cout << "Input data checked" << endl;
cout << "There is no arbitrage" << endl << endl;
return 0;
}
double BinModel::GetR() {
return R;
}
double BinModel::GetU() {
return U;
}
double BinModel::GetD() {
return D;
}
double BinModel::GetS0() {
return S0;
}