| 
1 | 1 | #!/usr/bin/env python  | 
2 | 2 | import matplotlib.pyplot as plt  | 
3 |  | -from matplotlib.dates import  DateFormatter, WeekdayLocator, HourLocator, \  | 
 | 3 | +from matplotlib.dates import DateFormatter, WeekdayLocator,\  | 
4 | 4 |      DayLocator, MONDAY  | 
5 |  | -from matplotlib.finance import quotes_historical_yahoo, candlestick,\  | 
6 |  | -     plot_day_summary, candlestick2  | 
 | 5 | +from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc  | 
 | 6 | + | 
7 | 7 | 
 
  | 
8 | 8 | # (Year, month, day) tuples suffice as args for quotes_historical_yahoo  | 
9 |  | -date1 = ( 2004, 2, 1)  | 
10 |  | -date2 = ( 2004, 4, 12 )  | 
 | 9 | +date1 = (2004, 2, 1)  | 
 | 10 | +date2 = (2004, 4, 12)  | 
11 | 11 | 
 
  | 
12 | 12 | 
 
  | 
13 | 13 | mondays = WeekdayLocator(MONDAY)        # major ticks on the mondays  | 
14 |  | -alldays    = DayLocator()              # minor ticks on the days  | 
 | 14 | +alldays = DayLocator()              # minor ticks on the days  | 
15 | 15 | weekFormatter = DateFormatter('%b %d')  # e.g., Jan 12  | 
16 | 16 | dayFormatter = DateFormatter('%d')      # e.g., 12  | 
17 | 17 | 
 
  | 
18 |  | -quotes = quotes_historical_yahoo('INTC', date1, date2)  | 
 | 18 | +quotes = quotes_historical_yahoo_ohlc('INTC', date1, date2)  | 
19 | 19 | if len(quotes) == 0:  | 
20 | 20 |     raise SystemExit  | 
21 | 21 | 
 
  | 
 | 
27 | 27 | #ax.xaxis.set_minor_formatter(dayFormatter)  | 
28 | 28 | 
 
  | 
29 | 29 | #plot_day_summary(ax, quotes, ticksize=3)  | 
30 |  | -candlestick(ax, quotes, width=0.6)  | 
 | 30 | +candlestick_ohlc(ax, quotes, width=0.6)  | 
31 | 31 | 
 
  | 
32 | 32 | ax.xaxis_date()  | 
33 | 33 | ax.autoscale_view()  | 
34 |  | -plt.setp( plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')  | 
 | 34 | +plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')  | 
35 | 35 | 
 
  | 
36 | 36 | plt.show()  | 
37 |  | - | 
0 commit comments