PHP code example of kyos / options-calculator

1. Go to this page and download the library: Download kyos/options-calculator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kyos / options-calculator example snippets


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