Skip to content

Commit fc2577a

Browse files
author
Jin
committed
build for 1.9
1 parent f6398d5 commit fc2577a

7 files changed

Lines changed: 51 additions & 15 deletions

File tree

‎README.md‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## QuantLib Async Bindings for Node.js [![npm version](https://badge.fury.io/js/quantlib.svg)](http://badge.fury.io/js/quantlib) [![Twitter Follow](https://img.shields.io/twitter/follow/quantlibnode.svg?style=social&maxAge=3600)](https://twitter.com/quantlibnode)
1+
## QuantLib Async Bindings for Node.js
2+
3+
[![NPM](https://nodei.co/npm/quantlib.png?downloads=true&downloadRank=true)](https://nodei.co/npm/quantlib/)
4+
5+
[![npm version](https://badge.fury.io/js/quantlib.svg)](http://badge.fury.io/js/quantlib)
6+
[![Twitter Follow](https://img.shields.io/twitter/follow/quantlibnode.svg?style=social&maxAge=3600)](https://twitter.com/quantlibnode)
27

38
This [open source project](https://github.com/quantlibnode/quantlibnode) brings [QuantLib](http://quantlib.org/) to the Node.js community, it's similar to [QuantLibXL](http://quantlib.org/quantlibxl/) project which is for Microsoft Excel.
49

@@ -13,10 +18,14 @@ All functions in this project are Async, they are exported to [Promise](https://
1318
npm install quantlib
1419
```
1520

16-
* Windows
21+
* Windows (32-bit & 64-bit)
1722

1823
`npm install quantlib` will do everything, including the node package installation and pre-built native addon (no dependency) download, you can start use it right away.
1924

25+
> v0.2.x windows prebuilt on windows 8.1 with VC14
26+
27+
> v0.1.x windows prebuilt on windows 7 with VC12, only 32-bit available
28+
2029
* Linux & Mac
2130

2231
Please refer to [how to build](#building-the-native-addon) below
@@ -34,6 +43,7 @@ Please refer to [how to build](#building-the-native-addon) below
3443
| -------- | ------------- | ------- | ------------- |
3544
| 1.7.1 | 1.7.0 | 6.9.1 | 0.1.x |
3645
| 1.8.1 | 1.8.0 | 6.9.5 | 0.2.x |
46+
| 1.9.2 | 1.9.0 | 6.9.5 | 0.3.x |
3747

3848
## Building the native addon
3949

@@ -46,6 +56,10 @@ Please refer to [how to build](#building-the-native-addon) below
4656
* QuantLib, QuantLibAddin, ObjectHandler source code according to [version matrix](#version-matrix), they need to be put in the same directory
4757
* `boost` - which is required to build QuantLib
4858

59+
> for Mac OS X and Linux, QuantLib projects must be built with `-std=c++11` this flag is required by node
60+
61+
> for linux, need to add `-fPIC` flag
62+
4963
#### Set environment variable
5064

5165
please refer to `cmake/*.cmake` and `CMakeList.txt` files
@@ -65,6 +79,14 @@ please refer to `cmake/*.cmake` and `CMakeList.txt` files
6579

6680
## Example
6781

82+
> This is from QuantLibXL - StandaloneExamples - Math - RankReduction.xlsx - FirstCorrMatrix
83+
84+
> C2 - formulat: =qlSymmetricSchurDecomposition(,B3:K12)
85+
86+
> M3:12 - forumula: {=qlSymmetricSchurDecompositionEigenvalues(C2)}
87+
88+
> the input/output are the same
89+
6890
```js
6991
var ql = require('quantlib');
7092

@@ -82,9 +104,15 @@ var mtx1 =
82104
[0.81880, 0.83520, 0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000]
83105
];
84106

85-
ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){
86-
87-
ql.SymmetricSchurDecompositionEigenvalues(obj).then(function(r){
107+
/*
108+
* call Constructor to create object, objectID needs to be provided as input, this is diffierent with QuantLibXL
109+
* ObjectID, can be generated with Node.js, it needs to be uniquie
110+
* since this is on server side, you may put session# as part of objectID
111+
*/
112+
ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){ //C2 formula: =qlSymmetricSchurDecomposition(,B3:K12)
113+
114+
// call Method with objectID, this is same as QuantLibXL
115+
ql.SymmetricSchurDecompositionEigenvalues(obj).then(function(r){ // M3:12 formula: {=qlSymmetricSchurDecompositionEigenvalues(C2)}
88116
console.log(r);
89117
});
90118

@@ -106,4 +134,4 @@ ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){
106134
0.01580103250921176,
107135
0.01377474504269164,
108136
0.012784934140218302 ]
109-
```
137+
```

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quantlib",
33
"description": "QuantLib Asyn Bindings for Node.js",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"keywords": [
66
"quantlib"
77
],

‎src/capfloor.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ void CapFloorImpliedVolatilityWorker::Execute(){
718718

719719

720720
// invoke the member function
721+
std::map<std::string, QuantLib::VolatilityType> strEnum;
721722
mReturnValue = ObjectIDLibObjPtr->impliedVolatility(
722723
mPrice
723724
,
@@ -733,7 +734,7 @@ void CapFloorImpliedVolatilityWorker::Execute(){
733734
,
734735
mMaxVol
735736
,
736-
mVolatilityType
737+
strEnum[mVolatilityType]
737738
,
738739
mDisplacement
739740
);

‎src/capletvolstructure.cpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ void ConstantOptionletVolatilityWorker::Execute(){
154154
));
155155

156156
// Construct the Object
157+
std::map<std::string, QuantLib::VolatilityType> strEnum;
157158
boost::shared_ptr<ObjectHandler::Object> object(
158159
new QuantLibAddin::ConstantOptionletVolatility(
159160
valueObject,
@@ -162,7 +163,7 @@ void ConstantOptionletVolatilityWorker::Execute(){
162163
BusinessDayConventionEnum,
163164
VolatilityLibObj,
164165
DayCounterEnum,
165-
mVolatilityType,
166+
strEnum[mVolatilityType],
166167
mDisplacement,
167168
false
168169
));
@@ -512,6 +513,7 @@ void StrippedOptionletWorker::Execute(){
512513
));
513514

514515
// Construct the Object
516+
std::map<std::string, QuantLib::VolatilityType> strEnum;
515517
boost::shared_ptr<ObjectHandler::Object> object(
516518
new QuantLibAddin::StrippedOptionlet(
517519
valueObject,
@@ -523,7 +525,7 @@ void StrippedOptionletWorker::Execute(){
523525
mStrikes,
524526
VolatilitiesLibObj,
525527
DayCounterEnum,
526-
mVolatilityType,
528+
strEnum[mVolatilityType],
527529
mDisplacement,
528530
false
529531
));
@@ -717,6 +719,7 @@ void OptionletStripper1Worker::Execute(){
717719
));
718720

719721
// Construct the Object
722+
std::map<std::string, QuantLib::VolatilityType> strEnum;
720723
boost::shared_ptr<ObjectHandler::Object> object(
721724
new QuantLibAddin::OptionletStripper1(
722725
valueObject,
@@ -725,7 +728,7 @@ void OptionletStripper1Worker::Execute(){
725728
mSwitchStrike,
726729
mAccuracy,
727730
MaxIterLib,
728-
mVolatilityType,
731+
strEnum[mVolatilityType],
729732
mDisplacement,
730733
false
731734
));

‎src/piecewiseyieldcurve.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ void PiecewiseYieldCurveMixedInterpolationWorker::Execute(){
285285
));
286286

287287
// Construct the Object
288+
std::map<std::string, QuantLib::MixedInterpolation::Behavior> strEnum;
288289
boost::shared_ptr<ObjectHandler::Object> object(
289290
new QuantLibAddin::PiecewiseYieldCurve(
290291
valueObject,
@@ -297,7 +298,7 @@ void PiecewiseYieldCurveMixedInterpolationWorker::Execute(){
297298
mAccuracy,
298299
mTraitsID,
299300
mInterpolatorID,
300-
mMixedInterpolationBehavior,
301+
strEnum[mMixedInterpolationBehavior],
301302
PillarsBeforeChangeLib,
302303
false
303304
));

‎src/smilesection.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void FlatSmileSectionWorker::Execute(){
6060
));
6161

6262
// Construct the Object
63+
std::map<std::string, QuantLib::VolatilityType> strEnum;
6364
boost::shared_ptr<ObjectHandler::Object> object(
6465
new QuantLibAddin::FlatSmileSection(
6566
valueObject,
@@ -68,7 +69,7 @@ void FlatSmileSectionWorker::Execute(){
6869
DayCounterEnum,
6970
RefDateLib,
7071
mAtmValue,
71-
mVolatilityType,
72+
strEnum[mVolatilityType],
7273
mDisplacement,
7374
false
7475
));
@@ -989,6 +990,7 @@ void InterpolatedSmileSectionWorker::Execute(){
989990
));
990991

991992
// Construct the Object
993+
std::map<std::string, QuantLib::VolatilityType> strEnum;
992994
boost::shared_ptr<ObjectHandler::Object> object(
993995
new QuantLibAddin::InterpolatedSmileSection(
994996
valueObject,
@@ -997,7 +999,7 @@ void InterpolatedSmileSectionWorker::Execute(){
997999
StdDevsLibObj,
9981000
AtmLevelLibObj,
9991001
DayCounterEnum,
1000-
mVolatilityType,
1002+
strEnum[mVolatilityType],
10011003
mDisplacement,
10021004
false
10031005
));

‎src/termstructures.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ void InterpolatedYieldCurveWorker::Execute(){
868868
));
869869

870870
// Construct the Object
871+
std::map<std::string, QuantLib::MixedInterpolation::Behavior> strEnum;
871872
boost::shared_ptr<ObjectHandler::Object> object(
872873
new QuantLibAddin::InterpolatedYieldCurve(
873874
valueObject,
@@ -879,7 +880,7 @@ void InterpolatedYieldCurveWorker::Execute(){
879880
JumpDatesLib,
880881
mTraitsID,
881882
mInterpolatorID,
882-
mMixedInterpolationBehavior,
883+
strEnum[mMixedInterpolationBehavior],
883884
NRateHelperLib,
884885
false
885886
));

0 commit comments

Comments
 (0)