I am learning how to analyze stock market. I followed this website:

https://ntguardian.wordpress.com/2016/09/19/introduction-stock-market-data-python-1/

Here are problems as of April 10, 2018 that I encountered and how I resolved them.

1-reading data: the problem was that google and yahoo discontinued their services and pandas.io.data no more works and I received this error:

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

After some searches I found the solution from https://github.com/rsvp/fecon235/issues/7:

The new code is

import pandas_datareader.data   as webapple = web.DataReader(symbol, 'quandl', start_date, end_date)

Next challenge was the number of records that one can fetch which is limited. For this you can create a database and store data. The following code checks the local database and if the data for the period is not available, it fetches the data and puts in the database.

import sqlite3start_date = datetime.datetime(2017, 1, 1)end_date = datetime.datetime(2018, 1, 1)symbol = 'WIKI/AAPL'db = sqlite3.connect("database\stock.db")c = db.cursor()sssymb = symbol.split('/')[1]sql = "SELECT * FROM " + sssymb + " WHERE date BETWEEN '" + \      "{:%Y-%m-%d} 00:00:00".format(start_date) + "' AND '" + "{:%Y-%m-%d} 00:00:00".format(end_date) + "'"c.execute(sql)dataExist = len(c.fetchall())if dataExist < 2:    apple = web.DataReader(symbol, 'quandl', start_date, end_date)    query = ''' insert or replace into AAPL (date, Open,High,Low,Close,Volume,ExDividend,SplitRatio,AdjOpen,AdjHigh,AdjLow ,  AdjClose ,  AdjVolume ) values (?,?,?,?,?,?,?,?,?,?,?,?,?) '''    c.executemany(query, apple.to_records(index=True))    db.commit()

The next step is candlestickplots. A goodway is to install the plotpy offline and  then use the following code. However, you also can use the code from the aforementioned website that I modified and stored it in a file named candlestickplot.py. The latter requires installation of mpl_finance.

import plotly.offline as offlinetrace = go.Candlestick(x=apple.index,open=apple.Open,high= apple.High, low=apple.Low,close=apple.Close)data=[trace]offline.plot(data,image="png")