-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathxll_njr.cpp
65 lines (55 loc) · 1.85 KB
/
xll_njr.cpp
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
58
59
60
61
62
63
64
// xll_njr.cpp - Normal Jarrow-Rudd model
#include "fms_njr.h"
#include "G5260.h"
using namespace fms;
using namespace xll;
Auto<Open> xao_fms_choose_test([]() {
fms_choose_test();
fms_hermite_test();
fms_bell_test();
return TRUE;
});
AddIn xai_njr_put(
Function(XLL_DOUBLE, L"?xll_njr_put", L"NJR.PUT")
.Arg(XLL_DOUBLE, L"f", L"is the forward value.")
.Arg(XLL_DOUBLE, L"sigma", L"is the volatility.")
.Arg(XLL_DOUBLE, L"k", L"is strike.")
.Arg(XLL_DOUBLE, L"t", L"is the expiration in years.")
.Arg(XLL_FP, L"kappa", L"is the perturbation of the cumulants from a standard normal.")
.Category(CATEGORY)
.FunctionHelp(L"Forward value of a put option.")
);
double WINAPI xll_njr_put(double f, double sigma, double k, double t, const _FP12* pkappa)
{
#pragma XLLEXPORT
double result = std::numeric_limits<double>::quiet_NaN();
try {
result = njr::put(f, sigma, k, t, size(*pkappa), pkappa->array);
}
catch (const std::exception& ex) {
XLL_ERROR(ex.what());
}
return result;
}
AddIn xai_njr_call(
Function(XLL_DOUBLE, L"?xll_njr_call", L"NJR.CALL")
.Arg(XLL_DOUBLE, L"f", L"is the forward value.")
.Arg(XLL_DOUBLE, L"sigma", L"is the volatility.")
.Arg(XLL_DOUBLE, L"k", L"is strike.")
.Arg(XLL_DOUBLE, L"t", L"is the expiration in years.")
.Arg(XLL_FP, L"kappa", L"is the perturbation of the cumulants from a standard normal.")
.Category(CATEGORY)
.FunctionHelp(L"Forward value of a call option.")
);
double WINAPI xll_njr_call(double f, double sigma, double k, double t, const _FP12* pkappa)
{
#pragma XLLEXPORT
double result = std::numeric_limits<double>::quiet_NaN();
try {
result = njr::call(f, sigma, k, t, size(*pkappa), pkappa->array);
}
catch (const std::exception& ex) {
XLL_ERROR(ex.what());
}
return result;
}