kyos/options-calculator

A collection of methods to calculate option prices, greeks & implied volatilities

1.0.2 2024-02-02 14:27 UTC

This package is auto-updated.

Last update: 2024-11-05 11:34:25 UTC


README

banner

Option Valuation Calculator

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A collection of methods to calculate option prices, greeks & implied volatilities.

Range of supported products:

  • European options on futures, using the Black'76 methodology.

Range of supported methodologies to derive implied volatilities:

  • Bisection search algorithm.

Installation

You can install the package via composer:

composer require kyos/options-calculator

Usage

use Kyos\OptionsCalculator\Black76;

$bs = new Black76();
echo $bs->getValues(Black76::CALL, 10.5, 12, 0.082, 0.60);
// [
//     'value' => 0.2405826183655344,
//     'delta' => 0.24449431791580983,
//     'gamma' => 0.17399585222314845,
//     'vega' => 0.009438057012140243,
//     'theta' => -3.450541861184725,
//     'rho' => -0.00019727774705973822,
// ]

echo $bs->getValues(Black76::PUT, 10.5, 12, 0.082, 0.60);
// [
//     'value' => 1.7393531225277215,
//     'delta' => -0.7546860181923143,
//     'gamma' => 0.17399585222314845,
//     'vega' => 0.009438057012140243,
//     'theta' => -3.435554156143103,
//     'rho' => -0.0014262695604727318,
// ]

echo $bs->getImpliedVolatility(Black76::CALL, 10.5, 12, 0.082, 0.2405826183655344);
// 0.60
echo $bs->getImpliedVolatility(Black76::PUT, 10.5, 12, 0.082, 1.7393531225277215);
// 0.60

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.