GithubHelp home page GithubHelp logo

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

greeks's People

Contributors

mattl922 avatar

Stargazers

Kirill Makukhin avatar vivekdev avatar Roland Schläfli avatar Robert Denus avatar Hard Fault avatar  avatar iam4x avatar Josh Skidmore avatar Jayprakash avatar tonokim avatar bronko avatar look avatar Alessandro Warth avatar Zachary Iles avatar Emanuel Fernandes avatar  avatar Flowerowl avatar Josh Ribakoff avatar Mohamed Shadab avatar Andrey avatar Andrey Chaschev avatar Cross Fire avatar  avatar Christian Portocarrero avatar suhel avatar SP avatar Ian Macalinao avatar John Johnson avatar Anton Cheng avatar Gonzalo Beviglia avatar Shekar Siri avatar Aakash Solanki avatar  avatar Pawan Wagh avatar λFT avatar  avatar gururaja avatar Robert Koeninger avatar  avatar Renan Caldas avatar Github Notification avatar Spicer Matthews avatar Mike Ehrenberg avatar Helly Guo avatar Tomas Trajan avatar worktimepower avatar Sergey Antoninko avatar Brendan Boyd avatar CG avatar  avatar

Watchers

 avatar  avatar  avatar SP avatar

greeks's Issues

What reference to use for risk free interest rate?

Great little library to use.
When calculating delta, there is a r argument required which is labeled as 'Annual risk-free interest rate as a decimal'.
What reference or benchmark or whatever to use to know what this should be for delta?
Should it be the 10-year treasury rate?

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.