-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simdiff.py
72 lines (61 loc) · 1.62 KB
/
simdiff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import numpy as np
import os
from esgtoolkit import simdiff, simshocks
from time import time
print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")
kappa = 1.5
V0 = theta = 0.04
sigma_v = 0.2
theta1 = kappa * theta
theta2 = kappa
theta3 = sigma_v
# OU
print("1 - Ornstein-Uhlenbeck process: ----------------- \n")
start = time()
sims = simdiff(
n=1000,
horizon=5,
frequency="quarterly",
model="OU",
x0=V0,
theta1=theta1,
theta2=theta2,
theta3=theta3,
)
print(f"Time taken: {time() - start}")
print(sims)
# GBM
print("2 - Geometric Brownian Motion: ----------------- \n")
start = time()
sims = simdiff(
n=100,
horizon=5,
frequency="semi-annual",
model="GBM",
x0=V0,
theta1=theta1,
theta2=theta2,
theta3=theta3,
)
print(f"Time taken: {time() - start}")
print(sims)
# GBM2
print("3 - Geometric Brownian Motion with input shock: ----------------- \n")
start = time()
eps0 = simshocks(n = 100, horizon = 5, frequency = "quarterly")
sim_GBM = simdiff(n = 100, horizon = 5, frequency = "quarterly",
model = "GBM",
x0 = 100, theta1 = 0.03, theta2 = 0.1,
eps = eps0)
print(f"Time taken: {time() - start}")
print(sim_GBM)
# GBM3
print("4 - Geometric Brownian Motion with input shock 2: ----------------- \n")
start = time()
eps0 = simshocks(n = 100, horizon = 5, frequency = "quarterly", seed=13)
sim_GBM = simdiff(n = 100, horizon = 5, frequency = "quarterly",
model = "GBM",
x0 = 100, theta1 = 0.03, theta2 = 0.1,
eps = eps0)
print(f"Time taken: {time() - start}")
print(sim_GBM)