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: Obtain complex weight factor information query_adjust_factor ().
(The following code from the official website, invasion and deletion )
Method Description: Obtain the complex weight factor information data. baostock provides a complex weight factor for the re-weighted algorithm, which is described in detail in the following: baostock
return type: The Dataframe type of pandas.
Gets the current time data since the listing.
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) # Query 2015-2017-year complex weight factor rs_list = []rs_factor = bs.query_adjust_factor (code= "sh.600000", start_date= "2015-01-01", end_date= "2017-12-31") while (rs_factor.error_code == ' 0 ') & rs_factor.next (): rs_list.append (Rs_factor.get_row_data ()) Result_ FACTOR = PD. DataFrame (rs_list, columns=rs_factor.fields) # printed output print (result_factor) # result set Output to CSV file Result_ Factor.to_csv ("D:\\adjust_factor_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;
start_date: The start date, which is empty when the default is 2015-01-01, contains this date;
end_date: The end date, which is empty when the default current date, contains this date.
Return Data Description
Parameter name |
Parameter description |
code |
security code |
dividoperatedate |
The ex-dividend date |
foreadjustfactor |
forward complex weight factor |
backadjustfactor |
back weight factor |
adjustfactor |
this time complex weight factor |
Sample data:
When the complex weight factor changes, the 2nd trading day can see the update. After acquiring the complex weight factor, how to calculate the price of complex right, see the next article.
Baostock: Querying complex weight factor information using Python's Baostock interface