Skip to content

Commit 31f44cf

Browse files
authored
Merge pull request #130 from PyFE/heston-mc
OUSV updates
2 parents 279310d + 573d2b0 commit 31f44cf

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

pyfeng/data/ousv_benchmark.xlsx

272 Bytes
Binary file not shown.

pyfeng/heston_mc.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,6 @@ def vol_paths(self, tobs):
253253

254254
return var_path
255255

256-
def cond_states_old(self, var_0, texp):
257-
258-
tobs = self.tobs(texp)
259-
n_dt = len(tobs)
260-
var_paths = self.vol_paths(tobs)
261-
var_final = var_paths[-1, :]
262-
var_avg = spint.simps(var_paths, dx=1, axis=0) / n_dt
263-
264-
return var_final, var_avg
265-
266256
def cond_states(self, var_0, texp):
267257

268258
tobs = self.tobs(texp)

pyfeng/ousv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ def cond_states_step(self, vol_0, dt, zn=None):
457457

458458
if self.antithetic:
459459
n_path_half = int(n_path//2)
460-
z_sin = self.rng_spawn[2].standard_normal(size=(n_sin, n_path_half))
460+
z_sin = self.rng_spawn[2].standard_normal(size=(n_path_half, n_sin)).T
461461
z_sin = np.stack([z_sin, -z_sin], axis=2).reshape((n_sin, n_path))
462462

463-
z_gpqr = self.rng_spawn[1].standard_normal(size=(4, n_path_half))
464-
z_gpqr = np.stack([z_gpqr, -z_gpqr], axis=2).reshape((4, n_path))
463+
z_gpqr = self.rng_spawn[1].standard_normal(size=(n_path_half, 4)).T
464+
z_gpqr = np.stack([z_gpqr, -z_gpqr], axis=-1).reshape((4, n_path))
465465
else:
466-
z_sin = self.rng_spawn[2].standard_normal(size=(n_sin, n_path))
467-
z_gpqr = self.rng_spawn[1].standard_normal(size=(4, n_path))
466+
z_sin = self.rng_spawn[2].standard_normal(size=(n_path, n_sin)).T
467+
z_gpqr = self.rng_spawn[1].standard_normal(size=(n_path, 4)).T
468468

469469
z_g = z_gpqr[0, :]
470470
z_p = z_gpqr[1, :]

pyfeng/sv_abc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def init_benchmark(cls, set_no=None):
7575
return df_param
7676
else:
7777
df_val = pd.read_excel(file, sheet_name=str(set_no))
78-
param = df_param.loc[set_no]
79-
args_model = {k: param[k] for k in ("sigma", "theta", "vov", "rho", "mr", "intr", "divr")}
80-
args_pricing = {k: param[k] for k in ("texp", "spot")}
78+
param = df_param.loc[set_no].to_dict()
79+
args_model = {k: param[k] for k in param.keys() & {"sigma", "theta", "vov", "rho", "mr", "intr", "divr"}}
80+
args_pricing = {k: param[k] for k in param.keys() & {"texp", "spot"}}
8181

8282
assert df_val.columns[0] == "Strike"
8383
args_pricing["strike"] = df_val.values[:, 0]

0 commit comments

Comments
 (0)