Valuacin de opciones por Balck, Scholes y Merton, griegas etc

dev-master 2020-01-04 09:54 UTC

This package is auto-updated.

Last update: 2024-05-06 19:49:59 UTC


README

Version Total Downloads License

A simple way to get options primes, greeks and implied volatility using Black&Scholes valuation model.

Installation

$ composer require "gauss314/bsm"

Usage

For Laravel 5, Symfony and any PHP project and framework with a composer.json file

<?php

// Instance Object
$bsm = new \gauss314\bsm\Bsm();

// Parameters
$spot=100;
$strike=100;
$free_risk=0.018;     //free risk rate 1=100%
$time=30/365;         //time year fraction 1=1yr
$sigma=0.2;           //Annualized volatility 1=100%
$mkt_value=2;         //Option market value, its only necessary for implied volatility calc
$dividend_yield=0;    //not required, default value = 0

/*
**********************************************
          GET Call prime, and greeks
**********************************************
*/
$call = $bsm->bsCall($spot, $strike, $free_risk, $time, $sigma, $dividend_yield);
/*
    Array
    (
        [call] => 2.3601461764389
        [delta] => 0.52172023548133
        [gamma] => 0.069473882914289
        [vega] => 0.11420364314678
        [theta] => -0.040524357193283
        [rho] => 0.040941269072625
    )
*/



/*
**********************************************
          GET Put prime, and greeks
**********************************************
*/
$put = $bsm->bsPut($spot, $strike, $free_risk, $time, $sigma, $dividend_yield);
/*
    Array
    (
      [put] => 2.2123103559286
      [delta] => -0.47827976451867
      [gamma] => 0.069473882914289
      [vega] => 0.11420364314678
      [theta] => -0.035600140877582
      [rho] => -0.041129002855723
    )
*/

/*
**********************************************
            GET Implied volatility
**********************************************
*/

$iv = $bsm->ivCall($spot, $strike, $free_risk, $tiempo, $mkt_value);  // 16.84647

//Use ivPut() method to get implied volatility from put contract.

Configuration

It doesnt need any configuration line

Enjoy it! ❤️


Reference


License

MIT