Skip to content

Commit 900ccbf

Browse files
committed
Initial Commit
1 parent 0f23ef4 commit 900ccbf

File tree

142 files changed

+139100
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+139100
-1
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
################################################
2+
# Miscellaneous
3+
#
4+
# Common files generated by text editors,
5+
# operating systems, file systems, etc.
6+
################################################
7+
*~
8+
*#
9+
.DS_STORE
10+
.netbeans
11+
nbproject
12+
.idea
13+
14+
################################################
15+
# C/C++ stuff
16+
#
17+
################################################
18+
*.o
19+
*.a
20+
*.exe
21+
*.gcda
22+
*.gcno
23+
*.gcov
24+
*.sln
25+
*.suo
26+
*.vc*proj*
27+
*.sdf
28+
*.opensdf
29+
*.aps
30+
*~
31+
mkmf.log
32+
*.js

.npmignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
*#
2+
node_modules
3+
ssl
4+
.DS_STORE
5+
*.swo
6+
*.swp
7+
*.swn
8+
*.swm
9+
*~
10+
.idea
11+
nbproject
12+
.git
13+
build
14+
cmake
15+
.gitignore
16+
.travis.yml
17+
appveyor.yml
18+
CMakeLists.txt
19+
bower.json
20+
*.o
21+
*.a
22+
*.exe
23+
*.gcda
24+
*.gcno
25+
*.gcov
26+
*.sln
27+
*.suo
28+
*.vc*proj*
29+
*.sdf
30+
*.opensdf
31+
*.aps
32+
mkmf.log

CMakeLists.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# CMake build script for QuantLibNode
2+
3+
PROJECT(QuantLibNode)
4+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
5+
6+
# For non-IDE build only
7+
SET(CMAKE_BUILD_TYPE "Release")
8+
9+
# Set build directory
10+
SET(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
11+
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
12+
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
13+
14+
IF (MSVC_IDE)
15+
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /INCREMENTAL:NO /MT")
16+
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /INCREMENTAL:NO /MTd")
17+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
18+
ELSE ()
19+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
20+
ENDIF ()
21+
22+
# dynamic lookup
23+
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
24+
SET (CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
25+
ENDIF()
26+
27+
FIND_PACKAGE(Boost)
28+
29+
# Load/Find CMake Modules
30+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
31+
INCLUDE(FindNode)
32+
INCLUDE(FindQuantLib)
33+
34+
# Add include/link directories
35+
36+
INCLUDE_DIRECTORIES(${NODE_GYP_DIR}/include/node)
37+
INCLUDE_DIRECTORIES(${NAN_DIR})
38+
39+
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
40+
41+
IF (MSVC_IDE)
42+
INCLUDE_DIRECTORIES(${QUANTLIB_DIR}/QuantLib)
43+
INCLUDE_DIRECTORIES(${QUANTLIB_DIR}/ObjectHandler)
44+
INCLUDE_DIRECTORIES(${QUANTLIB_DIR}/QuantLibAddin)
45+
ELSE ()
46+
INCLUDE_DIRECTORIES(${QUANTLIB_DIR}/include)
47+
ENDIF ()
48+
49+
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
50+
51+
IF (MSVC_IDE)
52+
LINK_DIRECTORIES(${QUANTLIB_DIR}/QuantLib/lib)
53+
LINK_DIRECTORIES(${QUANTLIB_DIR}/QuantLibAddin/lib)
54+
LINK_DIRECTORIES(${QUANTLIB_DIR}/ObjectHandler/lib)
55+
ELSE ()
56+
LINK_DIRECTORIES(${QUANTLIB_DIR}/lib)
57+
ENDIF ()
58+
59+
FILE(GLOB SRC_QUANTLIBNODE *.hpp *.cpp src/*.hpp src/*.cpp)
60+
IF (MSVC_IDE)
61+
SET_SOURCE_FILES_PROPERTIES(${SRC_QUANTLIBNODE} PROPERTIES COMPILE_FLAGS -Od)
62+
ENDIF ()
63+
ADD_LIBRARY(quantlib SHARED ${SRC_QUANTLIBNODE})
64+
IF (MSVC_IDE)
65+
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
66+
TARGET_LINK_LIBRARIES(quantlib ${NODE_GYP_DIR}/x64/node.lib)
67+
ELSE ()
68+
TARGET_LINK_LIBRARIES(quantlib ${NODE_GYP_DIR}/ia32/node.lib)
69+
ENDIF()
70+
ENDIF ()
71+
72+
IF (MSVC_IDE)
73+
IF ( CMAKE_CONFIGURATION_TYPES STREQUAL "Debug" )
74+
TARGET_LINK_LIBRARIES(quantlib QuantLib-vc120-mt-gd.lib)
75+
TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc120-mt-gd-1_7_0.lib)
76+
TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc120-mt-gd-1_7_0.lib)
77+
ELSE ()
78+
TARGET_LINK_LIBRARIES(quantlib QuantLib-vc120-mt-s.lib)
79+
TARGET_LINK_LIBRARIES(quantlib QuantLibObjects-vc120-mt-s-1_7_0.lib)
80+
TARGET_LINK_LIBRARIES(quantlib ObjectHandler-vc120-mt-s-1_7_0.lib)
81+
ENDIF ()
82+
ENDIF ()
83+
84+
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
85+
TARGET_LINK_LIBRARIES(quantlib QuantLib.a)
86+
TARGET_LINK_LIBRARIES(quantlib QuantLibAddin.a)
87+
TARGET_LINK_LIBRARIES(quantlib ObjectHandler.a)
88+
ENDIF()
89+
90+
SET_TARGET_PROPERTIES(quantlib PROPERTIES SUFFIX ".node")
91+
SET_TARGET_PROPERTIES(quantlib PROPERTIES PREFIX "")

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 quantlibnode
3+
Copyright (c) 2016 Jerry Jin
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
QuantLib [![npm version](https://badge.fury.io/js/quantlib.svg)](http://badge.fury.io/js/quantlib)
2+
========
3+
4+
QuantLib ASYNC Bindings for Node.js
5+
6+
Usage
7+
-----
8+
9+
```sh
10+
npm install quantlib
11+
```
12+
13+
Example
14+
-------
15+
16+
```js
17+
var ql = require('quantlib');
18+
19+
var mtx1 =
20+
[
21+
[1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230, 0.83520, 0.81880],
22+
[0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230, 0.83520],
23+
[0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040, 0.85230],
24+
[0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940, 0.87040],
25+
[0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940, 0.88940],
26+
[0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040, 0.90940],
27+
[0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240, 0.93040],
28+
[0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560, 0.95240],
29+
[0.83520, 0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000, 0.97560],
30+
[0.81880, 0.83520, 0.85230, 0.87040, 0.88940, 0.90940, 0.93040, 0.95240, 0.97560, 1.00000]
31+
];
32+
33+
ql.SymmetricSchurDecomposition('mtx#1',mtx1).then(function(obj){
34+
35+
ql.SymmetricSchurDecompositionEigenvalues(obj).then(function(r){
36+
console.log(r);
37+
});
38+
39+
ql.SymmetricSchurDecompositionEigenvectors(obj).then(function(r){
40+
console.log(r);
41+
});
42+
43+
}).catch(function(e){
44+
console.log(e);
45+
});
46+
47+
```

build/Release/.gitkeep

Whitespace-only changes.

cmake/FindNode.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# NODE_GYP_DIR - where to find node.h, etc.
2+
# NODE_GYP_VER - version of node
3+
# NAN_DIR - nan module
4+
# NODE_GYP_FOUND - True if node found.
5+
6+
# Read environment variables to find node_gyp include/lib directories
7+
SET(NODE_GYP_VER "4.4.5")
8+
MESSAGE( STATUS "NODE_GYP_VER: " ${NODE_GYP_VER} )
9+
SET(NODE_GYP_DIR $ENV{NODE_GYP_DIR}/${NODE_GYP_VER})
10+
MESSAGE( STATUS "NODE_GYP_DIR: " ${NODE_GYP_DIR} )
11+
12+
SET(NAN_DIR $ENV{NAN_DIR})
13+
MESSAGE( STATUS "NAN_DIR: " ${NAN_DIR} )
14+
15+
FIND_PATH(NODE_GYP_DIR installVersion)
16+
17+
INCLUDE(FindPackageHandleStandardArgs)
18+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NODE DEFAULT_MSG NODE_GYP_DIR NAN_DIR)
19+
20+
MARK_AS_ADVANCED(NODE_GYP_DIR NAN_DIR)

cmake/FindQuantLib.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# QUANTLIB_DIR - where to find quantlib.hpp, etc.
2+
# QUANTLIB_FOUND - True if QuantLib found.
3+
4+
# Read environment variables to find node_gyp include/lib directories
5+
SET(QUANTLIB_DIR $ENV{QUANTLIB_ROOT})
6+
MESSAGE( STATUS "QUANTLIB_DIR: " ${QUANTLIB_DIR} )
7+
8+
FIND_PATH(QUANTLIB_DIR QuantLib)
9+
10+
INCLUDE(FindPackageHandleStandardArgs)
11+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(QUANTLIB DEFAULT_MSG QUANTLIB_DIR)
12+
13+
MARK_AS_ADVANCED(QUANTLIB_DIR)

loop.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef ohn_loop_hpp
2+
#define ohn_loop_hpp
3+
4+
namespace ObjectHandler {
5+
6+
//! Invoke the contained function once for each item in the input vector.
7+
template<class LoopFunction, class InputType, class OutputType>
8+
void loop(
9+
LoopFunction &loopFunction,
10+
std::vector<InputType> &xIn,
11+
std::vector<OutputType> &xOut) {
12+
for (unsigned int i = 0; i < xIn.size(); i++) {
13+
xOut.push_back(loopFunction(xIn[i]));
14+
}
15+
}
16+
17+
template<class LoopFunction, class InputType>
18+
void loop(
19+
LoopFunction &loopFunction,
20+
std::vector<InputType> &xIn) {
21+
for (unsigned int i = 0; i < xIn.size(); i++) {
22+
loopFunction(xIn[i]);
23+
}
24+
}
25+
}
26+
27+
#endif

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "quantlib",
3+
"description": "QuantLib Asyn Bindings for Node.js",
4+
"version": "0.1.0",
5+
"keywords": [
6+
"QuantLib",
7+
"native"
8+
],
9+
"main": "lib/quantlib.js",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/quantlibnode/quantlibnode.git"
13+
},
14+
"directories": {
15+
"build": "./build",
16+
"lib": "./lib"
17+
},
18+
"engines": {
19+
"node": ">= 0.12"
20+
},
21+
"bundledDependencies": [
22+
"node-pre-gyp"
23+
],
24+
"dependencies": {
25+
"fs-extra": "~0.26.2",
26+
"node-pre-gyp": "~0.6.15",
27+
"promisify-node": "~0.3.0"
28+
},
29+
"devDependencies": {
30+
"nan": "^2.2.0",
31+
"node-gyp": "~3.0.3"
32+
},
33+
"binary": {
34+
"module_name": "quantlib",
35+
"module_path": "./build/Release/quantlib.node",
36+
"host": "https://github.com",
37+
"package_name": "{platform}-{arch}.tar.gz",
38+
"remote_path": "./quantlibnode/quantlibnode/releases/download/v{version}/"
39+
},
40+
"scripts": {
41+
"generateJson": "node generate/scripts/json",
42+
"generateNativeCode": "node generate/scripts/native"
43+
},
44+
"bugs": {
45+
"url": "http://github.com/quantlibnode/quantlibnode/issues"
46+
},
47+
"author": "Jerry Jin",
48+
"license": "MIT"
49+
}

0 commit comments

Comments
 (0)