Skip to content

Commit 17216bb

Browse files
committed
Merge pull request #1920 from tacaswell/ochl_to_ohlc
finance ochl->ohlc
2 parents 38e5eab + c4819c2 commit 17216bb

File tree

7 files changed

+1247
-316
lines changed

7 files changed

+1247
-316
lines changed

doc/api/api_changes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,16 @@ original location:
4848
- mstream -> `from matplotlib import stream as mstream`
4949
- mtable -> `from matplotlib import table as mtable`
5050

51+
52+
* In :module:`~matplotlib.finance`, almost all functions have been deprecated and
53+
replaced with a pair of functions name `*_ochl` and `*_ohlc`. The former is
54+
'open-close-high-low' order of quotes, and what the module used and the later
55+
is 'open-high-low-close' order of quotes, which is the standard in finance.
56+
57+
5158
.. _changes_in_1_3:
5259

60+
5361
Changes in 1.3.x
5462
================
5563

doc/api/finance_api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*******
2+
finance
3+
*******
4+
5+
6+
:mod:`matplotlib.finance`
7+
=========================
8+
9+
.. automodule:: matplotlib.finance
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
colors_api.rst
2929
dates_api.rst
3030
figure_api.rst
31+
finance_api.rst
3132
font_manager_api.rst
3233
gridspec_api.rst
3334
legend_api.rst

examples/pylab_examples/date_demo1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
"""
1616

1717
import matplotlib.pyplot as plt
18-
from matplotlib.finance import quotes_historical_yahoo
18+
from matplotlib.finance import quotes_historical_yahoo_ochl
1919
from matplotlib.dates import YearLocator, MonthLocator, DateFormatter
2020
import datetime
21-
date1 = datetime.date( 1995, 1, 1 )
22-
date2 = datetime.date( 2004, 4, 12 )
21+
date1 = datetime.date(1995, 1, 1)
22+
date2 = datetime.date(2004, 4, 12)
2323

24-
years = YearLocator() # every year
25-
months = MonthLocator() # every month
24+
years = YearLocator() # every year
25+
months = MonthLocator() # every month
2626
yearsFmt = DateFormatter('%Y')
2727

28-
quotes = quotes_historical_yahoo(
28+
quotes = quotes_historical_yahoo_ochl(
2929
'INTC', date1, date2)
3030
if len(quotes) == 0:
3131
raise SystemExit

examples/pylab_examples/date_demo2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
import datetime
1010
import matplotlib.pyplot as plt
1111
from matplotlib.dates import MONDAY
12-
from matplotlib.finance import quotes_historical_yahoo
12+
from matplotlib.finance import quotes_historical_yahoo_ochl
1313
from matplotlib.dates import MonthLocator, WeekdayLocator, DateFormatter
1414

1515

16-
date1 = datetime.date( 2002, 1, 5 )
17-
date2 = datetime.date( 2003, 12, 1 )
16+
date1 = datetime.date(2002, 1, 5)
17+
date2 = datetime.date(2003, 12, 1)
1818

1919
# every monday
20-
mondays = WeekdayLocator(MONDAY)
20+
mondays = WeekdayLocator(MONDAY)
2121

2222
# every 3rd month
23-
months = MonthLocator(range(1,13), bymonthday=1, interval=3)
23+
months = MonthLocator(range(1, 13), bymonthday=1, interval=3)
2424
monthsFmt = DateFormatter("%b '%y")
2525

2626

27-
quotes = quotes_historical_yahoo('INTC', date1, date2)
27+
quotes = quotes_historical_yahoo_ochl('INTC', date1, date2)
2828
if len(quotes) == 0:
2929
print ('Found no quotes')
3030
raise SystemExit
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)