Time for action – plotting a year's worth of stock quotes

We can plot a year's worth of stock quotes data with the matplotlib.finance package. This requires a connection to Yahoo Finance, which is the data source.

  1. Determine the start date by subtracting one year from today:
    from matplotlib.dates import DateFormatter
    from matplotlib.dates import DayLocator
    from matplotlib.dates import MonthLocator
    from matplotlib.finance import quotes_historical_yahoo
    from matplotlib.finance import candlestick
    import sys
    from datetime import date
    import matplotlib.pyplot as plt
    today = date.today()
    start = (today.year - 1, today.month, today.day)
  2. We need to create the so-called locators. These objects from the matplotlib.dates package locate months and days on the ...

Get NumPy : Beginner's Guide - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.