aboutsummaryrefslogtreecommitdiffstats
path: root/src/option.hpp
diff options
context:
space:
mode:
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;
};
-
-