@@ -295,7 +295,9 @@ def parse_yahoo_historical(fh, adjusted=True, asobject=False,
295
295
return d .view (np .recarray ) # Close enough to former Bunch return
296
296
297
297
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 ):
299
301
"""
300
302
Fetch historical data for ticker between date1 and date2. date1 and
301
303
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
357
359
if cachename is not None :
358
360
if os .path .exists (cachename ):
359
361
fh = open (cachename )
360
- verbose .report ('Using cachefile %s for %s' % (cachename , ticker ))
362
+ verbose .report ('Using cachefile %s for '
363
+ '%s' % (cachename , ticker ))
361
364
else :
362
365
mkdirs (os .path .abspath (os .path .dirname (cachename )))
363
366
with contextlib .closing (urlopen (url )) as urlfh :
364
367
with open (cachename , 'wb' ) as fh :
365
368
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 ))
367
371
fh = open (cachename , 'r' )
368
372
369
373
return fh
@@ -417,7 +421,7 @@ def quotes_historical_yahoo(ticker, date1, date2, asobject=False,
417
421
if len (ret ) == 0 :
418
422
return None
419
423
except IOError as exc :
420
- warnings .warn ('fh failure\n %s' % (exc .strerror [1 ]))
424
+ warnings .warn ('fh failure\n %s' % (exc .strerror [1 ]))
421
425
return None
422
426
423
427
return ret
@@ -607,12 +611,12 @@ def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4,
607
611
a list of lines added to the axes
608
612
"""
609
613
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"
611
615
"of `plot_day_summary_ochl`,"
612
616
"which maintains the original argument order,"
613
617
"or `plot_day_summary_ohlc`,"
614
618
"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 )
616
620
return plot_day_summary_ohlc (ax , opens , highs , lows , closes , ticksize ,
617
621
colorup , colordown )
618
622
@@ -691,7 +695,8 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
691
695
# note this code assumes if any value open, high, low, close is
692
696
# missing they all are missing
693
697
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 ]
695
700
696
701
# the ticks will be from ticksize to 0 in points at the origin and
697
702
# 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,
701
706
# we'll translate these to the i, close location
702
707
closeSegments = [((0 , 0 ), (ticksize , 0 ))]
703
708
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 ]
705
711
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 ]
707
714
708
715
scale = ax .figure .dpi * (1.0 / 72.0 )
709
716
@@ -716,7 +723,8 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
716
723
colord = {True : colorup ,
717
724
False : colordown ,
718
725
}
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 ]
720
728
721
729
assert (len (rangeSegments ) == len (offsetsOpen ))
722
730
assert (len (offsetsOpen ) == len (offsetsClose ))
@@ -761,6 +769,7 @@ def plot_day_summary_ohlc(ax, opens, highs, lows, closes, ticksize=4,
761
769
ax .add_collection (closeCollection )
762
770
return rangeCollection , openCollection , closeCollection
763
771
772
+
764
773
def candlestick_ochl (ax , opens , closes , highs , lows , width = 4 ,
765
774
colorup = 'k' , colordown = 'r' ,
766
775
alpha = 0.75 ,
@@ -810,10 +819,10 @@ def candlestick2(ax, opens, closes, highs, lows, width=4,
810
819
"""Represent the open, close as a bar line and high low range as a
811
820
vertical line.
812
821
813
- This function has been deprecated in 1.3 in favor of
822
+ This function has been deprecated in 1.4 in favor of
814
823
`candlestick_ochl`, which maintains the original argument order,
815
824
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
817
826
818
827
819
828
Parameters
@@ -842,20 +851,18 @@ def candlestick2(ax, opens, closes, highs, lows, width=4,
842
851
ret : tuple
843
852
(lineCollection, barCollection)
844
853
"""
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"
848
855
"of `candlestick_ochl`,"
849
856
"which maintains the original argument order,"
850
857
"or `candlestick_ohlc`,"
851
858
"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 )
854
860
855
861
candlestick_ohlc (ax , opens , highs , lows , closes , width = width ,
856
862
colorup = colorup , colordown = colordown ,
857
863
alpha = alpha )
858
864
865
+
859
866
def candlestick_ohlc (ax , opens , highs , lows , closes , width = 4 ,
860
867
colorup = 'k' , colordown = 'r' ,
861
868
alpha = 0.75 ,
@@ -895,7 +902,10 @@ def candlestick_ohlc(ax, opens, highs, lows, closes, width=4,
895
902
# missing they all are missing
896
903
897
904
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 ))
899
909
for i , open , close in zip (xrange (len (opens )), opens , closes )
900
910
if open != - 1 and close != - 1 ]
901
911
@@ -1046,7 +1056,8 @@ def volume_overlay2(ax, closes, volumes,
1046
1056
1047
1057
"""
1048
1058
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 )
1050
1061
1051
1062
1052
1063
def volume_overlay3 (ax , quotes ,
0 commit comments