npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quantlib

v0.3.0

Published

QuantLib Asyn Bindings for Node.js

Downloads

102

Readme

QuantLib Async Bindings for Node.js

NPM

npm version Twitter Follow

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.

Getting started

npm install quantlib
  • Windows (32-bit & 64-bit)

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.

v0.2.x windows prebuilt on windows 8.1 with VC14

v0.1.x windows prebuilt on windows 7 with VC12, only 32-bit available

  • Linux & Mac

Please refer to how to build below

QuantLib Documents

Version Matrix

| 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 | | 1.9.2 | 1.9.0 | 6.9.5 | 0.3.x |

Building the native addon

Prerequisite

  • 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

for Mac OS X and Linux, QuantLib projects must be built with -std=c++11 this flag is required by node

for linux, need to add -fPIC flag

Set environment variable

please refer to cmake/*.cmake and CMakeList.txt files

  • NAN_DIR - location of nan
  • NODE_GYP_DIR - location of .node-gyp generated by node-gyp tool, 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-gyp directory
  • QUANTLIB_ROOT - location of QuantLib, QuantLibAddin, ObjectHandler source code
  • BOOST_ROOT - location boost installed

Use cmake to build the addon

  1. Build QuantLib and QuantLibAddin, please check CMakeList.txt for library name, and make sure generated library names are the same in CMakeList.txt
  2. from quantlibnode root directory cd build
  3. cmake .. for Windows and Linux, cmake -G Xcode .. for Mac OS X
  4. cmake --build . --config Release
  5. For Linux, you may need to put quantlib.node under build/Release manually,

Example

This is from QuantLibXL - StandaloneExamples - Math - RankReduction.xlsx - FirstCorrMatrix

C2 - formulat: =qlSymmetricSchurDecomposition(,B3:K12)

M3:12 - forumula: {=qlSymmetricSchurDecompositionEigenvalues(C2)}

the input/output are the same

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]
];

/* 
 * call Constructor to create object, objectID needs to be provided as input, this is diffierent with QuantLibXL
 * ObjectID, can be generated with Node.js, it needs to be uniquie
 * since this is on server side, you may put session# as part of objectID
*/
ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){ //C2 formula: =qlSymmetricSchurDecomposition(,B3:K12)
  
  // call Method with objectID, this is same as QuantLibXL
  ql.SymmetricSchurDecompositionEigenvalues(obj).then(function(r){ // M3:12 formula: {=qlSymmetricSchurDecompositionEigenvalues(C2)}
    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 ]