Fix some of the calculations for the Greeks
This commit is contained in:
13
models.go
13
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user