Baostock: Querying complex weight factor information using Python's Baostock interface

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.