Fix some of the calculations for the Greeks

This commit is contained in:
Kevin
2017-09-17 21:47:37 -04:00
parent af10d6e9db
commit a80e891037

View File

@@ -60,7 +60,9 @@ func (opt *Option) PriceMonteCarlo() {
// Gamma -- TODO: Doesn't look right // Gamma -- TODO: Doesn't look right
level = gbmSimulation(opt.Spot+0.0001, opt.Rfr, opt.Vol, tte, randNum) 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) 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) 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)
@@ -72,8 +74,8 @@ func (opt *Option) PriceMonteCarlo() {
level = gbmSimulation(opt.Spot, opt.Rfr, opt.Vol, tte-1./365, randNum) level = gbmSimulation(opt.Spot, opt.Rfr, opt.Vol, tte-1./365, randNum)
opt.Theta += math.Max((level-opt.Strike)*float64(opt.OptType), 0) opt.Theta += math.Max((level-opt.Strike)*float64(opt.OptType), 0)
// Rho -- TODO: Doesn't look right // Rho
level = gbmSimulation(opt.Spot, opt.Rfr+0.0001, opt.Vol, tte, randNum) level = gbmSimulation(opt.Spot, opt.Rfr+0.01, opt.Vol, tte, randNum)
opt.Rho += math.Max((level-opt.Strike)*float64(opt.OptType), 0) opt.Rho += math.Max((level-opt.Strike)*float64(opt.OptType), 0)
} }
@@ -103,12 +105,11 @@ func (opt *Option) PriceClosedForm() {
if opt.OptType == -1 { if opt.OptType == -1 {
opt.Delta -= 1 opt.Delta -= 1
} }
opt.Gamma = 1 / (opt.Vol * math.Sqrt(tte) * math.Sqrt(2*math.Pi)) * opt.Gamma = 1 / (opt.Spot * opt.Vol * math.Sqrt(tte)) * NormCDF(d1)
math.Exp(-d1*d1/2)
opt.Vega = opt.Spot / 100 * math.Pow(tte, 0.5) * NormPDF(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) * opt.Rho = float64(opt.OptType) * tte * opt.Strike * math.Exp(-opt.Rfr*tte) *
NormCDF(float64(opt.OptType)*d2) / 100 NormCDF(float64(opt.OptType)*d2) / 100
opt.Theta = -float64(opt.OptType)*(opt.Rfr*opt.Strike*math.Exp(-opt.Rfr*tte)* 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) opt.Spot*NormPDF(float64(opt.OptType)*d1)
} }