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 details
|
||||
type Option struct {
|
||||
OptType int64
|
||||
Strike float64
|
||||
@@ -39,11 +38,9 @@ func gbmSimulation(spot float64, rfr float64, vol float64, tte float64, randNum
|
||||
return spot * math.Exp(drift+stoch)
|
||||
}
|
||||
|
||||
// runSimulations is the main function that runs Monte Carlo simulations
|
||||
// for an option. Note that it runs normal Geometric Brownian Motion
|
||||
// to calculate the future spot levels
|
||||
func runSimulations(opt *Option) {
|
||||
|
||||
// PriceMonteCarlo is the exported method to run the simulations and value
|
||||
// a vanilla option using Monte Carlo methods
|
||||
func (opt *Option) PriceMonteCarlo() {
|
||||
var i int64
|
||||
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)
|
||||
}
|
||||
|
||||
// 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