def parse_yahoo_historical(fh, asobject=False, adjusted=True):
results = []<EOL>lines = fh.readlines()<EOL>datefmt = None<EOL>for line in lines[<NUM_LIT:1>:]:<EOL><INDENT>vals = line.split('<STR_LIT:U+002C>')<EOL>if len(vals)!=<NUM_LIT:7>: continue<EOL>datestr = vals[<NUM_LIT:0>]<EOL>if datefmt is None:<EOL><INDENT>try:<EOL><INDENT>datefmt = '<STR_LIT>'<EOL>dt = datetime.date(*time.strptime(datestr, datefmt)[:<NUM_LIT:3>])<EOL><DEDENT>except ValueError:<EOL><INDENT>datefmt = '<STR_LIT>'  <EOL><DEDENT><DEDENT>dt = datetime.date(*time.strptime(datestr, datefmt)[:<NUM_LIT:3>])<EOL>d = date2num(dt)<EOL>open, high, low, close =  [float(val) for val in vals[<NUM_LIT:1>:<NUM_LIT:5>]]<EOL>volume = int(vals[<NUM_LIT:5>])<EOL>if adjusted:<EOL><INDENT>aclose = float(vals[<NUM_LIT:6>])<EOL>m = aclose/close<EOL>open *= m<EOL>high *= m<EOL>low *= m<EOL>close = aclose<EOL><DEDENT>results.append((d, open, close, high, low, volume))<EOL><DEDENT>results.reverse()<EOL>if asobject:<EOL><INDENT>if len(results)==<NUM_LIT:0>: return None<EOL>else:<EOL><INDENT>date, open, close, high, low, volume = list(map(np.asarray, list(zip(*results))))<EOL><DEDENT>return Bunch(date=date, open=open, close=close, high=high, low=low, volume=volume)<EOL><DEDENT>else:<EOL><INDENT>return results<EOL><DEDENT>
Parse the historical data in file handle fh from yahoo finance and return
results as a list of

d, open, close, high, low, volume

where d is a floating poing representation of date, as returned by date2num

if adjust=True, use adjusted prices