Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build for 1.8 #3

Merged
merged 2 commits into from Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions CMakeLists.txt
Expand Up @@ -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 ()

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
41 changes: 37 additions & 4 deletions 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.

Expand All @@ -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
Expand All @@ -33,6 +37,35 @@ 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.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

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindNode.cmake
Expand Up @@ -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} )
Expand Down
11 changes: 10 additions & 1 deletion 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");
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions package.json
@@ -1,11 +1,9 @@
{
"name": "quantlib",
"description": "QuantLib Asyn Bindings for Node.js",
"version": "0.1.5",
"version": "0.2.0",
"keywords": [
"quantlib",
"native",
"addon"
"quantlib"
],
"main": "lib/quantlib.js",
"repository": {
Expand Down
9 changes: 9 additions & 0 deletions quantlibnode.cpp
@@ -1,3 +1,7 @@
/*
Copyright (C) 2016 -2017 Jerry Jin
*/

#include <v8.h>
#include <node.h>
#include <nan.h>
Expand Down Expand Up @@ -1080,6 +1084,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);
Expand Down
10 changes: 10 additions & 0 deletions quantlibnode.hpp
@@ -1,3 +1,8 @@
/*
Copyright (C) 2016 -2017 Jerry Jin
*/


#ifndef quantlibnode_hpp
#define quantlibnode_hpp

Expand Down Expand Up @@ -1127,6 +1132,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);
Expand Down