Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e39c0c

Browse files
committed
updated finance_demo.py code to use new api
1 parent 4c76044 commit 1e39c0c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/usr/bin/env python
22
import matplotlib.pyplot as plt
3-
from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, \
3+
from matplotlib.dates import DateFormatter, WeekdayLocator,\
44
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+
77

88
# (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)
1111

1212

1313
mondays = WeekdayLocator(MONDAY) # major ticks on the mondays
14-
alldays = DayLocator() # minor ticks on the days
14+
alldays = DayLocator() # minor ticks on the days
1515
weekFormatter = DateFormatter('%b %d') # e.g., Jan 12
1616
dayFormatter = DateFormatter('%d') # e.g., 12
1717

18-
quotes = quotes_historical_yahoo('INTC', date1, date2)
18+
quotes = quotes_historical_yahoo_ohlc('INTC', date1, date2)
1919
if len(quotes) == 0:
2020
raise SystemExit
2121

@@ -27,11 +27,10 @@
2727
#ax.xaxis.set_minor_formatter(dayFormatter)
2828

2929
#plot_day_summary(ax, quotes, ticksize=3)
30-
candlestick(ax, quotes, width=0.6)
30+
candlestick_ohlc(ax, quotes, width=0.6)
3131

3232
ax.xaxis_date()
3333
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')
3535

3636
plt.show()
37-

0 commit comments

Comments
 (0)