Skip to content

Commit ab492c0

Browse files
committed
update src for 1.9
1 parent daf5094 commit ab492c0

10 files changed

Lines changed: 173 additions & 168 deletions

src/basketlossmodels.cpp

Lines changed: 96 additions & 96 deletions
Large diffs are not rendered by default.

src/basketlossmodels.hpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GaussianLHPLossmodelWorker : public Nan::AsyncWorker {
2222
public:
2323
string mObjectID;
2424
double mCorrelation;
25-
std::vector<double> mRecoveyRates;
25+
std::vector<double> mRecoveryRates;
2626

2727
string mReturnValue;
2828

@@ -32,12 +32,12 @@ class GaussianLHPLossmodelWorker : public Nan::AsyncWorker {
3232
Nan::Callback *callback
3333
,string ObjectID
3434
,double Correlation
35-
,std::vector<double> RecoveyRates
35+
,std::vector<double> RecoveryRates
3636
):
3737
Nan::AsyncWorker(callback)
3838
,mObjectID(ObjectID)
3939
,mCorrelation(Correlation)
40-
,mRecoveyRates(RecoveyRates)
40+
,mRecoveryRates(RecoveryRates)
4141
{
4242

4343
};
@@ -56,7 +56,7 @@ class IHGaussPoolLossModelWorker : public Nan::AsyncWorker {
5656
public:
5757
string mObjectID;
5858
double mCorrelation;
59-
std::vector<double> mRecoveyRates;
59+
std::vector<double> mRecoveryRates;
6060
long mNumBuckets;
6161

6262
string mReturnValue;
@@ -67,13 +67,13 @@ class IHGaussPoolLossModelWorker : public Nan::AsyncWorker {
6767
Nan::Callback *callback
6868
,string ObjectID
6969
,double Correlation
70-
,std::vector<double> RecoveyRates
70+
,std::vector<double> RecoveryRates
7171
,long NumBuckets
7272
):
7373
Nan::AsyncWorker(callback)
7474
,mObjectID(ObjectID)
7575
,mCorrelation(Correlation)
76-
,mRecoveyRates(RecoveyRates)
76+
,mRecoveryRates(RecoveryRates)
7777
,mNumBuckets(NumBuckets)
7878
{
7979

@@ -93,7 +93,7 @@ class IHStudentPoolLossModelWorker : public Nan::AsyncWorker {
9393
public:
9494
string mObjectID;
9595
double mCorrelation;
96-
std::vector<double> mRecoveyRates;
96+
std::vector<double> mRecoveryRates;
9797
std::vector<double> mTtraits;
9898
long mNumBuckets;
9999

@@ -105,14 +105,14 @@ class IHStudentPoolLossModelWorker : public Nan::AsyncWorker {
105105
Nan::Callback *callback
106106
,string ObjectID
107107
,double Correlation
108-
,std::vector<double> RecoveyRates
108+
,std::vector<double> RecoveryRates
109109
,std::vector<double> Ttraits
110110
,long NumBuckets
111111
):
112112
Nan::AsyncWorker(callback)
113113
,mObjectID(ObjectID)
114114
,mCorrelation(Correlation)
115-
,mRecoveyRates(RecoveyRates)
115+
,mRecoveryRates(RecoveryRates)
116116
,mTtraits(Ttraits)
117117
,mNumBuckets(NumBuckets)
118118
{
@@ -133,7 +133,7 @@ class GBinomialLossmodelWorker : public Nan::AsyncWorker {
133133
public:
134134
string mObjectID;
135135
std::vector< std::vector<double> > mFactors;
136-
std::vector<double> mRecoveyRates;
136+
std::vector<double> mRecoveryRates;
137137

138138
string mReturnValue;
139139

@@ -143,12 +143,12 @@ class GBinomialLossmodelWorker : public Nan::AsyncWorker {
143143
Nan::Callback *callback
144144
,string ObjectID
145145
,std::vector< std::vector<double> > Factors
146-
,std::vector<double> RecoveyRates
146+
,std::vector<double> RecoveryRates
147147
):
148148
Nan::AsyncWorker(callback)
149149
,mObjectID(ObjectID)
150150
,mFactors(Factors)
151-
,mRecoveyRates(RecoveyRates)
151+
,mRecoveryRates(RecoveryRates)
152152
{
153153

154154
};
@@ -167,7 +167,7 @@ class TBinomialLossmodelWorker : public Nan::AsyncWorker {
167167
public:
168168
string mObjectID;
169169
std::vector< std::vector<double> > mFactors;
170-
std::vector<double> mRecoveyRates;
170+
std::vector<double> mRecoveryRates;
171171
std::vector<double> mTtraits;
172172

173173
string mReturnValue;
@@ -178,13 +178,13 @@ class TBinomialLossmodelWorker : public Nan::AsyncWorker {
178178
Nan::Callback *callback
179179
,string ObjectID
180180
,std::vector< std::vector<double> > Factors
181-
,std::vector<double> RecoveyRates
181+
,std::vector<double> RecoveryRates
182182
,std::vector<double> Ttraits
183183
):
184184
Nan::AsyncWorker(callback)
185185
,mObjectID(ObjectID)
186186
,mFactors(Factors)
187-
,mRecoveyRates(RecoveyRates)
187+
,mRecoveryRates(RecoveryRates)
188188
,mTtraits(Ttraits)
189189
{
190190

@@ -244,7 +244,7 @@ class GMCLossModelWorker : public Nan::AsyncWorker {
244244
public:
245245
string mObjectID;
246246
std::vector< std::vector<double> > mFactors;
247-
std::vector<double> mRecoveyRates;
247+
std::vector<double> mRecoveryRates;
248248
long mNumSimulations;
249249

250250
string mReturnValue;
@@ -255,13 +255,13 @@ class GMCLossModelWorker : public Nan::AsyncWorker {
255255
Nan::Callback *callback
256256
,string ObjectID
257257
,std::vector< std::vector<double> > Factors
258-
,std::vector<double> RecoveyRates
258+
,std::vector<double> RecoveryRates
259259
,long NumSimulations
260260
):
261261
Nan::AsyncWorker(callback)
262262
,mObjectID(ObjectID)
263263
,mFactors(Factors)
264-
,mRecoveyRates(RecoveyRates)
264+
,mRecoveryRates(RecoveryRates)
265265
,mNumSimulations(NumSimulations)
266266
{
267267

@@ -281,7 +281,7 @@ class GRandomRRMCLossModelWorker : public Nan::AsyncWorker {
281281
public:
282282
string mObjectID;
283283
std::vector< std::vector<double> > mFactors;
284-
std::vector<double> mRecoveyRates;
284+
std::vector<double> mRecoveryRates;
285285
double mModelA;
286286
long mNumSimulations;
287287

@@ -293,14 +293,14 @@ class GRandomRRMCLossModelWorker : public Nan::AsyncWorker {
293293
Nan::Callback *callback
294294
,string ObjectID
295295
,std::vector< std::vector<double> > Factors
296-
,std::vector<double> RecoveyRates
296+
,std::vector<double> RecoveryRates
297297
,double ModelA
298298
,long NumSimulations
299299
):
300300
Nan::AsyncWorker(callback)
301301
,mObjectID(ObjectID)
302302
,mFactors(Factors)
303-
,mRecoveyRates(RecoveyRates)
303+
,mRecoveryRates(RecoveryRates)
304304
,mModelA(ModelA)
305305
,mNumSimulations(NumSimulations)
306306
{
@@ -321,7 +321,7 @@ class TMCLossModelWorker : public Nan::AsyncWorker {
321321
public:
322322
string mObjectID;
323323
std::vector< std::vector<double> > mFactors;
324-
std::vector<double> mRecoveyRates;
324+
std::vector<double> mRecoveryRates;
325325
std::vector<double> mTtraits;
326326
long mNumSimulations;
327327

@@ -333,14 +333,14 @@ class TMCLossModelWorker : public Nan::AsyncWorker {
333333
Nan::Callback *callback
334334
,string ObjectID
335335
,std::vector< std::vector<double> > Factors
336-
,std::vector<double> RecoveyRates
336+
,std::vector<double> RecoveryRates
337337
,std::vector<double> Ttraits
338338
,long NumSimulations
339339
):
340340
Nan::AsyncWorker(callback)
341341
,mObjectID(ObjectID)
342342
,mFactors(Factors)
343-
,mRecoveyRates(RecoveyRates)
343+
,mRecoveryRates(RecoveryRates)
344344
,mTtraits(Ttraits)
345345
,mNumSimulations(NumSimulations)
346346
{
@@ -361,7 +361,7 @@ class TRandomRRMCLossModelWorker : public Nan::AsyncWorker {
361361
public:
362362
string mObjectID;
363363
std::vector< std::vector<double> > mFactors;
364-
std::vector<double> mRecoveyRates;
364+
std::vector<double> mRecoveryRates;
365365
std::vector<double> mTtraits;
366366
double mModelA;
367367
long mNumSimulations;
@@ -374,15 +374,15 @@ class TRandomRRMCLossModelWorker : public Nan::AsyncWorker {
374374
Nan::Callback *callback
375375
,string ObjectID
376376
,std::vector< std::vector<double> > Factors
377-
,std::vector<double> RecoveyRates
377+
,std::vector<double> RecoveryRates
378378
,std::vector<double> Ttraits
379379
,double ModelA
380380
,long NumSimulations
381381
):
382382
Nan::AsyncWorker(callback)
383383
,mObjectID(ObjectID)
384384
,mFactors(Factors)
385-
,mRecoveyRates(RecoveyRates)
385+
,mRecoveryRates(RecoveryRates)
386386
,mTtraits(Ttraits)
387387
,mModelA(ModelA)
388388
,mNumSimulations(NumSimulations)
@@ -404,7 +404,7 @@ class GSaddlePointLossmodelWorker : public Nan::AsyncWorker {
404404
public:
405405
string mObjectID;
406406
std::vector< std::vector<double> > mFactors;
407-
std::vector<double> mRecoveyRates;
407+
std::vector<double> mRecoveryRates;
408408

409409
string mReturnValue;
410410

@@ -414,12 +414,12 @@ class GSaddlePointLossmodelWorker : public Nan::AsyncWorker {
414414
Nan::Callback *callback
415415
,string ObjectID
416416
,std::vector< std::vector<double> > Factors
417-
,std::vector<double> RecoveyRates
417+
,std::vector<double> RecoveryRates
418418
):
419419
Nan::AsyncWorker(callback)
420420
,mObjectID(ObjectID)
421421
,mFactors(Factors)
422-
,mRecoveyRates(RecoveyRates)
422+
,mRecoveryRates(RecoveryRates)
423423
{
424424

425425
};
@@ -438,7 +438,7 @@ class TSaddlePointLossmodelWorker : public Nan::AsyncWorker {
438438
public:
439439
string mObjectID;
440440
std::vector< std::vector<double> > mFactors;
441-
std::vector<double> mRecoveyRates;
441+
std::vector<double> mRecoveryRates;
442442
std::vector<double> mTtraits;
443443

444444
string mReturnValue;
@@ -449,13 +449,13 @@ class TSaddlePointLossmodelWorker : public Nan::AsyncWorker {
449449
Nan::Callback *callback
450450
,string ObjectID
451451
,std::vector< std::vector<double> > Factors
452-
,std::vector<double> RecoveyRates
452+
,std::vector<double> RecoveryRates
453453
,std::vector<double> Ttraits
454454
):
455455
Nan::AsyncWorker(callback)
456456
,mObjectID(ObjectID)
457457
,mFactors(Factors)
458-
,mRecoveyRates(RecoveyRates)
458+
,mRecoveryRates(RecoveryRates)
459459
,mTtraits(Ttraits)
460460
{
461461

@@ -475,7 +475,7 @@ class GRecursiveLossmodelWorker : public Nan::AsyncWorker {
475475
public:
476476
string mObjectID;
477477
std::vector< std::vector<double> > mFactors;
478-
std::vector<double> mRecoveyRates;
478+
std::vector<double> mRecoveryRates;
479479

480480
string mReturnValue;
481481

@@ -485,12 +485,12 @@ class GRecursiveLossmodelWorker : public Nan::AsyncWorker {
485485
Nan::Callback *callback
486486
,string ObjectID
487487
,std::vector< std::vector<double> > Factors
488-
,std::vector<double> RecoveyRates
488+
,std::vector<double> RecoveryRates
489489
):
490490
Nan::AsyncWorker(callback)
491491
,mObjectID(ObjectID)
492492
,mFactors(Factors)
493-
,mRecoveyRates(RecoveyRates)
493+
,mRecoveryRates(RecoveryRates)
494494
{
495495

496496
};

src/capfloor.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ void CapFloorImpliedVolatilityWorker::Execute(){
732732
mMinVol
733733
,
734734
mMaxVol
735+
,
736+
mVolatilityType
735737
,
736738
mDisplacement
737739
);
@@ -777,7 +779,10 @@ NAN_METHOD(QuantLibNode::CapFloorImpliedVolatility) {
777779
if (info.Length() == 7 || !info[7]->IsNumber()) {
778780
return Nan::ThrowError("MaxVol is required.");
779781
}
780-
if (info.Length() == 8 || !info[8]->IsNumber()) {
782+
if (info.Length() == 8 || !info[8]->IsString()) {
783+
return Nan::ThrowError("VolatilityType is required.");
784+
}
785+
if (info.Length() == 9 || !info[9]->IsNumber()) {
781786
return Nan::ThrowError("Displacement is required.");
782787
}
783788
// convert js argument to c++ type
@@ -808,11 +813,15 @@ NAN_METHOD(QuantLibNode::CapFloorImpliedVolatility) {
808813
double MaxVolCpp = Nan::To<double>(info[7]).FromJust();
809814

810815
// convert js argument to c++ type
811-
double DisplacementCpp = Nan::To<double>(info[8]).FromJust();
816+
String::Utf8Value strVolatilityType(info[8]->ToString());
817+
string VolatilityTypeCpp(strdup(*strVolatilityType));
818+
819+
// convert js argument to c++ type
820+
double DisplacementCpp = Nan::To<double>(info[9]).FromJust();
812821

813822

814823
// declare callback
815-
Nan::Callback *callback = new Nan::Callback(info[9].As<Function>());
824+
Nan::Callback *callback = new Nan::Callback(info[10].As<Function>());
816825
// launch Async worker
817826
Nan::AsyncQueueWorker(new CapFloorImpliedVolatilityWorker(
818827
callback
@@ -824,6 +833,7 @@ NAN_METHOD(QuantLibNode::CapFloorImpliedVolatility) {
824833
,MaxIterCpp
825834
,MinVolCpp
826835
,MaxVolCpp
836+
,VolatilityTypeCpp
827837
,DisplacementCpp
828838
));
829839

src/capfloor.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class CapFloorImpliedVolatilityWorker : public Nan::AsyncWorker {
282282
ObjectHandler::property_t mMaxIter;
283283
double mMinVol;
284284
double mMaxVol;
285+
string mVolatilityType;
285286
double mDisplacement;
286287

287288
double mReturnValue;
@@ -298,6 +299,7 @@ class CapFloorImpliedVolatilityWorker : public Nan::AsyncWorker {
298299
,ObjectHandler::property_t MaxIter
299300
,double MinVol
300301
,double MaxVol
302+
,string VolatilityType
301303
,double Displacement
302304
):
303305
Nan::AsyncWorker(callback)
@@ -309,6 +311,7 @@ class CapFloorImpliedVolatilityWorker : public Nan::AsyncWorker {
309311
,mMaxIter(MaxIter)
310312
,mMinVol(MinVol)
311313
,mMaxVol(MaxVol)
314+
,mVolatilityType(VolatilityType)
312315
,mDisplacement(Displacement)
313316
{
314317

0 commit comments

Comments
 (0)