aboutsummaryrefslogtreecommitdiffstats
path: root/src/option.hpp
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-04-13 11:34:19 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-04-13 11:34:19 -0400
commit28fe184f2fea5031f352cf73fc30b99b5cde8f6f (patch)
tree5b5e40c800c5648da44f6cf70ebde8ecb6110723 /src/option.hpp
parent4e5104a0186bd705b5ed1f57f73375ace60587f6 (diff)
downloadprojet_C++-28fe184f2fea5031f352cf73fc30b99b5cde8f6f.tar.gz
replace unary_function by function
Diffstat (limited to 'src/option.hpp')
-rw-r--r--src/option.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/option.hpp b/src/option.hpp
index 4d9ee13..c969071 100644
--- a/src/option.hpp
+++ b/src/option.hpp
@@ -1,12 +1,12 @@
-#include "rqmc.hpp"
+#include <functional>
double pos (double x);
-struct asian_option : public std::unary_function<std::vector<double>, double>
+struct asian_option : public std::function<double(std::vector<double>)>
{
asian_option(double r, double T, double S0, double V, int d, double K)
: r(r), T(T), S0(S0), V(V), d(d), K(K) {};
-
+
double operator()(std::vector<double> X) const {
std::vector<double> S(d);
S[0]= S0*exp((r-V*V/2)*(T/d)+V*sqrt(T/d)*X[0]);
@@ -15,8 +15,8 @@ struct asian_option : public std::unary_function<std::vector<double>, double>
}
double temp = std::accumulate(S.begin(), S.end(), 0.)/d;
return exp(-r*T)*pos(temp-K);
- };
-
+ };
+
private:
double r;
double T;
@@ -25,5 +25,3 @@ struct asian_option : public std::unary_function<std::vector<double>, double>
int d;
double K;
};
-
-