JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q12739F
  • License MIT

Library for analytical pricings of financial derivatives under (log)normal distribution assumptions

Package Exports

  • gaussian-analytics

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gaussian-analytics) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gaussian-analytics

npm version Build status

JavaScript library for analytical pricings of financial derivatives under (log)normal distribution assumptions.

Usage

Experiment in browser console

As gaussian-analytics.js is published as an ES6 module your have to apply the following trick to play with it in your browser's dev console. First open the dev console (in Firefox press F12) and execute

// dynamically import ES6 module and store it as global variable gauss
import('//unpkg.com/gaussian-analytics').then(m => window.gauss=m);

Afterwards, the global variable gauss will contain the module and you can run call exported functions on it, e.g.

gauss.pdf(0);
// 0.3989422804014327

This should work at least for Firefox and Chrome.

API Documentation

Functions

pdf(x)number

Probability density function (pdf) for a standard normal distribution.

cdf(x)number

Cumulative distribution function (cdf) for a standard normal distribution. Approximation by Zelen, Marvin and Severo, Norman C. (1964), formula 26.2.17.

margrabesFormula(S1, S2, T, sigma1, sigma2, rho, q1, q2)PricingResult

Margrabe's formula for pricing the exchange option between two risky assets.

See William Margrabe, The Value of an Option to Exchange One Asset for Another, Journal of Finance, Vol. 33, No. 1, (March 1978), pp. 177-186.

margrabesFormulaShort(S1, S2, T, sigma, q1, q2)PricingResult

Margrabe's formula for pricing the exchange option between two risky assets. Equivalent to margrabesFormula but accepting only the volatility corresponding to the ratio S1/S2 instead of their individual volatilities.

Typedefs

PricingResult : Object

pdf(x) ⇒ number

Probability density function (pdf) for a standard normal distribution.

Kind: global function
Returns: number - density of standard normal distribution

Param Type Description
x number value for which the density is to be calculated

cdf(x) ⇒ number

Cumulative distribution function (cdf) for a standard normal distribution. Approximation by Zelen, Marvin and Severo, Norman C. (1964), formula 26.2.17.

Kind: global function
Returns: number - cumulative distribution of standard normal distribution

Param Type Description
x number value for which the cumulative distribution is to be calculated

margrabesFormula(S1, S2, T, sigma1, sigma2, rho, q1, q2) ⇒ PricingResult

Margrabe's formula for pricing the exchange option between two risky assets.

See William Margrabe, The Value of an Option to Exchange One Asset for Another, Journal of Finance, Vol. 33, No. 1, (March 1978), pp. 177-186.

Kind: global function

Param Type Description
S1 number spot value of the first asset
S2 number spot value of the second asset
T number time to maturity (typically expressed in years)
sigma1 number volatility of the first asset
sigma2 number volatility of the second asset
rho number correlation of the Brownian motions driving the asset prices
q1 number dividend yield of the first asset
q2 number dividend yield of the second asset

margrabesFormulaShort(S1, S2, T, sigma, q1, q2) ⇒ PricingResult

Margrabe's formula for pricing the exchange option between two risky assets. Equivalent to margrabesFormula but accepting only the volatility corresponding to the ratio S1/S2 instead of their individual volatilities.

Kind: global function
See: margrabesFormula

Param Type Description
S1 number spot value of the first asset
S2 number spot value of the second asset
T number time to maturity (typically expressed in years)
sigma number volatility of the ratio of both assets
q1 number dividend yield of the first asset
q2 number dividend yield of the second asset

PricingResult : Object

Kind: global typedef
Properties

Name Type Description
price number price of the derivative
N_d1 number cumulative probability of d1
N_d2 number cumulative probability of d2
d1 number
d2 number
sigma number pricing volatility

History

0.3.0 (2020-05-10)

0.2.0 (2020-05-09)

  • cdf (cumulative distribution function) for a standard normal distribution
  • test case for relationship between cdf and pdf

0.1.3 (2020-05-09)

  • extract normalizing constant for improved performance
  • test pdf example values
  • set up eslint linting (also on Travis CI)

0.1.2 (2020-05-09)

  • integrate API doc in README
  • API doc in README can automatically be updated by running npm run update-docs
  • set up .npmignore

0.1.1 (2020-05-09)

  • add first tests
  • set up CI infrastructure with Travis CI for testing

0.1.0 (2020-05-09)

  • pdf (probability density function) for a standard normal distribution
  • First release on npm