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

Skip to content

Commit ca8845e

Browse files
committed
fixed pep8, updated depreciation messages because this missed 1.3
1 parent 9c5e1c3 commit ca8845e

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

lib/matplotlib/finance.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ def parse_yahoo_historical(fh, adjusted=True, asobject=False,
295295
return d.view(np.recarray) # Close enough to former Bunch return
296296

297297

298-
def fetch_historical_yahoo(ticker, date1, date2, cachename=None, dividends=False):
298+
def fetch_historical_yahoo(ticker, date1, date2, cachename=None,
299+
dividends=False,
300+
ochl=True):
299301
"""
300302
Fetch historical data for ticker between date1 and date2. date1 and
301303
date2 are date or datetime instances, or (year, month, day) sequences.
@@ -357,13 +359,15 @@ def fetch_historical_yahoo(ticker, date1, date2, cachename=None, dividends=False
357359
if cachename is not None:
358360
if os.path.exists(cachename):
359361
fh = open(cachename)
360-
verbose.report('Using cachefile %s for %s'%(cachename, ticker))
362+
verbose.report('Using cachefile %s for '
363+
'%s' % (cachename, ticker))
361364
else:
362365
mkdirs(os.path.abspath(os.path.dirname(cachename)))
363366
with contextlib.closing(urlopen(url)) as urlfh:
364367
with open(cachename, 'wb') as fh:
365368
fh.write(urlfh.read())
366-
verbose.report('Saved %s data to cache file %s'%(ticker, cachename))
369+
verbose.report('Saved %s data to cache file '
370+
'%s' % (ticker, cachename))
367371
fh = open(cachename, 'r')
368372

369373
return fh
@@ -417,7 +421,7 @@ def quotes_historical_yahoo(ticker, date1, date2, asobject=False,
417421
if len(ret) == 0:
418422
return None
419423
except IOError as exc:
420-
warnings.warn('fh failure\n%s'%(exc.strerror[1]))
424+
warnings.warn('fh failure\n%s' % (exc.strerror[1]))
421425
return None
422426

423427
return ret
@@ -607,12 +611,12 @@ def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4,
607611
a list of lines added to the axes
608612
"""
609613

610-
warnings.warn("This function has been deprecated in 1.3 in favor"
614+
warnings.warn("This function has been deprecated in 1.4 in favor"
611615
"of `plot_day_summary_ochl`,"
612616
"which maintains the original argument order,"
613617
"or `plot_day_summary_ohlc`,"
614618
"which uses the open-high-low-close order."
615-
"This function will be removed in 1.4", mplDeprecation)
619+
"This function will be removed in 1.5", mplDeprecation)
616620
return plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize,
617621
colorup, colordown)
618622

@@ -691,7 +695,8 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
691695
# note this code assumes if any value open, high, low, close is
692696
# missing they all are missing
693697

694-
rangeSegments = [((i, low), (i, high)) for i, low, high in zip(xrange(len(lows)), lows, highs) if low != -1]
698+
rangeSegments = [((i, low), (i, high)) for i, low, high in
699+
zip(xrange(len(lows)), lows, highs) if low != -1]
695700

696701
# the ticks will be from ticksize to 0 in points at the origin and
697702
# we'll translate these to the i, close location
@@ -701,9 +706,11 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
701706
# we'll translate these to the i, close location
702707
closeSegments = [((0, 0), (ticksize, 0))]
703708

704-
offsetsOpen = [(i, open) for i, open in zip(xrange(len(opens)), opens) if open != -1]
709+
offsetsOpen = [(i, open) for i, open in
710+
zip(xrange(len(opens)), opens) if open != -1]
705711

706-
offsetsClose = [(i, close) for i, close in zip(xrange(len(closes)), closes) if close != -1]
712+
offsetsClose = [(i, close) for i, close in
713+
zip(xrange(len(closes)), closes) if close != -1]
707714

708715
scale = ax.figure.dpi * (1.0 / 72.0)
709716

@@ -716,7 +723,8 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
716723
colord = {True: colorup,
717724
False: colordown,
718725
}
719-
colors = [colord[open < close] for open, close in zip(opens, closes) if open != -1 and close != -1]
726+
colors = [colord[open < close] for open, close in
727+
zip(opens, closes) if open != -1 and close != -1]
720728

721729
assert(len(rangeSegments) == len(offsetsOpen))
722730
assert(len(offsetsOpen) == len(offsetsClose))
@@ -761,6 +769,7 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
761769
ax.add_collection(closeCollection)
762770
return rangeCollection, openCollection, closeCollection
763771

772+
764773
def candlestick_ochl(ax, opens, closes, highs, lows, width=4,
765774
colorup='k', colordown='r',
766775
alpha=0.75,
@@ -810,10 +819,10 @@ def candlestick2(ax, opens, closes, highs, lows, width=4,
810819
"""Represent the open, close as a bar line and high low range as a
811820
vertical line.
812821
813-
This function has been deprecated in 1.3 in favor of
822+
This function has been deprecated in 1.4 in favor of
814823
`candlestick_ochl`, which maintains the original argument order,
815824
or `candlestick_ohlc`, which uses the open-high-low-close order.
816-
This function will be removed in 1.4
825+
This function will be removed in 1.5
817826
818827
819828
Parameters
@@ -842,20 +851,18 @@ def candlestick2(ax, opens, closes, highs, lows, width=4,
842851
ret : tuple
843852
(lineCollection, barCollection)
844853
"""
845-
846-
847-
warnings.warn("This function has been deprecated in 1.3 in favor"
854+
warnings.warn("This function has been deprecated in 1.4 in favor"
848855
"of `candlestick_ochl`,"
849856
"which maintains the original argument order,"
850857
"or `candlestick_ohlc`,"
851858
"which uses the open-high-low-close order."
852-
"This function will be removed in 1.4", mplDeprecation)
853-
859+
"This function will be removed in 1.5", mplDeprecation)
854860

855861
candlestick_ohlc(ax, opens, highs, lows, closes, width=width,
856862
colorup=colorup, colordown=colordown,
857863
alpha=alpha)
858864

865+
859866
def candlestick_ohlc(ax, opens, highs, lows, closes, width=4,
860867
colorup='k', colordown='r',
861868
alpha=0.75,
@@ -895,7 +902,10 @@ def candlestick_ohlc(ax, opens, highs, lows, closes, width=4,
895902
# missing they all are missing
896903

897904
delta = width / 2.
898-
barVerts = [((i - delta, open), (i - delta, close), (i + delta, close), (i + delta, open))
905+
barVerts = [((i - delta, open),
906+
(i - delta, close),
907+
(i + delta, close),
908+
(i + delta, open))
899909
for i, open, close in zip(xrange(len(opens)), opens, closes)
900910
if open != -1 and close != -1]
901911

@@ -1046,7 +1056,8 @@ def volume_overlay2(ax, closes, volumes,
10461056
10471057
"""
10481058

1049-
return volume_overlay(ax, closes[:-1], closes[1:], volumes[1:], colorup, colordown, width, alpha)
1059+
return volume_overlay(ax, closes[:-1], closes[1:], volumes[1:],
1060+
colorup, colordown, width, alpha)
10501061

10511062

10521063
def volume_overlay3(ax, quotes,

0 commit comments

Comments
 (0)