Hi,

In this post, I would like to present you the “Option Pricing n Greeks” in Jedox.

Well continuing on my previous post, I would like to highlight the potential of Jedox in terms of number crunching capacity, where I have designed the macro for option pricing most commonly used in any front desk team of an investment bank.

For all the background about options derivatives used in the financial industry and the measures (the Greeks) incorporated in this model references are as below:

http://www.investopedia.com/university/options/

http://www.investopedia.com/university/option-greeks/

http://en.wikipedia.org/wiki/Option_(finance)

http://en.wikipedia.org/wiki/Greeks_(finance)

This model in Jedox computes the option prices and its greeks based on the user inputs and as the benefits of Jedox come along together the possibilities are enormous.

Code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | function dOne($S, $X, $T, $r, $v, $d){ $n1 = application()->Log($S / $X); $n2 = ($r - $d + 0.5 * pow($v , 2)) * $T; $d1 = $v * pow($T,2); $value = ($n1 + $n2) / $d1; return $value; } function NdOne($S, $X, $T, $r, $v, $d){ $nd = dOne($S, $X, $T, $r, $v, $d); $n1 = -1* (pow($nd , 2) / 2); $d1 = application()->sqrt(2 * application()->Pi()); $value = application()->Exp($n1) / $d1 ; return $value; } function dTwo($S, $X, $T, $r, $v, $d){ $value = dOne($S, $X, $T, $r, $v, $d) - $v * application()->sqrt($T); return $value; } function NdTwo($S, $X, $T, $r, $v, $d){ $value = application()->NormSDist(dTwo($S, $X, $T, $r, $v, $d)); return $value; } function OptionPrice($OptionType, $S, $X, $T, $r, $v, $d) { if($OptionType == 'C'){ $value = application()->Exp(-$d * $T) * $S * application()->NormSDist(dOne($S, $X, $T, $r, $v, $d)) - $X * application()->Exp(-$r * $T) * application()->NormSDist(dOne($S, $X, $T, $r, $v, $d) - $v * applica tion()->sqrt($T)); } elseif ($OptionType == 'P'){ $m1 = application()->Exp(-1*$r * $T); $m2 = application()->NormSDist(-1 * dTwo($S, $X, $T, $r, $v, $d)); $m3 = application()->Exp(-1 * $d * $T); $m4 = application()->NormSDist(-1 * dOne($S, $X, $T, $r, $v, $d)); $s1 = $X * $m1 * $m2; $s2 = $S * $m3 * $m4; $value = $s1-$s2; } return $value; } function OptionDelta($OptionType, $S, $X, $T, $r, $v, $d){ if($OptionType == 'C') { $value = application()->NormSDist(dOne($S, $X, $T, $r, $v, $d)); }elseif ($OptionType == 'P'){ $value = application()->NormSDist(dOne($S, $X, $T, $r, $v, $d)) - 1; } return $value; } function Gamma($S, $X, $T, $r, $v, $d){ $value = NdOne($S, $X, $T, $r, $v, $d) / ($S * ($v * application()->sqrt($T))); return $value; } function Vega($S, $X, $T, $r, $v, $d){ $value = 0.01 * $S * application()->sqrt($T) * NdOne($S, $X, $T, $r, $v, $d); return $value; } function OptionRho($OptionType, $S, $X, $T, $r, $v, $d){ if($OptionType == 'C'){ $value = 0.01 * $X * $T * Exp(-1 * $r * $T) * application()->NormSDist(dTwo($S, $X, $T, $r, $v, $d)); }elseif ($OptionType == 'P'){ $value = -0.01 * $X * $T * Exp(-1*$r * $T) * (1 - application()->NormSDist(dTwo($S, $X, $T, $r, $v, $d))); } return $value; } function OptionTheta($OptionType, $S, $X, $T, $r, $v, $d){ if($OptionType == 'C'){ $value = -(($S * $v * NdOne($S, $X, $T, $r, $v, $d)) / (2 * application()->sqrt($T)) - $r * $X * Exp(-1 * $r * ($T)) * NdTwo($S, $X, $T, $r, $v, $d)) / 365; }elseif ($OptionType == 'P'){ $value = -(($S * $v * NdOne($S, $X, $T, $r, $v, $d)) / (2 * application()->sqrt($T)) + $r * $X * Exp(-1 * $r * ($T)) * (1 - NdTwo($S, $X, $T, $r, $v, $d))) / 365; } return $value; } |

Hope you like it.

Enjoy !!!

**Downloads:**

http://amolpandey.com/home/downloads/blog34_download.zip

Refrence: http://www.amolpandey.com/2014/11/11/option-pricing-and-greeks-jedox/