Giter Site home page Giter Site logo

kelvinni / quant-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joastbg/quant-js

0.0 1.0 0.0 2.51 MB

Easy to use quantitative finance workbench for JavaScript, combining Google V8 and QuantLib

Makefile 0.32% C++ 96.18% C 0.85% JavaScript 2.63% Shell 0.02%

quant-js's Introduction

About Quant-JS

What is Quant-JS

Quant-JS is an easy to use quantitative finance workbench for JavaScript, combining Google V8 and QuantLib.

Will price options (European, Bermudan and American) using the following methods, where they apply:

  • Black-Scholes
  • Heston semi-analytic
  • Bates semi-analytic
  • Barone-Adesi/Whaley
  • Bjerksund/Stensland
  • Integral
  • Finite differences
  • Binomial Jarrow-Rudd
  • Binomial Cox-Ross-Rubinstein
  • Additive equiprobabilities
  • Binomial Trigeorgis
  • Binomial Tian
  • Binomial Leisen-Reimer
  • Binomial Joshi
  • MC (crude)
  • QMC (Sobol)
  • MC (Longstaff Schwartz)

Getting started

You need the following to be able to compile quant-js (yum package names):

  • QuantLib (QuantLib-devel)
  • Boost libraries (boost-devel)
  • Google V8 (v8-devel)
  • Optional: rlwrap (wrapper for readline)

Build binary:

$ make

Run quantjs:

$ rlwrap -p'1;33' -m ./quantjs --infiles quantjs.js

Example features:

qjs> var pricingEngine = new PricingEngine(0) // BS
qjs> var europeanOption = new EuropeanOption()
qjs> europeanOption.setParams(new OptionParams('PUT', 36, 40, 0.5, 0.00, 0.06, 0.20))
qjs> var t = pricingEngine.calculateNPV(europeanOption)
qjs> t
	3.8094

qjs> var m1 = ident(5)
qjs> m1
	[0]	1 0 0 0 0 
	[1]	0 1 0 0 0 
	[2]	0 0 1 0 0 
	[3]	0 0 0 1 0 
	[4]	0 0 0 0 1 
qjs> numeric.det(m1)
	1.0000
	
qjs> var v = _.range(10).map(function(n) { return n; });
qjs> v
	[0]	0
	[1]	1
	[2]	2
	[3]	3
	[4]	4
	[5]	5
	[6]	6
	[7]	7
	[8]	8
	[9]	9

The file quantjs.js is a JavaScript library to hide some implementation details and open for use of other JavaScript libraries as well.

Here's a fully-functional example of how to valuate three different put options using Quant-JS:

// Calculation date is today's date
var pricingEngine = new PricingEngine(2); // Binomial Trigeorgis

// Params: optionType, underlyingPrice, strikePrice, timeToMaturity, dividendYield, riskFreeRate, volatility

var europeanOption = new EuropeanOption();
europeanOption.setParams(new OptionParams('PUT', 36, 40, 0.5, 0.00, 0.06, 0.20));
pricingEngine.calculateNPV(europeanOption); // 3.843556981971868

var americanOption = new AmericanOption();
americanOption.setParams(new OptionParams('PUT', 36, 40, 0.5, 0.00, 0.06, 0.20));
pricingEngine.calculateNPV(americanOption); // 4.486461065154719

var bermudanOption = new BermudanOption();
bermudanOption.setParams(new OptionParams('PUT', 36, 40, 0.5, 0.00, 0.06, 0.20));
pricingEngine.calculateNPV(bermudanOption); // 4.360909275428335

Project status

The project is still in early Alpha stage, so there is a lot of missing functionality.

License and copyright

Quant-JS is copyrighted free software made available under the terms of either the GNU General Public Licence (GPL).

Copyright: (C) 2012-13 by Johan Astborg. All Rights Reserved.

quant-js's People

Contributors

joastbg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.