Securities Bao Www.baostock.com is a free, open-source securities data platform.
Provide a large number of accurate and complete securities historical market data, listed company financial data, real-time securities market push services.
Acquisition of securities data information through the Python API, to meet quantitative trading investors, quantitative financial enthusiasts, metering economic practitioners data needs.
This introduction interface: Get quarterly profitability data :query_growth_data ()
(The following code from the official website, invasion and deletion )
Method Description: Query the quarterly frequency growth ability information, can be set by the parameters of the corresponding year, quarter data, to provide 2007 to date data, to provide 2007 to date data.
return type: The Dataframe type of pandas.
The sample code is as follows:
IMPORT BAOSTOCK AS BSIMPORT PANDAS AS PD # Landing System Lg = bs.login (user_id= "Anonymous", password= "123456") # display login return information print (' Login respond error_code: ' +lg.error_code ' Print (' login respond error_msg: ' +lg.error_msg) # Growth capacity Growth_list = []rs_growth = bs.query_growth_data (code= "sh.600000", year= 2017, quarter=2) while (rs_growth.error_code == ' 0 ') & rs_growth.next (): growth_list.append (Rs_growth.get_row_data ()) result_growth = pd. DataFrame (growth_list, columns=rs_growth.fields) # printed output print (result_growth) # result set Output to CSV file Result_ Growth.to_csv ("D:\\growth_data.csv", encoding= "GBK", index=false) # logout system bs.logout ()
parameter meaning:
Code: Stock code, SH or sz.+6 digit code, or index code, such as: sh.601398. SH: Shanghai; SZ: Shenzhen. This parameter is not nullable;
Year: Statistic year, default current year for empty;
Quarter: Statistics quarter, empty when default current quarter. When not empty, there are only 4 values: 1,2,3,4.
Return Data Description
parameter name |
parameter description |
code |
security code |
pubdate |
date of publication of the company's earnings |
statdate |
Last day of the quarter of the earnings statistics, such as 2017-03-31, 2017-06-30 |
yoyequity |
net asset growth rate (YoY) |
yoyasset |
Total assets YoY growth rate |
yoyni |
net profit YoY growth rate |
yoyepsbasic |
Basic earnings per share YoY growth rate |
YOYPNI |
attributable to parent company shareholder net profit YoY growth rate |
Sample data:
Baostock: Use Python's Baostock interface to query the quarterly frequency growth capability