-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecutor.py
54 lines (45 loc) · 1.62 KB
/
executor.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
import finam_export, emitent_names
import random
from distutils.dir_util import mkpath
# Markets:
# MosBirzha = 1
# MosBirzha top = 200
# ? = 8
# Bonds = 2
# Indexes = 6
# Currencies = 45
# US(BATS) = 25, 517
# bad markets = 91, 519
#
# 'emitents' = [(ticker : market)]
experiment_number = '0'
market = '200'
sample_number = 2
portfolio_size = 2
data_folder = ('/Users/julybelost/Documents/portfolio-fixed-share/' +
'exp{}_market{}/portf_size{}/'.format(experiment_number,
market,
portfolio_size))
download_path = data_folder + 'input/finam_raw/'
mkpath(download_path)
mkpath(data_folder + 'results/plot_data/')
print('result files will be in ' + download_path)
emitent_list = emitent_names.get_market_emitents(market)[1]
# set of portfolios to iterate through looks like:
# portfolios = [
# {'emitents' : [('LKOH', '1'), ('SIBN', '1')]},
# {'emitents' : [('AFLT', '1'), ('BANE', '1')]}
# ]
portfolios = []
for i in range(sample_number):
random_emitent_sample = random.sample(emitent_list, portfolio_size)
random_emitents = [(ticker, market) for ticker in random_emitent_sample]
random_portfolio = {'emitents' : random_emitents}
portfolios.append(random_portfolio)
for p in portfolios:
print(p['emitents'])
finam_export.gather_finam_data(period = finam_export.Period.min,
from_str = '08.01.12',
to_str = '08.07.18',
path = download_path,
**p)