From 16e1de7cbeaf4d62d8d008d6c3bc0eab2b1d6c5f Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 13 Apr 2016 13:40:48 -0400 Subject: simplify opti.cpp --- src/opti.cpp | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'src/opti.cpp') diff --git a/src/opti.cpp b/src/opti.cpp index 6b05ecd..211a7e3 100644 --- a/src/opti.cpp +++ b/src/opti.cpp @@ -1,8 +1,5 @@ #include "opti.hpp" - -double pos (double x){ - return x>0?x:0; -}; +#include "option.hpp" double f (const std::vector &X, std::vector &grad, void *params) { int d = X.size(); @@ -13,23 +10,15 @@ double f (const std::vector &X, std::vector &grad, void *params) for(int i=0; i S(d); - S[0]= S0*exp((r-V*V/2)*(T/d)+V*sqrt(T/d)*X[0]); - for(int i=1;i argmax(double r, double T, double S0, double V, double K, int d){ - + double params[5] = {r, T, S0, V, K}; - + nlopt::opt opt(nlopt::LN_COBYLA, d); opt.set_max_objective(f, ¶ms); @@ -44,11 +33,3 @@ std::vector argmax(double r, double T, double S0, double V, double K, in return x; } - - - - - - - - -- cgit v1.2.3-70-g09d2