How to implement Financial data Reading Port by Python
Editor to share with you how to achieve Python financial data reading port, I hope you will learn something after reading this article, let's discuss it together!
For reference only, use the official website: https://www.yahoo.com/
Yahoo is a famous Internet portal in the United States and one of the creators of Internet miracles at the end of the 20th century. Its services include search engines, e-mail, news, etc., with operations in 24 countries and regions, providing diversified network services to more than 500 million independent users around the world. It is also a global Internet communications, business and media company. Import pandas_datareader.data as pdr # pre-installed: pip install pandas-datareader# from pandas_datareader import data as pdrsp500 = pdr.DataReader (name=' ^ GSPC',data_source='yahoo',start='1/1/2019',end='4/14/2019') # S & P 500sp500.info ()
# apple = web.get_data_yahoo ('AAPL') # Apple Stock # apple.info ()
# stock_300481 = pdr.get_data_yahoo ('300481.szgift stock_300481.info ()
The read result is
Sp500.head (10) # print 10 lines
The read result is
TuShare official website: http://tushare.waditu.com/TuShare is a free and open source python financial data interface package, which mainly realizes the process of data collection, cleaning and processing to data storage for financial data such as stocks, and can provide financial analysts with fast, neat, and diverse data that are easy to analyze, and greatly reduce their workload in data acquisition. Make them pay more attention to the research and implementation of strategies and models. Considering the advantages of Python pandas package in financial quantitative analysis, most of the data returned by TuShare is of pandas DataFrame type. Import tushare as ts # pre-installed: pip install tushare# ts.get_hist_data () function df = ts.get_hist_data ('002414, start='2018-10-17, end='2018-11-17') df.head ()
The output is as follows
Df.tail ()
The output is as follows
The meanings of each variable are as follows
Import tushare as ts # pre-installed: pip install tushare# ts.get_k_data () function data = ts.get_k_data ('600118,' 2014-01-01-01), ktype='D') # Dmuri-daily line, Wmuri-weekly line, data-monthly line data.head ()
The output is as follows
Data.tail ()
The output is as follows
After reading this article, I believe you have a certain understanding of "how to achieve financial data reading port in Python". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!