Cleanup and function simplification
This commit is contained in:
14
models.go
14
models.go
@@ -7,7 +7,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Option struct that holds all the details of an option
|
// Option struct that holds all the details of an option
|
||||||
// Option details
|
|
||||||
type Option struct {
|
type Option struct {
|
||||||
OptType int64
|
OptType int64
|
||||||
Strike float64
|
Strike float64
|
||||||
@@ -39,11 +38,9 @@ func gbmSimulation(spot float64, rfr float64, vol float64, tte float64, randNum
|
|||||||
return spot * math.Exp(drift+stoch)
|
return spot * math.Exp(drift+stoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runSimulations is the main function that runs Monte Carlo simulations
|
// PriceMonteCarlo is the exported method to run the simulations and value
|
||||||
// for an option. Note that it runs normal Geometric Brownian Motion
|
// a vanilla option using Monte Carlo methods
|
||||||
// to calculate the future spot levels
|
func (opt *Option) PriceMonteCarlo() {
|
||||||
func runSimulations(opt *Option) {
|
|
||||||
|
|
||||||
var i int64
|
var i int64
|
||||||
var level float64
|
var level float64
|
||||||
|
|
||||||
@@ -89,8 +86,3 @@ func runSimulations(opt *Option) {
|
|||||||
opt.Rho = (opt.Rho/float64(opt.Sims)*math.Exp(-(opt.Rfr+0.01)*tte) - opt.FV)
|
opt.Rho = (opt.Rho/float64(opt.Sims)*math.Exp(-(opt.Rfr+0.01)*tte) - opt.FV)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PriceMonteCarlo is the exported method to run the simulations and value
|
|
||||||
// a vanilla option using Monte Carlo methods
|
|
||||||
func (opt *Option) PriceMonteCarlo() {
|
|
||||||
runSimulations(opt)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user