-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRollingScenarios.gms
58 lines (39 loc) · 1.5 KB
/
RollingScenarios.gms
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
*****Scenario Generation by Bootstrapping*****
SETS
Date 'Dates'
Asset 'Assets'
Periods 'Amount of 4-week intervals' /p0*p49/
Weeks 'Weeks for bootstrapping' /w1*w4/
Scenarios 'Scenarios for bootstrapping' /s1*s250/
;
ALIAS(Date,t);
ALIAS(Asset,i);
ALIAS(Periods,p);
ALIAS(Weeks,w);
ALIAS(Scenarios,s);
PARAMETER
Return 'Return of index i at date t.'
ScenarioReturnPW(i, s, w, p) 'Return of index i, at date t, in week w, in scenariointerval p'
ScenarioReturnP(i,s,p) 'Return of index i, at date t, in scenariointerval p'
;
SCALARS
RandomNumber 'A random number for bootstrapping';
*Loading date, asset and ETF returns data from "out-ETFRet.gdx"
$GDXIN out-ETFRet
$LOAD Date,Asset,Return
$GDXIN
*Setting for generating random numbers
execseed = gmillisec(jnow);
*Generating 250 scenarios in 49 period-intervals.
LOOP(p,
LOOP(s,
LOOP(w,
RandomNumber = uniformint(1+4*ORD(p)-4,97+4*ORD(p)-4);
ScenarioReturnPW(i,s,w,p) = SUM(t$(ORD(t)=RandomNumber), Return(t,i) );
);
ScenarioReturnP(i,s,p) = PROD(W, (1+ScenarioReturnPW(i,s,w,p)))-1;
);
);
DISPLAY ScenarioReturnP;
*Export to GDX-file
EXECUTE_UNLOAD 'RollingScenarios150.gdx' ScenarioReturnP, Asset, Scenarios, Periods;