Skip to content

Commit

Permalink
correct dt value
Browse files Browse the repository at this point in the history
  • Loading branch information
virgesmith committed Nov 20, 2020
1 parent 2098f52 commit 518b9e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/option/black_scholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ def checkpoint(self):
# !checkpoint!

def simulate(self):
# get the time from the environment
dt = self.timeline().time()
# get the single timestep from the timeline
dt = self.timeline().dt()
normals = nstream(self.mc().ustream(self.nsims))

# compute underlying prices at dt
# compute underlying prices at t=dt
S = self.market["spot"]
r = self.market["rate"]
q = self.market["divy"]
sigma = self.market["vol"]
underlyings = S * np.exp((r - q - 0.5 * sigma * sigma) * dt + normals * sigma * sqrt(dt))
# compute option prices at dt
# compute option prices at t=dt
if self.option["callput"] == "CALL":
fv = (underlyings - self.option["strike"]).clip(min=0.0).mean()
else:
Expand Down

0 comments on commit 518b9e8

Please sign in to comment.