options-math

European option prices and Greeks under Black-Scholes. That is the whole library.

Spot, strike, time to maturity, rate and volatility in. Price, delta, gamma, vega, theta and rho out, as plain doubles. Profit at expiry for a bought or sold position. No dividend yield, no American exercise, no volatility surface.

View on GitHub Maven Central


Try it

import com.druvu.options.math.OptionSide;
import com.druvu.options.math.price.OptionPriceMath;
import com.druvu.options.math.price.OptionPriceRequest;

// Parameters: side, spotPrice, strike, yearsToMaturity, riskFreeInterest, volatility
OptionPriceRequest callRequest = new OptionPriceRequest(
    OptionSide.CALL,
    300,    // spot price
    250,    // strike
    1,      // 1 year to maturity
    0.05,   // 5% risk-free rate
    0.15    // 15% volatility
);

double callPrice = OptionPriceMath.price(callRequest);  // 63.24

OptionPriceRequest putRequest = new OptionPriceRequest(OptionSide.PUT, 300, 250, 1, 0.05, 0.15);
double putPrice = OptionPriceMath.price(putRequest);    // 1.05

The Greeks, from the same request:

import com.druvu.options.math.price.OptionGreeks;

OptionGreeks greeks = OptionPriceMath.greeks(callRequest);

greeks.price();  // 63.24 - theoretical option price
greeks.delta();  // 0.948 - rate of change of price with respect to underlying
greeks.gamma();  // 0.002 - rate of change of delta
greeks.vega();   // sensitivity to volatility
greeks.theta();  // time decay
greeks.rho();    // 221.10 - sensitivity to interest rate

Profit at expiry:

import com.druvu.options.math.profit.MarketSide;
import com.druvu.options.math.profit.OptionProfitMath;
import com.druvu.options.math.profit.OptionProfitRequest;

// Bought 10 call options at strike 250, paid $5 premium each
OptionProfitRequest profitRequest = new OptionProfitRequest(
    OptionSide.CALL,
    MarketSide.BUY,
    250,    // strike
    5,      // premium paid
    10      // number of options
);

double profit = OptionProfitMath.profit(profitRequest, 280);  // spot at expiry = 280
// Profit = (280 - 250 - 5) * 10 = 250

Install

On Maven Central. Java 17 or newer.

<dependency>
    <groupId>com.druvu</groupId>
    <artifactId>options-math</artifactId>
    <version>1.0.1</version>
</dependency>
implementation 'com.druvu:options-math:1.0.1'

Something it almost does?

Open an issue, or write to me. If it is small and useful to more than you, I will often just build it.

Apache License 2.0.


Back to top

Copyright © 2026 druvu.com. All rights reserved.

This site uses Just the Docs, a documentation theme for Jekyll.