mò Gk‰Ec@s;dklZlZlZlZlZd„Zd„ZdS((s fromstringsargsortstakesarraysresizecCsúd \}}ttd|dƒiƒdƒ}t||idddfƒ}ttd|dƒiƒdƒ}t||idddfƒ}|dd…df|dd…d f}}|dd…df|dd…d f}}||||fS( sª load stock time and price data for two stocks The return values (d1,p1,d2,p2) are the trade time (in days) and prices for stocks 1 and 2 (intc and aapl) tINTCtAAPLs data/%s.dattrbtdiiNi(RR( tticker1tticker2t fromstringtfiletreadtM1tresizetshapetM2td1tp1td2tp2(RRR R RRRR ((tJ/home/jbjuin/Documents/HowToCode/Python/Matplotlib-examples/data_helper.pytget_two_stock_datas " " --csAdfd„ƒY‰‡d†}|dƒ}|dƒ}||fS(s return stock1 and stock2 instances, each of which have attributes open, high, low, close, volume as numeric arrays tCcBstZRS(N(t__name__t __module__(((RR!scsg}td|ƒiƒ}xM|dD]A}|ig}|idƒdD]}|t |ƒqK~ƒq'Wt |ƒ}ˆƒ}|dd…df|_|dd…df|_|dd…df|_|dd…df|_|dd…df|_|S(Ns data/%s.csvit,iiii(tvalsRttickert readlinestlinestlinetappendt_[1]tsplittvaltfloattarraytMRtctopenthightlowtclosetvolume(RR#RR"RRRR(R(Rt get_ticker#s ?  tintctmsftN(RR)tc1tc2(R-RR,R)((RRtget_daily_datas    N(tmatplotlib.numerixRtargsortttakeR!R RR.(RR0R.R1R!RR ((Rt?s%