Use python get stock data

First, the use pandas API interfaces

Pandas library provides special access to financial data from financial websites API interface, it is another way to trade stocks quantification data obtained can be used as the interface to the data stock identity of the client to access the site in urllib3 library basis.

Pandas can be found by looking at the manual, the first parameter to the stock symbol, Apple's code "AAPL", input methods used in the domestic stock market "ticker symbol" + "to the stock market", the Shanghai stock plus behind the ticker symbol " .SS ", behind Shenzhen stock ticker symbol plus" .SZ ". DataReader can be obtained from multiple sites to share financial data, such as "Yahoo! Finance", "Google Finance" and so on, where to Yahoo, for example. Third, four parameters are broken start time stock data. The returned data format DataFrame.

Import pandas_datareader.data AS Web 
Import datetime Start
= A datetime.datetime (2010,1,1) # acquiring data period - start time End = datetime.date.today () # acquiring data period - end time stock = web.DataReader ( " 600000.SS " , " yahoo " , start, end) # Gets Shanghai Pudong Development Bank stock data from start to end of

The above code, the data can be obtained:

 

 

Second, use tushare

Specific reference may be used in http://tushare.org/

Third, the use quandl

# By WIKI acquire US stock data 
Import quandl 
tiker = [ ' NDAQ ' ] # [ 'NDAQ', 'AAPL', 'GOOGL', 'FB', 'YHOO', 'YELP', 'AMZN', 'MSFT'] 
quandl.get = DF ( ' WIKI / ' + TICKER, authToken = ' 2c24stWyXfdzLVFWxGe4 ' , START_DATE = START_DATE, END_DATE = END_DATE)

 

First wrote here, I think of what to add.

 

Guess you like

Origin www.cnblogs.com/pandas-blue/p/11632735.html