npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

future-options-bs

v1.0.2

Published

Calculate options prices, greeks and volatilities

Downloads

8

Readme

Options calculation over future contracts based on Black-Scholes-Merton model

This Module calculate price, implied volatility, and greeks of options over futures based on Black-Scholes-Merton model.

Installation

> npm i future-options-bs

Import

You should import by ES6 modules calling just calling some especific function:

import { callPrice } from "futures-options-bs";
const myCall = callPrice(300, 350, 0.2, 0.55, 0.05);

or the hole as an object:

import option from "futures-options-bs";
const myCall = option.callPrice(300, 350, 0.2, 0.55, 0.05);

Functions contained in this module

  • callPrice(fut, sp, vol, t, r, decimal) Returns CALL price
  • putPrice(fut, sp, vol, t, r, decimal) Returns PUT price
  • deltaCall(fut,sp,vol,t,r) Returns Delta of a CALL
  • deltaPut(fut,sp,vol,t,r) Returns Delta of a PUT
  • gamma(fut,sp,vol,t,r) Returns Gamma of both types
  • vega(fut,sp,vol,t,r) Returns Vega of both types
  • thetaCall(fut,sp,vol,t,r,days) Returns Theta of a CALL
  • thetaPut(fut,sp,vol,t,r,days) Returns Theta of a PUT
  • impliedVolat(type,prime,fut,sp,t,r,error) Returns an implied volatility of an option

Variables used in functions

  • fut - price of an underlying future contract
  • sp - strike price
  • vol - annual volatility
  • t - time as a proportion of a year
  • r - anual interest rate, 0 by default
  • decimal - optional parameter - number of decimals tu return, 2 by default
  • days - number of days per year, 365 by default
  • type - "CALL" or "PUT"
  • error - optional parameter - Desired error as a proportion of the prime 0.02 by default

Notes

Calculate of probabilities are made by an aproximation function method, but its error its quite small. The statistics functions are in a separate module for future improvements or changes in javascript functions that currently do not support these statistical functions.

These functions does not validate variables types, so inputs of string instead of number will result in a NaN or undefined output.