Name | baostock JSON |
Version |
0.8.8
JSON |
| download |
home_page | http://www.baostock.com |
Summary | A tool for obtaining historical data of China stock market |
upload_time | 2019-01-25 10:00:33 |
maintainer | |
docs_url | None |
author | baostock |
requires_python | |
license | BSD License |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
BaoStock
===============
* It's easy to use because most of the data returned are pandas DataFrame objects
* We have our own data server, efficient and stable operation
* Free china stock market data
* Friendly to machine learning and data mining
Target Users
--------------
* China Financial Market Analyst
* Financial data analysis enthusiasts
* Quanters who are interested in china stock market
Installation
--------------
pip install baostock
Upgrade
---------------
pip install baostock --upgrade
Quick Start
--------------
::
import baostock as bs
import pandas as pd
# 登陆系统
lg = bs.login()
# 显示登陆返回信息
print(lg.error_code)
print(lg.error_msg)
# 详细指标参数,参见“历史行情指标参数”章节
rs = bs.query_history_k_data("sh.601398",
"date,code,open,high,low,close,volume,amount,adjustflag",
start_date='2017-01-01', end_date='2017-01-31',
frequency="d", adjustflag="3")
print(rs.error_code)
print(rs.error_msg)
# 获取具体的信息
result_list = []
while (rs.error_code == '0') & rs.next():
# 分页查询,将每页信息合并在一起
result_list.append(rs.get_row_data())
result = pd.DataFrame(result_list, columns=rs.fields)
result.to_csv("D:/history_k_data.csv", encoding="gbk", index=False)
print(result)
# 登出系统
bs.logout()
return::
date code open high low close preclose volume
0 2017-01-03 sh.601398 4.4000 4.4300 4.3900 4.4300 4.4100 104161632
1 2017-01-04 sh.601398 4.4200 4.4400 4.4100 4.4300 4.4300 118923425
2 2017-01-05 sh.601398 4.4300 4.4500 4.4200 4.4400 4.4300 87356137
3 2017-01-06 sh.601398 4.4400 4.4500 4.4300 4.4400 4.4400 87008191
4 2017-01-09 sh.601398 4.4500 4.4800 4.4300 4.4600 4.4400 117454094
5 2017-01-10 sh.601398 4.4500 4.4700 4.4400 4.4600 4.4600 63663257
6 2017-01-11 sh.601398 4.4600 4.4800 4.4500 4.4700 4.4600 52395427
7 2017-01-12 sh.601398 4.4600 4.4700 4.4400 4.4700 4.4700 62166279
amount adjustflag turn tradestatus
0 460087744.0000 3 0.038634 1
1 526408816.0000 3 0.044109 1
2 387580736.0000 3 0.032401 1
3 386138112.0000 3 0.032272 1
4 523539392.0000 3 0.043564 1
5 283646224.0000 3 0.023613 1
6 233898107.0000 3 0.019434 1
7 277258304.0000 3 0.023058 1
Raw data
{
"_id": null,
"home_page": "http://www.baostock.com",
"name": "baostock",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "baostock",
"author_email": "baostock@163.com",
"download_url": "https://files.pythonhosted.org/packages/b7/b1/49b688e1e6338603d59e10c4b4e30530b180cf24439a5c7519a0f03b8bd8/baostock-0.8.8.tar.gz",
"platform": "all",
"description": "\nBaoStock\n===============\n\n* It's easy to use because most of the data returned are pandas DataFrame objects\n* We have our own data server, efficient and stable operation\n* Free china stock market data\n* Friendly to machine learning and data mining\n\nTarget Users\n--------------\n\n* China Financial Market Analyst\n* Financial data analysis enthusiasts\n* Quanters who are interested in china stock market\n\nInstallation\n--------------\n\n pip install baostock\n\nUpgrade\n---------------\n\n pip install baostock --upgrade\n\nQuick Start\n--------------\n\n::\n\n import baostock as bs\n import pandas as pd\n\n # \u767b\u9646\u7cfb\u7edf\n lg = bs.login()\n # \u663e\u793a\u767b\u9646\u8fd4\u56de\u4fe1\u606f\n print(lg.error_code)\n print(lg.error_msg)\n # \u8be6\u7ec6\u6307\u6807\u53c2\u6570\uff0c\u53c2\u89c1\u201c\u5386\u53f2\u884c\u60c5\u6307\u6807\u53c2\u6570\u201d\u7ae0\u8282\n rs = bs.query_history_k_data(\"sh.601398\",\n \"date,code,open,high,low,close,volume,amount,adjustflag\",\n start_date='2017-01-01', end_date='2017-01-31',\n frequency=\"d\", adjustflag=\"3\")\n print(rs.error_code)\n print(rs.error_msg)\n # \u83b7\u53d6\u5177\u4f53\u7684\u4fe1\u606f\n result_list = []\n while (rs.error_code == '0') & rs.next():\n # \u5206\u9875\u67e5\u8be2\uff0c\u5c06\u6bcf\u9875\u4fe1\u606f\u5408\u5e76\u5728\u4e00\u8d77\n result_list.append(rs.get_row_data())\n result = pd.DataFrame(result_list, columns=rs.fields)\n result.to_csv(\"D:/history_k_data.csv\", encoding=\"gbk\", index=False)\n print(result)\n # \u767b\u51fa\u7cfb\u7edf\n bs.logout()\n\nreturn::\n\n date code open high low close preclose volume\n 0 2017-01-03 sh.601398 4.4000 4.4300 4.3900 4.4300 4.4100 104161632 \n 1 2017-01-04 sh.601398 4.4200 4.4400 4.4100 4.4300 4.4300 118923425 \n 2 2017-01-05 sh.601398 4.4300 4.4500 4.4200 4.4400 4.4300 87356137 \n 3 2017-01-06 sh.601398 4.4400 4.4500 4.4300 4.4400 4.4400 87008191 \n 4 2017-01-09 sh.601398 4.4500 4.4800 4.4300 4.4600 4.4400 117454094 \n 5 2017-01-10 sh.601398 4.4500 4.4700 4.4400 4.4600 4.4600 63663257 \n 6 2017-01-11 sh.601398 4.4600 4.4800 4.4500 4.4700 4.4600 52395427 \n 7 2017-01-12 sh.601398 4.4600 4.4700 4.4400 4.4700 4.4700 62166279 \n \n amount adjustflag turn tradestatus \n 0 460087744.0000 3 0.038634 1 \n 1 526408816.0000 3 0.044109 1 \n 2 387580736.0000 3 0.032401 1 \n 3 386138112.0000 3 0.032272 1 \n 4 523539392.0000 3 0.043564 1 \n 5 283646224.0000 3 0.023613 1 \n 6 233898107.0000 3 0.019434 1 \n 7 277258304.0000 3 0.023058 1 \n\n",
"bugtrack_url": null,
"license": "BSD License",
"summary": "A tool for obtaining historical data of China stock market",
"version": "0.8.8",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43e2b367c78db42bafcf752442b7d582ba2a724286313d9f126c5fee06064fb2",
"md5": "7444a3e83d13aa4c1cab3b1906323940",
"sha256": "f7b0466a71ce0c70cecf7b02f5631d4cb400a04b8a5a9c330c1b0d29dcdab97d"
},
"downloads": -1,
"filename": "baostock-0.8.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7444a3e83d13aa4c1cab3b1906323940",
"packagetype": "bdist_wheel",
"python_version": "3.6",
"requires_python": null,
"size": 55238,
"upload_time": "2019-01-25T10:00:44",
"upload_time_iso_8601": "2019-01-25T10:00:44.423069Z",
"url": "https://files.pythonhosted.org/packages/43/e2/b367c78db42bafcf752442b7d582ba2a724286313d9f126c5fee06064fb2/baostock-0.8.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b7b149b688e1e6338603d59e10c4b4e30530b180cf24439a5c7519a0f03b8bd8",
"md5": "9926ac112d771b9819dff850464670e3",
"sha256": "e5c5b81257f900f520700516e072a46d36870de88c0b4d715406f97ed1a4e479"
},
"downloads": -1,
"filename": "baostock-0.8.8.tar.gz",
"has_sig": false,
"md5_digest": "9926ac112d771b9819dff850464670e3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 26458,
"upload_time": "2019-01-25T10:00:33",
"upload_time_iso_8601": "2019-01-25T10:00:33.343830Z",
"url": "https://files.pythonhosted.org/packages/b7/b1/49b688e1e6338603d59e10c4b4e30530b180cf24439a5c7519a0f03b8bd8/baostock-0.8.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2019-01-25 10:00:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "baostock"
}