-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsge_run_lob.py
95 lines (85 loc) · 2.72 KB
/
sge_run_lob.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
"""
Script to run LOB implementation on a cluster
managed by Sun Grid Engine using Python bindings for DRMAA.
"""
import drmaa
import glob
import os
import os.path
# List of the 50 firms with the highest average daily volume of trade:
firm_name_list = ['TATAPOWER',
'IFCI',
'SUZLON',
'RCOM',
'JPASSOCIAT',
'UNITECH',
'HDIL',
'GVKPIL',
'LITL',
'RENUKA',
'TATAMOTORS',
'DLF',
'GMRINFRA',
'ALOKTEXT',
'HINDALCO',
'IVRCLINFRA',
'STER',
'IDFC',
'BHEL',
'NIFTY',
'MTNL',
'RPOWER',
'NHPC',
'PANTALOONR',
'IBREALEST',
'APOLLOTYRE',
'TATASTEEL',
'PUNJLLOYD',
'BHARTIARTL',
'SAIL',
'DENABANK',
'JISLJALEQS',
'ITC',
'SINTEX',
'ASHOKLEY',
'DISHTV',
'PFC',
'JSWENERGY',
'CAIRN',
'SESAGOA',
'KTKBANK',
'RELCAPITAL',
'IRB',
'N',
'RELIANCE',
'ICICIBANK',
'JINDALSTEL',
'IDBI',
'YESBANK',
'AUROPHARMA',
'TATAPOWER']
def main():
# Base directory containing orders_* subdirectories with securities order
# data:
home_dir = os.path.expanduser('~')
base_dir = home_dir + '/nseindia_lob'
# Subdirectory in which output data should be written:
output_dir = os.path.join(base_dir, 'output')
# Location of LOB implementation:
lob_app = os.path.join(base_dir, 'lob.py')
# Set the PATH accordingly if using a virtualenv:
s = drmaa.Session()
s.initialize()
jt = s.createJobTemplate()
jt.remoteCommand = 'python'
jt.nativeSpecification = '-q all.q -l virtual_free=2000000000,h_vmem=2000000000,h_stack=67208864 -v PATH=$PATH:%s/PYTHON/bin' % home_dir
for firm_name in firm_name_list:
file_name_list = sorted(glob.glob(os.path.join(base_dir, 'orders_*', '%s-orders.csv.gz' % firm_name)))
jt.jobName = firm_name
print 'submitted job: ' + jt.jobName
jt.args = [lob_app, firm_name, output_dir] + file_name_list
jid = s.runJob(jt)
s.exit()
if __name__ == '__main__':
main()