-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputData.py
More file actions
65 lines (53 loc) · 6.91 KB
/
Copy pathinputData.py
File metadata and controls
65 lines (53 loc) · 6.91 KB
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
import numpy as np
#input data for portfolio optimization, i.e. covariance matrices, average returns and transaction costs
#datasets Test1 and Test3 are purelly fictional, number specify how many time periods is included in the optimization
#actual datasets are based on currency market real data, Actual1 and Actual3 comprises 9 currencies, ActualToy only 3 currencies
def loadData(dataset):
if dataset == 'Test3':
C1 = np.array ([[0.5,0.5,-0.5],[0.5,2,0],[-0.5,0,2.5]])
C2 = np.array ([[0.2,0.5,-0.5],[0.5,4,-0.3],[-0.5,-0.3,7]])
C3 = np.array ([[0.1,0.5,-0.5],[0.5,4,-0.7],[-0.5,-0.7,5]])
V1 = np.array ([[0.1,0,0],[0,0.3,0],[0,0,0.5]])
V2 = np.array ([[0.1,0,0],[0,0.3,0],[0,0,0.6]])
V3 = np.array ([[0.2,0,0],[0,0.2,0],[0,0,0.4]])
r1 = np.array ([1,2,8])
r2 = np.array ([1,4,6])
r3 = np.array ([2,2,-1])
C = [C1, C2, C3]
V = [V1, V2, V3]
r = [r1, r2, r3]
elif dataset == 'Test1':
C1 = np.array([[0.5,0.5,-0.5],[0.5,4,-0.3],[-0.5,-0.3,6]])
V1 = np.zeros( (3,3) )
r1 = np.array([1,2,3])
C = [C1]
V = [V1]
r = [r1]
elif dataset == 'ActualToy':
C1 = np.array([[1.2773, 0.8695, 0.6971],[0.8695, 1.1172, 0.6518],[0.6971, 0.6518, 3.0041]])
V1 = np.zeros( (3,3) )
r1 = np.array([0.8396, 0.8898, 1.4017])
C = [C1/100]
V = [V1]
r = [r1/100]
elif dataset == 'Actual3':
C1 = np.array ([[0.01903818,0.00669664,0.00766054,0.01110857,0.01202774,0.00437826,0.01813046,0.01888374,0.01236974],[0.00669664,0.00477763,0.00356396,0.00447115,0.00541469,0.0034935,0.00740974,0.00665486,0.00533228],[0.00766054,0.00356396,0.01340087,0.00937147,0.00725951,0.00533946,0.00686757,0.00763734,0.00897192],[0.01110857,0.00447115,0.00937147,0.01275794,0.00838604,0.00506371,0.00961787,0.01100613,0.00954129],[0.01202774,0.00541469,0.00725951,0.00838604,0.01291127,0.00457909,0.01215973,0.01198117,0.01006867],[0.00437826,0.0034935,0.00533946,0.00506371,0.00457909,0.00910948,0.0041378,0.00444051,0.0049703],[0.01813046,0.00740974,0.00686757,0.00961787,0.01215973,0.0041378,0.02780546,0.01802722,0.01510912],[0.01888374,0.00665486,0.00763734,0.01100613,0.01198117,0.00444051,0.01802722,0.01914485,0.01246339],[0.01236974,0.00533228,0.00897192,0.00954129,0.01006867,0.0049703,0.01510912,0.01246339,0.03865719]])
C2 = np.array ([[0.01252615,0.0034788,0.00685207,0.0086971,0.00751078,0.00416833,0.01015783,0.01233751,0.00671473],[0.0034788,0.00256386,0.00241266,0.00276204,0.00285422,0.00238464,0.00348276,0.00346161,0.0025636],[0.00685207,0.00241266,0.01277343,0.00869493,0.00629412,0.00418888,0.00620499,0.00711431,0.00697072],[0.0086971,0.00276204,0.00869493,0.01117206,0.00676493,0.00413825,0.00692382,0.00872669,0.00651831],[0.00751078,0.00285422,0.00629412,0.00676493,0.01005057,0.00386501,0.00585318,0.00764644,0.00423652],[0.00416833,0.00238464,0.00418888,0.00413825,0.00386501,0.00691817,0.00372981,0.00423276,0.00353088],[0.01015783,0.00348276,0.00620499,0.00692382,0.00585318,0.00372981,0.01731678,0.01011946,0.00954215],[0.01233751,0.00346161,0.00711431,0.00872669,0.00764644,0.00423276,0.01011946,0.01290346,0.00668162],[0.00671473,0.0025636,0.00697072,0.00651831,0.00423652,0.00353088,0.00954215,0.00668162,0.03004144]])
C3 = np.array ([[0.00957541,0.0044484,0.00296374,0.00540264,0.00401321,0.00240441,0.00718053,0.00810831,0.00394961],[0.0044484,0.00346766,0.00183083,0.0025781,0.00228642,0.00221595,0.00400346,0.00386155,0.00297499],[0.00296374,0.00183083,0.00737167,0.00466241,0.0039709,0.00350515,0.00222771,0.00308442,0.00408306],[0.00540264,0.0025781,0.00466241,0.00700705,0.00387301,0.00293244,0.00334042,0.0048721,0.0028265],[0.00401321,0.00228642,0.0039709,0.00387301,0.0060329,0.00253243,0.00356525,0.00370263,0.00297235],[0.00240441,0.00221595,0.00350515,0.00293244,0.00253243,0.00518958,0.00210631,0.00252544,0.00297537],[0.00718053,0.00400346,0.00222771,0.00334042,0.00356525,0.00210631,0.00859031,0.00633743,0.00541195],[0.00810831,0.00386155,0.00308442,0.0048721,0.00370263,0.00252544,0.00633743,0.00816081,0.00471048],[0.00394961,0.00297499,0.00408306,0.0028265,0.00297235,0.00297537,0.00541195,0.00471048,0.02453451]])
V1 = np.array ([[0.00264338,0,0,0,0,0,0,0,0],[0,0.00271099,0,0,0,0,0,0,0],[0,0,0.00229326,0,0,0,0,0,0],[0,0,0,0.00221687,0,0,0,0,0],[0,0,0,0,0.00210111,0,0,0,0],[0,0,0,0,0,0.00265603,0,0,0],[0,0,0,0,0,0,0.0019618,0,0],[0,0,0,0,0,0,0,0.0023385,0],[0,0,0,0,0,0,0,0,0.00252246]])
V2 = np.array ([[0.00224825,0,0,0,0,0,0,0,0],[0,0.00180113,0,0,0,0,0,0,0],[0,0,0.00309175,0,0,0,0,0,0],[0,0,0,0.00196917,0,0,0,0,0],[0,0,0,0,0.00266142,0,0,0,0],[0,0,0,0,0,0.00194672,0,0,0],[0,0,0,0,0,0,0.0013336,0,0],[0,0,0,0,0,0,0,0.00183715,0],[0,0,0,0,0,0,0,0,0.00167637]])
V3 = np.array ([[0.00334655,0,0,0,0,0,0,0,0],[0,0.00205894,0,0,0,0,0,0,0],[0,0,0.00412254,0,0,0,0,0,0],[0,0,0,0.00338257,0,0,0,0,0],[0,0,0,0,0.00246664,0,0,0,0],[0,0,0,0,0,0.00438154,0,0,0],[0,0,0,0,0,0,0.0029716,0,0],[0,0,0,0,0,0,0,0.0029265,0],[0,0,0,0,0,0,0,0,0.00340942]])
r1 = np.array ([-0.00802969912069083,0.000491607504932068,0.0499897264574572,0.0186540847307143,0.0202120045623188,0.0590153314113404,-0.011032787118299,0.0173227128818372,0.0627776222703613])
r2 = np.array ([0.0612406839230379,0.0175108792609412,0.00839620583613732,0.00889795731916425,0.0250662739464351,0.0138306056967103,0.00743299722364845,0.0535987452142273,0.0140169574613058])
r3 = np.array ([-0.0572443239107255,-0.044992837142234,0.0434325581434029,-0.00251716883304856,-7.52094479015572E-06,-0.0121824708461747,-0.0934997770685352,-0.00635020030634144,0.0402109206361646])
C = [C1, C2, C3]
V = [V1, V2, V3]
r = [r1, r2, r3]
elif dataset == 'Actual1':
C1 = np.array ([[0.01903818,0.00669664,0.00766054,0.01110857,0.01202774,0.00437826,0.01813046,0.01888374,0.01236974],[0.00669664,0.00477763,0.00356396,0.00447115,0.00541469,0.0034935,0.00740974,0.00665486,0.00533228],[0.00766054,0.00356396,0.01340087,0.00937147,0.00725951,0.00533946,0.00686757,0.00763734,0.00897192],[0.01110857,0.00447115,0.00937147,0.01275794,0.00838604,0.00506371,0.00961787,0.01100613,0.00954129],[0.01202774,0.00541469,0.00725951,0.00838604,0.01291127,0.00457909,0.01215973,0.01198117,0.01006867],[0.00437826,0.0034935,0.00533946,0.00506371,0.00457909,0.00910948,0.0041378,0.00444051,0.0049703],[0.01813046,0.00740974,0.00686757,0.00961787,0.01215973,0.0041378,0.02780546,0.01802722,0.01510912],[0.01888374,0.00665486,0.00763734,0.01100613,0.01198117,0.00444051,0.01802722,0.01914485,0.01246339],[0.01236974,0.00533228,0.00897192,0.00954129,0.01006867,0.0049703,0.01510912,0.01246339,0.03865719]])
V1 = np.zeros( (9,9) )
r1 = np.array ([-0.00802969912069083,0.000491607504932068,0.0499897264574572,0.0186540847307143,0.0202120045623188,0.0590153314113404,-0.011032787118299,0.0173227128818372,0.0627776222703613])
C = [C1]
V = [V1]
r = [r1]
return [C, r, V]