/
get_stock_by_tushare.py
57 lines (41 loc) · 1.59 KB
/
get_stock_by_tushare.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
#!/usr/bin/python
# coding: UTF-8
"""This script parse stock info"""
import matplotlib.pyplot as plt
import tushare as ts
def get_all_price(code_list):
'''''process all stock'''
df = ts.get_realtime_quotes(STOCK)
print df
df = ts.get_latest_news()
print df
df = ts.get_cpi()
print df
df =ts.get_stock_basics()
print df
df = ts.get_sz50s()
print df
df = ts.get_hist_data('600848')
print df
if __name__ == '__main__':
STOCK = ['600219', ##南山铝业
'000002', ##万 科A
'000623', ##吉林敖东
'000725', ##京东方A
'600036', ##招商银行
'601166', ##兴业银行
'600298', ##安琪酵母
'600881', ##亚泰集团
'002582', ##好想你
'600750', ##江中药业
'601088', ##中国神华
'000338', ##潍柴动力
'000895', ##双汇发展
'000792'] ##盐湖股份
#get_all_price(STOCK)
data_frame = ts.get_hist_data('300104',start='2015-01-01',end='2016-08-01')
for index, row in data_frame.iterrows():
# 这里修改为组装SQL并执行的语句
print index,row
data_frame['close'].plot(legend=True, figsize=(10,4))
plt.show()