A tool for obtaining historical data of China stock market
Project description
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_plus("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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
baostock-0.8.9.tar.gz
(21.9 kB
view details)
Built Distribution
baostock-0.8.9-py3-none-any.whl
(45.9 kB
view details)
File details
Details for the file baostock-0.8.9.tar.gz
.
File metadata
- Download URL: baostock-0.8.9.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8169cdbed14fa442ace63c59549bef3f92b0c3dd1df9e5d9069f7bd04a76b0da |
|
MD5 | 7e88e78fcbfeed1a82c50c2e7275f25b |
|
BLAKE2b-256 | eed50fb2c61f392f89b1655490acb17a02861f1f1c38e973c9fc6aa049e54401 |
File details
Details for the file baostock-0.8.9-py3-none-any.whl
.
File metadata
- Download URL: baostock-0.8.9-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a51fb30cd6b4325f5517198e350dc2fffaaab2923cd132b9f747b8b73ae7303 |
|
MD5 | 0c599907120545ceee9ad0d9fd62fd27 |
|
BLAKE2b-256 | b237bbabac2d33723d71bd8dbd5e819d9cbe5dc1e031b7dd12ed7de8fa040816 |