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: Security Code query :query_all_stock ()
(The following code from the official website, invasion and deletion )
Method Description: Query the securities code and stock trading status information information, can be through the parameters ' a trading day ' access to data (including: A-share, index), providing 2014 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 () # display login return information print (' Login respond error_code: ' + Lg.error_code) Print (' login respond error_msg: ' +lg.error_msg) #### access to securities information ### #rs = bs.query_all_stock (day= "2017-06-30") print (' Query_all_stock respond error_code: ' +rs.error_code Print (' query_all_stock respond error_msg: ' +rs.error_msg) #### prints the result set ### #data_list = []while (rs.error_code == ' 0 ') & rs.next (): # Gets a record that merges records together data_list.append (Rs.get_row_data ()) result = pd. DataFrame (data_list, columns=rs.fields) #### result set Output to CSV file #### result.to_csv ("D : \\all_stock.csv ", encoding=" GBK ", index=false) print (Result) #### logout system ### #bs. Logout ()
Parameter meaning:
Day : The date that needs to be queried is the default current date when it is empty.
Return Data Description
parameter name |
parameter description |
code |
security code |
Tradestatus |
Trading status (1: normal trade 0: suspension) |
Sample data (more data, only part of the data is posted):
Use Python to get stock specified date transaction code data