-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_share.py
29 lines (26 loc) · 1 KB
/
new_share.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
#!/usb/bin/python
#-*- coding:utf-8 -*-
from sqlalchemy import create_engine
import tushare as ts
import datetime
import time
def save_new_share(start_date, end_date):
'''
获取新股上市列表数据
:return:
'''
engine = create_engine('mysql+pymysql://root:root@localhost:3306/stock_quant?charset=utf8')
ts.set_token('428031aafb294e841ad21237fca19c91d0483e83435294728abcffeb')
pro = ts.pro_api()
# 获取多个公司高管全部数据
df = pro.new_share(start_date=start_date, end_date=end_date)
df.to_sql('new_share', engine, index=True)
if __name__ == "__main__":
start = datetime.datetime.now()
start_year = int(time.strftime('%Y', time.localtime(time.time()))) - 3
start_date = '{}{}'.format(start_year, '0101')
end_year = time.strftime('%Y', time.localtime(time.time()))
end_date = '{}{}'.format(end_year, '1231')
save_new_share(start_date, end_date)
end = datetime.datetime.now()
print('Running time: %s Seconds' % (end - start))