This open source project brings QuantLib to the Node.js community, it's similar to QuantLibXL project which is for Microsoft Excel.
Most functions in QuantLibXL can be used in the similar way in Node on the server side.
All functions in this project are Async, they are exported to Promise sytle function, please see Example below.
npm install quantlib- Windows
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.
- Linux & Mac
Please refer to how to build below
| QuantLib | QuantLibAddin | Node.js | quantlib.node |
|---|---|---|---|
| 1.7.1 | 1.7.0 | 6.9.1 | 0.1.x |
| 1.8.1 | 1.8.0 | 6.9.5 | 0.2.x |
- CMake 2.8 or above, Visual C++ for windows, Xcode for Mac, GCC for Linux
- Node.js according to version matrix
- nan ^2.2.0
- node-gyp ~3.0.3
- QuantLib, QuantLibAddin, ObjectHandler source code according to version matrix, they need to be put in the same directory
boost- which is required to build QuantLib
please refer to cmake/*.cmake and CMakeList.txt files
NAN_DIR- location ofnanNODE_GYP_DIR- location of.node-gypgenerated bynode-gyptool, which is at~/.node-gyp, if it doesn't exist, follow the instruction in node-gyp, and build a helloword program, it will generate the.node-gypdirectoryQUANTLIB_ROOT- location of QuantLib, QuantLibAddin, ObjectHandler source codeBOOST_ROOT- locationboostinstalled
- Build QuantLib and QuantLibAddin, please check
CMakeList.txtfor library name, and make sure generated library names are the same inCMakeList.txt - from
quantlibnoderoot directorycd build cmake ..for Windows and Linux,cmake -G Xcode ..for Mac OS Xcmake --build . --config Release- For Linux, you may need to put
quantlib.nodeunderbuild/Releasemanually,
- CMake 2.8 or above, Visual C++ for windows, Xcode for Mac, GCC for Linux
- Node.js according to version matrix
- nan ^2.2.0
- node-gyp ~3.0.3
- QuantLib, QuantLibAddin, ObjectHandler source code according to version matrix, they need to be put in the same directory
boost- which is required to build QuantLib
please refer to cmake/*.cmake and CMakeList.txt files
NAN_DIR- location ofnanNODE_GYP_DIR- location of.node-gypgenerated bynode-gyptool, which is at~/.node-gyp, if it doesn't exist, follow the instruction in node-gyp, and build a helloword program, it will generate the.node-gypdirectoryQUANTLIB_ROOT- location of QuantLib, QuantLibAddin, ObjectHandler source codeBOOST_ROOT- locationboostinstalled
- Build QuantLib and QuantLibAddin, please check
CMakeList.txtfor library name, and make sure generated library names are the same inCMakeList.txt - from
quantlibnoderoot directorycd build cmake ..for Windows and Linux,cmake -G Xcode ..for Mac OS Xcmake --build . --config Release- For Linux, you may need to put
quantlib.nodeunderbuild/Releasemanually,
var ql = require('quantlib');
var mtx1 =
[
[1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230, 0.83520, 0.81880],
[0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230, 0.83520],
[0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230],
[0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040],
[0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940],
[0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940],
[0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040],
[0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240],
[0.83520, 0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560],
[0.81880, 0.83520, 0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000]
];
ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){
ql.SymmetricSchurDecompositionEigenvalues(obj).then(function(r){
console.log(r);
});
}).catch(function(e){
console.log(e);
});>
[ 9.270906840163782,
0.4207173234885105,
0.12674770658244172,
0.059239731356788505,
0.03595303870722261,
0.024956978505270924,
0.019117669503864024,
0.01580103250921176,
0.01377474504269164,
0.012784934140218302 ]