From f88ac4c3e168b9d140fa1d0146756cc1964190aa Mon Sep 17 00:00:00 2001 From: Jerry Jin Date: Thu, 16 Feb 2017 12:32:58 +0800 Subject: [PATCH 1/2] add new functions from 1.8 --- README.md | 2 +- package.json | 2 +- quantlibnode.cpp | 5 +++++ quantlibnode.hpp | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4dda56..1c94d56 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Quantlib and QuantLibAddin must be built first, then build QuantLibNode linking | 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.4 | 0.2.x | ## Example diff --git a/package.json b/package.json index 9491342..5e6a589 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "quantlib", "description": "QuantLib Asyn Bindings for Node.js", - "version": "0.1.5", + "version": "0.2.0", "keywords": [ "quantlib", "native", diff --git a/quantlibnode.cpp b/quantlibnode.cpp index 0d4b537..c4b5d03 100644 --- a/quantlibnode.cpp +++ b/quantlibnode.cpp @@ -1080,6 +1080,11 @@ NAN_MODULE_INIT(init){ Nan::SetMethod(target, "PiecewiseConstantVarianceTotalVariance", QuantLibNode::PiecewiseConstantVarianceTotalVariance); Nan::SetMethod(target, "PiecewiseConstantVarianceTotalVolatility", QuantLibNode::PiecewiseConstantVarianceTotalVolatility); + Nan::SetMethod(target, "PiecewiseYieldCurveMixedInterpolation", QuantLibNode::PiecewiseYieldCurveMixedInterpolation); + Nan::SetMethod(target, "BachelierCapFloorEngine", QuantLibNode::BachelierCapFloorEngine); + Nan::SetMethod(target, "BachelierCapFloorEngine2", QuantLibNode::BachelierCapFloorEngine2); + Nan::SetMethod(target, "BachelierBlackFormulaImpliedVol", QuantLibNode::BachelierBlackFormulaImpliedVol); + Nan::SetMethod(target, "DeleteObject", QuantLibNode::DeleteObject); Nan::SetMethod(target, "DeleteObjects", QuantLibNode::DeleteObjects); Nan::SetMethod(target, "DeleteAllObjects", QuantLibNode::DeleteAllObjects); diff --git a/quantlibnode.hpp b/quantlibnode.hpp index d05eb29..bc97eb2 100644 --- a/quantlibnode.hpp +++ b/quantlibnode.hpp @@ -1127,6 +1127,11 @@ class QuantLibNode : public Nan::ObjectWrap { static NAN_METHOD(PiecewiseConstantVarianceTotalVariance); static NAN_METHOD(PiecewiseConstantVarianceTotalVolatility); + static NAN_METHOD(PiecewiseYieldCurveMixedInterpolation); + static NAN_METHOD(BachelierCapFloorEngine); + static NAN_METHOD(BachelierCapFloorEngine2); + static NAN_METHOD(BachelierBlackFormulaImpliedVol); + static NAN_METHOD(DeleteObject); static NAN_METHOD(DeleteObjects); static NAN_METHOD(DeleteAllObjects); From a14befc83143627767d5ad909ab09f8b41f7ccfb Mon Sep 17 00:00:00 2001 From: Jerry Jin Date: Thu, 16 Feb 2017 17:26:16 +0800 Subject: [PATCH 2/2] update version info --- CMakeLists.txt | 12 ++++++------ LICENSE | 2 +- README.md | 43 ++++++++++++++++++++++++++++++++++++++----- cmake/FindNode.cmake | 2 +- lib/quantlib.js | 11 ++++++++++- package.json | 4 +--- quantlibnode.cpp | 4 ++++ quantlibnode.hpp | 5 +++++ 8 files changed, 66 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cad8d5..31dc831 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,13 +71,13 @@ ENDIF () IF (MSVC_IDE) IF ( CMAKE_CONFIGURATION_TYPES STREQUAL "Debug" ) - TARGET_LINK_LIBRARIES(quantlib QuantLib-vc120-mt-gd.lib) - TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc120-mt-gd-1_7_0.lib) - TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc120-mt-gd-1_7_0.lib) + TARGET_LINK_LIBRARIES(quantlib QuantLib-vc140-mt-gd.lib) + TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc140-mt-gd-1_8_0.lib) + TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc140-mt-gd-1_8_0.lib) ELSE () - TARGET_LINK_LIBRARIES(quantlib QuantLib-vc120-mt-s.lib) - TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc120-mt-s-1_7_0.lib) - TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc120-mt-s-1_7_0.lib) + TARGET_LINK_LIBRARIES(quantlib QuantLib-vc140-mt-s.lib) + TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc140-mt-s-1_8_0.lib) + TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc140-mt-s-1_8_0.lib) ENDIF () ENDIF () diff --git a/LICENSE b/LICENSE index 113256f..23f2727 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Jerry Jin +Copyright (c) 2016 - 2017 Jerry Jin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1c94d56..aae0e55 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -## QuantLib Async Bindings for Node.js [![npm version](https://badge.fury.io/js/quantlib.svg)](http://badge.fury.io/js/quantlib) +## 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) -This project 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. +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. Most functions in QuantLibXL can be used in the similar way in Node on the server side. @@ -13,13 +13,17 @@ All functions in this project are Async, they are exported to [Promise](https:// npm install quantlib ``` -* Windows +* Windows - 32-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. +* Windows - 64-Bit + +I will try to build and upload the pre-built addon, before that, Please refer to [how to build](#building-the-native-addon) below + * Linux & Mac -Quantlib and QuantLibAddin must be built first, then build QuantLibNode linking to them, pre-built native code is not provided for now +Please refer to [how to build](#building-the-native-addon) below ## QuantLib Documents @@ -32,7 +36,36 @@ Quantlib and QuantLibAddin must be built first, then build QuantLibNode linking | QuantLib | QuantLibAddin | Node.js | quantlib.node | | -------- | ------------- | ------- | ------------- | -| 1.8.1 | 1.8.0 | 6.9.4 | 0.2.x | +| 1.7.1 | 1.7.0 | 6.9.1 | 0.1.x | +| 1.8.1 | 1.8.0 | 6.9.5 | 0.2.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](#version-matrix) +* [nan](https://github.com/nodejs/nan) ^2.2.0 +* [node-gyp](https://github.com/nodejs/node-gyp) ~3.0.3 +* QuantLib, QuantLibAddin, ObjectHandler source code according to [version matrix](#version-matrix), they need to be put in the same directory +* `boost` - which is required to build QuantLib + +#### 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](https://github.com/nodejs/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 diff --git a/cmake/FindNode.cmake b/cmake/FindNode.cmake index 5584f51..6ed2ce8 100644 --- a/cmake/FindNode.cmake +++ b/cmake/FindNode.cmake @@ -4,7 +4,7 @@ # NODE_GYP_FOUND - True if node found. # Read environment variables to find node_gyp include/lib directories -SET(NODE_GYP_VER "6.9.1") +SET(NODE_GYP_VER "6.9.5") MESSAGE( STATUS "NODE_GYP_VER: " ${NODE_GYP_VER} ) SET(NODE_GYP_DIR $ENV{NODE_GYP_DIR}/${NODE_GYP_VER}) MESSAGE( STATUS "NODE_GYP_DIR: " ${NODE_GYP_DIR} ) diff --git a/lib/quantlib.js b/lib/quantlib.js index 730a936..f6e0923 100644 --- a/lib/quantlib.js +++ b/lib/quantlib.js @@ -1,4 +1,7 @@ -// This is a generated file, modify: generate/templates/quantlib.js +/* + Copyright (C) 2016 -2017 Jerry Jin +*/ + var promisify = require("promisify-node"); var rawApi = require("../build/Release/quantlib"); @@ -1060,6 +1063,12 @@ exports.PiecewiseConstantVarianceVariance = promisify(rawApi.PiecewiseConstantVa exports.PiecewiseConstantVarianceVolatility = promisify(rawApi.PiecewiseConstantVarianceVolatility); exports.PiecewiseConstantVarianceTotalVariance = promisify(rawApi.PiecewiseConstantVarianceTotalVariance); exports.PiecewiseConstantVarianceTotalVolatility = promisify(rawApi.PiecewiseConstantVarianceTotalVolatility); + +exports.PiecewiseYieldCurveMixedInterpolation = promisify(PiecewiseYieldCurveMixedInterpolation); +exports.BachelierCapFloorEngine = promisify(BachelierCapFloorEngine); +exports.BachelierCapFloorEngine2 = promisify(BachelierCapFloorEngine2); +exports.BachelierBlackFormulaImpliedVol = promisify(BachelierBlackFormulaImpliedVol); + exports.ObjectPropertyNames = promisify(rawApi.ObjectPropertyNames); exports.DeleteObject = promisify(rawApi.DeleteObject); exports.DeleteObjects = promisify(rawApi.DeleteObjects); diff --git a/package.json b/package.json index 5e6a589..be2fe52 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,7 @@ "description": "QuantLib Asyn Bindings for Node.js", "version": "0.2.0", "keywords": [ - "quantlib", - "native", - "addon" + "quantlib" ], "main": "lib/quantlib.js", "repository": { diff --git a/quantlibnode.cpp b/quantlibnode.cpp index c4b5d03..c9d223c 100644 --- a/quantlibnode.cpp +++ b/quantlibnode.cpp @@ -1,3 +1,7 @@ +/* + Copyright (C) 2016 -2017 Jerry Jin +*/ + #include #include #include diff --git a/quantlibnode.hpp b/quantlibnode.hpp index bc97eb2..f6c0c32 100644 --- a/quantlibnode.hpp +++ b/quantlibnode.hpp @@ -1,3 +1,8 @@ +/* + Copyright (C) 2016 -2017 Jerry Jin +*/ + + #ifndef quantlibnode_hpp #define quantlibnode_hpp