-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscripty.py
More file actions
38 lines (26 loc) · 854 Bytes
/
scripty.py
File metadata and controls
38 lines (26 loc) · 854 Bytes
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
import ts_api_demo as ts
from WindPy import w
import os
w.start()
from datetime import datetime
dt = datetime.now()
if dt.hour < 16:
date_before = w.tdaysoffset(-1, dt).Data[0][0]
date_before = ''.join(str(date_before).split(' ')[0].split('-'))
dt = date_before
path = 'E:\minute_bar'
filename_list = os.listdir(path)
date_list = map(lambda x:x.split('.')[0], filename_list)
begin_date = date_list[-1]
tradedate = w.tdays(begin_date, dt).Data[0]
tradedate = map(lambda x:''.join(str(x).split(' ')[0].split('-')), tradedate)
print tradedate
for date in tradedate[1:]:
try:
df = ts.get_minute_bar(int(date))
df['secid'] = df['secid'].apply(lambda x: x[2:]+'.'+x[:2])
df.to_hdf(os.path.join(path, '%s.h5' % date), 'table')
print df
print date
except Exception as e:
continue