@@ -116,8 +116,8 @@ def parse_yahoo_historical_ochl(fh, adjusted=True, asobject=False):
116
116
very similar to the Bunch.
117
117
118
118
"""
119
- _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
120
- oclh = True )
119
+ return _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
120
+ ochl = True )
121
121
122
122
123
123
def parse_yahoo_historical_ohlc (fh , adjusted = True , asobject = False ):
@@ -160,7 +160,7 @@ def parse_yahoo_historical_ohlc(fh, adjusted=True, asobject=False):
160
160
holding 1-D ndarrays. The behavior of a numpy recarray is
161
161
very similar to the Bunch.
162
162
"""
163
- _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
163
+ return _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
164
164
ochl = False )
165
165
166
166
@@ -217,11 +217,12 @@ def parse_yahoo_historical(fh, adjusted=True, asobject=False):
217
217
Defaults to True to preserve original functionality.
218
218
219
219
"""
220
+
220
221
warnings .warn (_warn_str .format (fun = 'parse_yahoo_historical' ),
221
222
mplDeprecation )
222
223
223
- _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
224
- oclh = True )
224
+ return _parse_yahoo_historical (fh , adjusted = adjusted , asobject = asobject ,
225
+ ochl = True )
225
226
226
227
227
228
def _parse_yahoo_historical (fh , adjusted = True , asobject = False ,
@@ -283,13 +284,11 @@ def _parse_yahoo_historical(fh, adjusted=True, asobject=False,
283
284
else :
284
285
stock_dt = stock_dt_ohlc
285
286
286
- lines = fh .readlines ()
287
-
288
287
results = []
289
288
290
289
# datefmt = '%Y-%m-%d'
291
-
292
- for line in lines [ 1 :] :
290
+ fh . readline () # discard heading
291
+ for line in fh :
293
292
294
293
vals = line .split (',' )
295
294
if len (vals ) != 7 :
@@ -303,9 +302,13 @@ def _parse_yahoo_historical(fh, adjusted=True, asobject=False,
303
302
open , high , low , close = [float (val ) for val in vals [1 :5 ]]
304
303
volume = float (vals [5 ])
305
304
aclose = float (vals [6 ])
305
+ if ochl :
306
+ results .append ((dt , dt .year , dt .month , dt .day ,
307
+ dnum , open , close , high , low , volume , aclose ))
306
308
307
- results .append ((dt , dt .year , dt .month , dt .day ,
308
- dnum , open , high , low , close , volume , aclose ))
309
+ else :
310
+ results .append ((dt , dt .year , dt .month , dt .day ,
311
+ dnum , open , high , low , close , volume , aclose ))
309
312
results .reverse ()
310
313
d = np .array (results , dtype = stock_dt )
311
314
if adjusted :
@@ -459,7 +462,7 @@ def quotes_historical_yahoo(ticker, date1, date2, asobject=False,
459
462
warnings .warn (_warn_str .format (fun = 'quotes_historical_yahoo' ),
460
463
mplDeprecation )
461
464
462
- _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
465
+ return _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
463
466
adjusted = adjusted , cachename = cachename ,
464
467
ochl = True )
465
468
@@ -499,7 +502,7 @@ def quotes_historical_yahoo_ochl(ticker, date1, date2, asobject=False,
499
502
and date range)
500
503
"""
501
504
502
- _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
505
+ return _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
503
506
adjusted = adjusted , cachename = cachename ,
504
507
ochl = True )
505
508
@@ -539,7 +542,7 @@ def quotes_historical_yahoo_ohlc(ticker, date1, date2, asobject=False,
539
542
and date range)
540
543
"""
541
544
542
- _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
545
+ return _quotes_historical_yahoo (ticker , date1 , date2 , asobject = asobject ,
543
546
adjusted = adjusted , cachename = cachename ,
544
547
ochl = True )
545
548
@@ -639,7 +642,7 @@ def plot_day_summary(ax, quotes, ticksize=3,
639
642
warnings .warn (_warn_str .format (fun = 'plot_day_summary' ),
640
643
mplDeprecation )
641
644
642
- _plot_day_summary (ax , quotes , ticksize = ticksize ,
645
+ return _plot_day_summary (ax , quotes , ticksize = ticksize ,
643
646
colorup = colorup , colordown = colordown ,
644
647
ochl = True )
645
648
@@ -673,7 +676,7 @@ def plot_day_summary_oclh(ax, quotes, ticksize=3,
673
676
lines : list
674
677
list of tuples of the lines added (one tuple per quote)
675
678
"""
676
- _plot_day_summary (ax , quotes , ticksize = ticksize ,
679
+ return _plot_day_summary (ax , quotes , ticksize = ticksize ,
677
680
colorup = colorup , colordown = colordown ,
678
681
ochl = True )
679
682
@@ -707,7 +710,7 @@ def plot_day_summary_ohlc(ax, quotes, ticksize=3,
707
710
lines : list
708
711
list of tuples of the lines added (one tuple per quote)
709
712
"""
710
- _plot_day_summary (ax , quotes , ticksize = ticksize ,
713
+ return _plot_day_summary (ax , quotes , ticksize = ticksize ,
711
714
colorup = colorup , colordown = colordown ,
712
715
ochl = False )
713
716
@@ -831,8 +834,9 @@ def candlestick(ax, quotes, width=0.2, colorup='k', colordown='r',
831
834
warnings .warn (_warn_str .format (fun = 'candlestick' ),
832
835
mplDeprecation )
833
836
834
- _candlestick (ax , quotes , width = width , colorup = colorup , colordown = colordown ,
835
- alpha = alpha , ochl = True )
837
+ return _candlestick (ax , quotes , width = width , colorup = colorup ,
838
+ colordown = colordown ,
839
+ alpha = alpha , ochl = True )
836
840
837
841
838
842
def candlestick_ochl (ax , quotes , width = 0.2 , colorup = 'k' , colordown = 'r' ,
@@ -870,8 +874,9 @@ def candlestick_ochl(ax, quotes, width=0.2, colorup='k', colordown='r',
870
874
added and patches is a list of the rectangle patches added
871
875
872
876
"""
873
- _candlestick (ax , quotes , width = width , colorup = colorup , colordown = colordown ,
874
- alpha = alpha , ochl = True )
877
+ return _candlestick (ax , quotes , width = width , colorup = colorup ,
878
+ colordown = colordown ,
879
+ alpha = alpha , ochl = True )
875
880
876
881
877
882
def candlestick_ohlc (ax , quotes , width = 0.2 , colorup = 'k' , colordown = 'r' ,
@@ -909,8 +914,9 @@ def candlestick_ohlc(ax, quotes, width=0.2, colorup='k', colordown='r',
909
914
added and patches is a list of the rectangle patches added
910
915
911
916
"""
912
- _candlestick (ax , quotes , width = width , colorup = colorup , colordown = colordown ,
913
- alpha = alpha , ochl = False )
917
+ return _candlestick (ax , quotes , width = width , colorup = colorup ,
918
+ colordown = colordown ,
919
+ alpha = alpha , ochl = False )
914
920
915
921
916
922
def _candlestick (ax , quotes , width = 0.2 , colorup = 'k' , colordown = 'r' ,
0 commit comments