From a80e891037b5d03be85b39194b03c001b40fbc99 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 17 Sep 2017 21:47:37 -0400 Subject: [PATCH] Fix some of the calculations for the Greeks --- models.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/models.go b/models.go index 602e837..42b6924 100644 --- a/models.go +++ b/models.go @@ -60,9 +60,11 @@ func (opt *Option) PriceMonteCarlo() { // Gamma -- TODO: Doesn't look right level = gbmSimulation(opt.Spot+0.0001, opt.Rfr, opt.Vol, tte, randNum) + opt.Gamma += math.Max((level - opt.Strike) * float64(opt.OptType), 0) level += gbmSimulation(opt.Spot-0.0001, opt.Rfr, opt.Vol, tte, randNum) + opt.Gamma += math.Max((level - opt.Strike) * float64(opt.OptType), 0) level -= 2 * gbmSimulation(opt.Spot, opt.Rfr, opt.Vol, tte, randNum) - opt.Gamma += math.Max((level-opt.Strike)*float64(opt.OptType), 0) + opt.Gamma += math.Max((level - opt.Strike) * float64(opt.OptType), 0) // Vega level = gbmSimulation(opt.Spot, opt.Rfr, opt.Vol+0.0001, tte, randNum) @@ -72,8 +74,8 @@ func (opt *Option) PriceMonteCarlo() { level = gbmSimulation(opt.Spot, opt.Rfr, opt.Vol, tte-1./365, randNum) opt.Theta += math.Max((level-opt.Strike)*float64(opt.OptType), 0) - // Rho -- TODO: Doesn't look right - level = gbmSimulation(opt.Spot, opt.Rfr+0.0001, opt.Vol, tte, randNum) + // Rho + level = gbmSimulation(opt.Spot, opt.Rfr+0.01, opt.Vol, tte, randNum) opt.Rho += math.Max((level-opt.Strike)*float64(opt.OptType), 0) } @@ -103,12 +105,11 @@ func (opt *Option) PriceClosedForm() { if opt.OptType == -1 { opt.Delta -= 1 } - opt.Gamma = 1 / (opt.Vol * math.Sqrt(tte) * math.Sqrt(2*math.Pi)) * - math.Exp(-d1*d1/2) + opt.Gamma = 1 / (opt.Spot * opt.Vol * math.Sqrt(tte)) * NormCDF(d1) opt.Vega = opt.Spot / 100 * math.Pow(tte, 0.5) * NormPDF(d1) opt.Rho = float64(opt.OptType) * tte * opt.Strike * math.Exp(-opt.Rfr*tte) * NormCDF(float64(opt.OptType)*d2) / 100 opt.Theta = -float64(opt.OptType)*(opt.Rfr*opt.Strike*math.Exp(-opt.Rfr*tte)* - NormCDF(float64(opt.OptType)*d1)) - (opt.Vol/2*math.Pow(tte, 0.5))* + NormCDF(float64(opt.OptType)*d2)) - (opt.Vol/2*math.Sqrt(tte))* opt.Spot*NormPDF(float64(opt.OptType)*d1) }