用于从不同来源检索基本中国股票数据的实用程序。

cn_stock_src的Python项目详细描述


https://travis-ci.org/jealous/cn_stock_src.svghttps://coveralls.io/repos/jealous/cn_stock_src/badge.svg

版本:0.1.8

简介

从web界面检索股票数据并保存在pandasDataFrame中。

在Python2.7、3.4、3.5和Pypy上测试。

安装

pip install cn_stock_src

教程

  • 获取股票指数的最新交易数据。

示例:

latest('sh600000','sh600238','sz000001')

输出:

          name   open  close  price   high    low     volume        amount  \
sh600000  浦发银行  13.93  14.22  12.87  13.95  12.80  334859429  4.407389e+09
sh600238  海南椰岛  12.60  12.91  11.62  12.60  11.62   12069736  1.421766e+08
sz000001  平安银行  11.10  11.50  10.35  11.17  10.35  151802968  1.601529e+09

          buy1_volume  buy1_price    ...     sell2_volume  sell2_price  \
sh600000       981800       12.87    ...            71334        12.89
sh600238            0        0.00    ...            12913        11.63
sz000001            0        0.00    ...           284420        10.36

          sell3_volume  sell3_price  sell4_volume  sell4_price  sell5_volume  \
sh600000        241900        12.90        238100        12.91         37500
sh600238          2000        11.65          2300        11.68          9200
sz000001         68739        10.37        212580        10.38         57200

          sell5_price      date      time
sh600000        12.92  20150824  15:03:04
sh600238        11.70  20150824  15:03:04
sz000001        10.39  20150824  15:05:55

[3 rows x 30 columns]
  • 获取股票指数的基本公司信息。

示例:

latest_company_info('sh600000','sh600238','sz000001')

输出:

             type pinyin  per-share earnings(year)
sh600000    A   pfyh                     2.521
sh600238    A   hnyd                     0.090
sz000001    A   payh                     1.730

          per-share earnings(four quarters)  per-share earnings(quarter)
sh600000                             2.5877                       1.2810
sh600238                             0.0038                       0.0033
sz000001                             1.7603                       0.8400

          net assets per share    unknown  general capital(10,000Y)
sh600000               13.7120  6085.9750              1865347.1415
sh600238                1.9813   517.2827                44820.0000
sz000001               10.5400  3688.2195              1430867.6139

          floating stock(10,000Y)  floating A stock(10,000Y)
sh600000             1492277.7132               1492277.7132
sh600238               44473.1580                 44473.1580
sz000001             1180405.4579               1180405.4579

          floating B stock(10,000Y) currency  annual net profit(10**8Y)
sh600000                          0      CNY                   470.2600
sh600238                          0      CNY                     0.4189
sz000001                          0      CNY                   198.0200

          four quarters net profit(10**8Y)  issue price  unknown
sh600000                          482.7300         10.0        1
sh600238                            0.0178          4.1        1
sz000001                          213.1500         40.0        1

          return on equity  quarter main business income(10**8Y)
sh600000              9.35                                707.01
sh600238              0.17                                  1.88
sz000001              7.68                                465.75

          quarter net profit(10**8Y)
sh600000                    239.0300
sh600238                      0.0148
sz000001                    115.8500
  • 获取股票指数的日K线

示例:

data=daily_k_line('sh600000','sh600238','sz000001')data.next()

输出:

sh600000      open      high       low     close     volume  adjClose
date
19991110  29.50000  29.80000  27.00001  27.74999  617827800   5.03743
19991111  27.57999  28.38001  27.52998  27.70999  104352900   5.03017
19991112  27.86001  28.30001  27.77000  28.04998   53263200   5.09189
...            ...       ...       ...       ...        ...       ...
20150819  14.87000  15.17000  14.50000  15.00000  199062100  15.00000
20150820  14.94000  14.99000  14.66000  14.68000   88124700  14.68000
20150821  14.61000  14.74000  14.20000  14.22000  123792800  14.22000
  • 获取股票的历史基本财务数据(按季节)。

这个结果是从网易的html中解析出来的。小心使用。

示例:

financial_info('sh600238')

输出:

         name per-share earnings net assets per share  \
date
20150930 海南椰岛      -0.03                 1.95
20150630 海南椰岛          0                 None
20150331 海南椰岛          0                 None
...
         Net cash flow from operating activities per share  \
date
20150930                                             -0.22
20150630                                              None
20150331                                              None
...
         main business income(10**5) main business profit(10**5)  \
date
20150930                        6827                        1967
20150630                        9150                        2929
20150331                        9649                        3658
...
         operating profit(10**5) equity earnings(10**5)  \
date
20150930                   -2628                   -759
20150630                   -1232                   -104
20150331                      86                    550
...
         net non-operating income(10**5) total profit(10**5)  \
date
20150930                            None               -1381
20150630                            None                 -49
20150331                            None                 275
...
         net margin(10**5)  \
date
20150930             -1448
20150630                77
20150331                72
...
         Net profit (ex. non recurring gains and losses)(10**5)  \
date
20150930                                               None
20150630                                               None
20150331                                               None
...
         Net cash flow from operating activities(10**5)  \
date
20150930                                         -10066
20150630                                          -7532
20150331                                          -3412
...
         Net increase in cash and cash equivalents(10**5) total assets(10**5)  \
date
20150930                                            -7977              124629
20150630                                            -8384              126958
20150331                                             -912              137809
...
         floating assets(10**5) gross liabilities(10**5)  \
date
20150930                  77675                    37206
20150630                  79353                    38078
20150331                  89095                    49008
...
         floating liabilities(10**5) shareholders interests(10**5)  \
date
20150930                       29585                         87346
20150630                       30422                         88801
20150331                       41316                         88723
...
         net assets yield weighted (%)
date
20150930                         -1.48
20150630                          0.17
20150331                          0.08
...
         per-share earnings net assets per share  \
date
20150930              -0.03                 1.95
20150630                  0                 None
20150331                  0                 None
...
         Net cash flow from operating activities per share  \
date
20150930                                             -0.22
20150630                                              None
20150331                                              None
...
         main business income(10**5) main business profit(10**5)  \
date
20150930                        6827                        1967
20150630                        9150                        2929
20150331                        9649                        3658
...
         operating profit(10**5) equity earnings(10**5)  \
date
20150930                   -2628                   -759
20150630                   -1232                   -104
20150331                      86                    550
...
         net non-operating income(10**5) total profit(10**5)  \
date
20150930                            None               -1381
20150630                            None                 -49
20150331                            None                 275
...
         net margin(10**5)  \
date
20150930             -1448
20150630                77
20150331                72
...
         Net profit (ex. non recurring gains and losses)(10**5)  \
date
20150930                                               None
20150630                                               None
20150331                                               None
...
         Net cash flow from operating activities(10**5)  \
date
20150930                                         -10066
20150630                                          -7532
20150331                                          -3412
...
         Net increase in cash and cash equivalents(10**5) total assets(10**5)  \
date
20150930                                            -7977              124629
20150630                                            -8384              126958
20150331                                             -912              137809
...
         floating assets(10**5) gross liabilities(10**5)  \
date
20150930                  77675                    37206
20150630                  79353                    38078
20150331                  89095                    49008
...
         floating liabilities(10**5) shareholders interests(10**5)  \
date
20150930                       29585                         87346
20150630                       30422                         88801
20150331                       41316                         88723
...
         net assets yield weighted (%)
date
20150930                         -1.48
20150630                          0.17
20150331                          0.08
...

若要提交问题,请访问:

https://github.com/jealous/cn_stock_src

联系作者:

jealous@163.com

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用Eclipse Helios for Web项目   java指定行。作为编译器设置的分隔符?   osm映射中带有osmdroid的java标记   java Android ClassNotFoundException在路径:DexPathList上未找到类   java从j2me调用GWT方法   更新到java 8后的aspectj问题   如何仅从根元素java,com提取文本内容。滴虫软件。是的。html   安卓公司。谷歌。火基。数据库DatabaseException:未能转换java类型的值。将字符串改为长字符串   从java中的方法返回arraylist变量   java如果将引用重新分配给同步块内的锁对象,会是什么?   java下载。使用spring mvc的资源文件中的xlsx文件   java Eclipse提供了什么工具来运行Eclipse中未包含的程序?   spring boot Java泛型如何读取传递给泛型方法的类型上的字段或调用方法   Javacard中的javaecdsa签名