5.1 tushare包介绍

 

 
股票分析
tushare
http://tushare.org/

安装
pip install Tushare
In [1]:
import tushare as ts
In [5]:
ts.get_k_data("601390")  # 中国中铁
Out[5]:
 
 dateopenclosehighlowvolumecode
0 2017-03-31 8.776 8.590 8.815 8.551 857620.0 601390
1 2017-04-05 8.766 8.971 9.058 8.707 2164944.0 601390
2 2017-04-06 9.049 9.448 9.721 8.932 3078158.0 601390
3 2017-04-07 9.439 9.312 9.439 9.185 2070300.0 601390
4 2017-04-10 9.331 9.312 9.517 9.205 1814621.0 601390
... ... ... ... ... ... ... ...
635 2020-03-02 5.430 5.910 5.910 5.420 3217750.0 601390
636 2020-03-03 6.080 5.860 6.080 5.790 2689631.0 601390
637 2020-03-04 5.810 5.950 6.050 5.770 1745901.0 601390
638 2020-03-05 6.000 5.930 6.050 5.880 1353211.0 601390
639 2020-03-06 5.850 5.760 5.930 5.740 1211796.0 601390

640 rows × 7 columns

In [4]:
ts.get_k_data("601318")
Out[4]:
 
 dateopenclosehighlowvolumecode
0 2017-07-20 51.560 52.003 52.138 50.857 659198.0 601318
1 2017-07-21 51.223 50.029 51.300 49.971 1294791.0 601318
2 2017-07-24 50.145 50.655 51.127 49.760 904595.0 601318
3 2017-07-25 50.665 50.366 51.079 50.241 506834.0 601318
4 2017-07-26 50.164 49.962 50.549 49.374 657610.0 601318
... ... ... ... ... ... ... ...
635 2020-03-02 78.320 79.580 80.200 78.320 712323.0 601318
636 2020-03-03 80.480 79.490 80.570 79.260 678238.0 601318
637 2020-03-04 79.900 80.580 80.750 79.900 677574.0 601318
638 2020-03-05 81.010 82.450 82.760 80.620 960642.0 601318
639 2020-03-06 81.570 80.910 81.920 80.800 584186.0 601318

640 rows × 7 columns

 

3xLam4.png

In [7]:
df = ts.get_k_data("000016",index=True)
df
Out[7]:
 
 dateopenclosehighlowvolumecode
0 2017-07-20 2653.38 2665.45 2666.04 2643.64 37580733.0 sh000016
1 2017-07-21 2655.23 2639.21 2661.48 2635.00 29715562.0 sh000016
2 2017-07-24 2636.55 2654.38 2666.65 2632.76 33056566.0 sh000016
3 2017-07-25 2656.48 2643.07 2667.79 2639.61 34185413.0 sh000016
4 2017-07-26 2642.26 2636.20 2665.15 2617.55 35447256.0 sh000016
... ... ... ... ... ... ... ...
635 2020-03-02 2837.77 2907.89 2922.95 2837.77 54884776.0 sh000016
636 2020-03-03 2941.68 2921.44 2948.55 2910.76 53161398.0 sh000016
637 2020-03-04 2921.07 2947.57 2949.57 2919.37 42569549.0 sh000016
638 2020-03-05 2966.69 3018.07 3023.12 2956.65 60497966.0 sh000016
639 2020-03-06 2989.76 2964.83 2999.49 2962.40 41855288.0 sh000016

640 rows × 7 columns

In [9]:
ts.get_k_data("601390",start='2019-01-01')
Out[9]:
 
 dateopenclosehighlowvolumecode
0 2019-01-02 7.00 6.87 7.04 6.80 370089.0 601390
1 2019-01-03 6.88 6.92 6.94 6.84 325933.0 601390
2 2019-01-04 6.86 7.01 7.02 6.85 405116.0 601390
3 2019-01-07 7.05 7.04 7.13 7.01 457590.0 601390
4 2019-01-08 7.04 7.05 7.10 7.03 223430.0 601390
... ... ... ... ... ... ... ...
280 2020-03-02 5.43 5.91 5.91 5.42 3217750.0 601390
281 2020-03-03 6.08 5.86 6.08 5.79 2689631.0 601390
282 2020-03-04 5.81 5.95 6.05 5.77 1745901.0 601390
283 2020-03-05 6.00 5.93 6.05 5.88 1353211.0 601390
284 2020-03-06 5.85 5.76 5.93 5.74 1211796.0 601390

285 rows × 7 columns

 

3xO5b4.png

 

3xO75R.png

posted @ 2020-03-08 18:01  前海渔文乐  阅读(193)  评论(0编辑  收藏  举报