Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/abcd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/abcd.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef abcd_h
Expand Down
2 changes: 1 addition & 1 deletion src/accountingengines.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/accountingengines.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef accountingengines_h
Expand Down
2 changes: 1 addition & 1 deletion src/alphaform.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/alphaform.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef alphaform_h
Expand Down
2 changes: 1 addition & 1 deletion src/assetswap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/assetswap.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef assetswap_h
Expand Down
2 changes: 1 addition & 1 deletion src/basketlossmodels.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/basketlossmodels.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef basketlossmodels_h
Expand Down
2 changes: 1 addition & 1 deletion src/bonds.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/bonds.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef bonds_h
Expand Down
2 changes: 1 addition & 1 deletion src/browniangenerators.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/browniangenerators.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef browniangenerators_h
Expand Down
2 changes: 1 addition & 1 deletion src/btp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/btp.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef btp_h
Expand Down
2 changes: 1 addition & 1 deletion src/calendar.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/calendar.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef calendar_h
Expand Down
2 changes: 1 addition & 1 deletion src/calibrationhelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/calibrationhelpers.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef calibrationhelpers_h
Expand Down
2 changes: 1 addition & 1 deletion src/capfloor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down
2 changes: 1 addition & 1 deletion src/capfloor.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#ifndef capfloor_h
Expand Down
71 changes: 67 additions & 4 deletions src/capletvolstructure.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Jerry Jin
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <nan.h>
Expand Down Expand Up @@ -136,6 +136,8 @@ void ConstantOptionletVolatilityWorker::Execute(){
QuantLib::DayCounter DayCounterEnum =
ObjectHandler::Create<QuantLib::DayCounter>()(mDayCounter);


// convert input datatypes to QuantLib datatypes

// Construct the Value Object
boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
Expand All @@ -146,6 +148,8 @@ void ConstantOptionletVolatilityWorker::Execute(){
mBusinessDayConvention,
mVolatility,
mDayCounter,
mVolatilityType,
mDisplacement,
false
));

Expand All @@ -158,6 +162,8 @@ void ConstantOptionletVolatilityWorker::Execute(){
BusinessDayConventionEnum,
VolatilityLibObj,
DayCounterEnum,
mVolatilityType,
mDisplacement,
false
));

Expand Down Expand Up @@ -202,6 +208,12 @@ NAN_METHOD(QuantLibNode::ConstantOptionletVolatility) {
if (info.Length() == 5 || !info[5]->IsString()) {
return Nan::ThrowError("DayCounter is required.");
}
if (info.Length() == 6 || !info[6]->IsString()) {
return Nan::ThrowError("VolatilityType is required.");
}
if (info.Length() == 7 || !info[7]->IsNumber()) {
return Nan::ThrowError("Displacement is required.");
}
// convert js argument to c++ type
String::Utf8Value strObjectID(info[0]->ToString());
string ObjectIDCpp(strdup(*strObjectID));
Expand All @@ -225,9 +237,16 @@ NAN_METHOD(QuantLibNode::ConstantOptionletVolatility) {
String::Utf8Value strDayCounter(info[5]->ToString());
string DayCounterCpp(strdup(*strDayCounter));

// convert js argument to c++ type
String::Utf8Value strVolatilityType(info[6]->ToString());
string VolatilityTypeCpp(strdup(*strVolatilityType));

// convert js argument to c++ type
double DisplacementCpp = Nan::To<double>(info[7]).FromJust();


// declare callback
Nan::Callback *callback = new Nan::Callback(info[6].As<Function>());
Nan::Callback *callback = new Nan::Callback(info[8].As<Function>());
// launch Async worker
Nan::AsyncQueueWorker(new ConstantOptionletVolatilityWorker(
callback
Expand All @@ -237,6 +256,8 @@ NAN_METHOD(QuantLibNode::ConstantOptionletVolatility) {
,BusinessDayConventionCpp
,VolatilityCpp
,DayCounterCpp
,VolatilityTypeCpp
,DisplacementCpp
));

}
Expand Down Expand Up @@ -470,6 +491,8 @@ void StrippedOptionletWorker::Execute(){
QuantLib::DayCounter DayCounterEnum =
ObjectHandler::Create<QuantLib::DayCounter>()(mDayCounter);


// convert input datatypes to QuantLib datatypes

// Construct the Value Object
boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
Expand All @@ -483,6 +506,8 @@ void StrippedOptionletWorker::Execute(){
mStrikes,
mVolatilities,
mDayCounter,
mVolatilityType,
mDisplacement,
false
));

Expand All @@ -498,6 +523,8 @@ void StrippedOptionletWorker::Execute(){
mStrikes,
VolatilitiesLibObj,
DayCounterEnum,
mVolatilityType,
mDisplacement,
false
));

Expand Down Expand Up @@ -554,6 +581,12 @@ NAN_METHOD(QuantLibNode::StrippedOptionlet) {
if (info.Length() == 8 || !info[8]->IsString()) {
return Nan::ThrowError("DayCounter is required.");
}
if (info.Length() == 9 || !info[9]->IsString()) {
return Nan::ThrowError("VolatilityType is required.");
}
if (info.Length() == 10 || !info[10]->IsNumber()) {
return Nan::ThrowError("Displacement is required.");
}
// convert js argument to c++ type
String::Utf8Value strObjectID(info[0]->ToString());
string ObjectIDCpp(strdup(*strObjectID));
Expand Down Expand Up @@ -610,9 +643,16 @@ NAN_METHOD(QuantLibNode::StrippedOptionlet) {
String::Utf8Value strDayCounter(info[8]->ToString());
string DayCounterCpp(strdup(*strDayCounter));

// convert js argument to c++ type
String::Utf8Value strVolatilityType(info[9]->ToString());
string VolatilityTypeCpp(strdup(*strVolatilityType));

// convert js argument to c++ type
double DisplacementCpp = Nan::To<double>(info[10]).FromJust();


// declare callback
Nan::Callback *callback = new Nan::Callback(info[9].As<Function>());
Nan::Callback *callback = new Nan::Callback(info[11].As<Function>());
// launch Async worker
Nan::AsyncQueueWorker(new StrippedOptionletWorker(
callback
Expand All @@ -625,6 +665,8 @@ NAN_METHOD(QuantLibNode::StrippedOptionlet) {
,StrikesCpp
,VolatilitiesCpp
,DayCounterCpp
,VolatilityTypeCpp
,DisplacementCpp
));

}
Expand Down Expand Up @@ -657,6 +699,8 @@ void OptionletStripper1Worker::Execute(){
QuantLib::Natural MaxIterLib = ObjectHandler::convert2<long>(
mMaxIter, "MaxIter", QuantLib::Null<QuantLib::Natural>());


// convert input datatypes to QuantLib datatypes

// Construct the Value Object
boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
Expand All @@ -667,6 +711,8 @@ void OptionletStripper1Worker::Execute(){
mSwitchStrike,
mAccuracy,
mMaxIter,
mVolatilityType,
mDisplacement,
false
));

Expand All @@ -679,6 +725,8 @@ void OptionletStripper1Worker::Execute(){
mSwitchStrike,
mAccuracy,
MaxIterLib,
mVolatilityType,
mDisplacement,
false
));

Expand Down Expand Up @@ -723,6 +771,12 @@ NAN_METHOD(QuantLibNode::OptionletStripper1) {
if (info.Length() == 4 || !info[4]->IsNumber()) {
return Nan::ThrowError("Accuracy is required.");
}
if (info.Length() == 6 || !info[6]->IsString()) {
return Nan::ThrowError("VolatilityType is required.");
}
if (info.Length() == 7 || !info[7]->IsNumber()) {
return Nan::ThrowError("Displacement is required.");
}
// convert js argument to c++ type
String::Utf8Value strObjectID(info[0]->ToString());
string ObjectIDCpp(strdup(*strObjectID));
Expand All @@ -745,9 +799,16 @@ NAN_METHOD(QuantLibNode::OptionletStripper1) {
ObjectHandler::property_t MaxIterCpp =
ObjectHandler::property_t(static_cast<long>(Nan::To<int32_t>(info[5]).FromJust()));

// convert js argument to c++ type
String::Utf8Value strVolatilityType(info[6]->ToString());
string VolatilityTypeCpp(strdup(*strVolatilityType));

// convert js argument to c++ type
double DisplacementCpp = Nan::To<double>(info[7]).FromJust();


// declare callback
Nan::Callback *callback = new Nan::Callback(info[6].As<Function>());
Nan::Callback *callback = new Nan::Callback(info[8].As<Function>());
// launch Async worker
Nan::AsyncQueueWorker(new OptionletStripper1Worker(
callback
Expand All @@ -757,6 +818,8 @@ NAN_METHOD(QuantLibNode::OptionletStripper1) {
,SwitchStrikeCpp
,AccuracyCpp
,MaxIterCpp
,VolatilityTypeCpp
,DisplacementCpp
));

}
Expand Down
Loading