GithubHelp home page GithubHelp logo

fireinjava / greeks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattl922/greeks

0.0 1.0 0.0 204 KB

Calculations of option greeks - delta, gamma, theta, vega, rho

License: MIT License

JavaScript 100.00%

greeks's Introduction

greeks

Calculations of option greeks - delta, gamma, theta, vega, rho

Common parameters

  • s - Current price of the underlying
  • k - Strike price
  • t - Time to expiration in years
  • v - Volatility as a decimal
  • r - Annual risk-free interest rate as a decimal
  • callPut - The type of option to be priced - "call" or "put"
  • [scale] - The value to scale a return value by

Usage

var greeks = require("greeks");

// Delta

greeks.getDelta(100, 100, .086, .1, .0015, "call"); // 0.5076040742445566
greeks.getDelta(100, 100, .086, .1, .0015, "put"); // -0.49239592575544344

// Gamma - call and put gammas are equal at a given strike

greeks.getGamma(206.35, 206, .086, .1, .0015); // 0.06573105549942765

// Vega - call and put vegas are equal at a given strike
// Note: vega is calculated per 1 percentage point change in volatility

greeks.getVega(206.35, 206, .086, .1, .0015); // 0.24070106056306836

// Theta - the default scale is 365 (days per year)

greeks.getTheta(206.35, 206, .086, .1, .0015, "call"); // -0.03877971361524501
greeks.getTheta(206.35, 206, .086, .1, .0015, "put"); // -0.0379332474739548

// or you can set the scale to a value like 252 (trading days per year)

greeks.getTheta(206.35, 206, .086, .1, .0015, "call", 252); // -0.05616902964112869
greeks.getTheta(206.35, 206, .086, .1, .0015, "put", 252); // -0.054942997333307556

// Rho - the default scale is 100 (rho per 1%, or 100BP, change in the risk-free interest rate)

greeks.getRho(206.35, 206, .086, .1, .0015, "call"); // 0.09193271711465777
greeks.getRho(206.35, 206, .086, .1, .0015, "put"); // -0.08520443071933861

// or you can set the scale to a value like 10000 (rho per .01%, or 1BP, change in the risk-free interest rate)

greeks.getRho(206.35, 206, .086, .1, .0015, "call", 10000); // 0.0009193271711465777
greeks.getRho(206.35, 206, .086, .1, .0015, "put", 10000); // -0.0008520443071933862

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.