HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pyo
�
�)�Uc
@s�dZddlZddlZddlmZyddlmZWn!ek
reddlmZnXddlZddl	Z
ddlmZm
Z
ddlmZddlmZddlmZmZdd	lmZdd
lmZmZmZddlmZddlmZe
�Zej j!ed
�Z"e
j#de$fde
j%fde
j&fde
j&fde
j'fde
j'fde
j'fde
j'fde
j'fde
j'fde
j'fg�Z(e)e*d�Z+dd�Z-e*e)dd�Z.dddd�Z/d ddd!d"�Z0d#ddd$�Z1d#ddd%d&�Z2ddd#d!d'�Z3ddd#d!d(�Z4ddd#d!d)�Z5d*d+d#d!d,�Z6dS(-so
A collection of modules for collecting, analyzing and plotting
financial data.   User contributions welcome!

i����N(turlopen(tmd5(tverboset
get_configdir(tdate2num(titerable(tLineCollectiontPolyCollection(tcolorConverter(tLine2DtTICKLEFTt	TICKRIGHT(t	Rectangle(tAffine2Ds
finance.cachetdatetyeartmonthtdaytdtopentclosethightlowtvolumetaclosec
Cs�|j�}g}d}x	|dD]�}|jd�}t|�dkrPq#n|d}tjg|jd�D]}	t|	�^qp�}
t|
�}g|dd!D]}	t|	�^q�\}}
}}t|d�}t|d�}|j|
|
j	|
j
|
j||||
|||f�q#W|j�t
j|d	t�}|r�|d
|d}t
j|t
j|�<|dc|9<|dc|9<|d
c|9<|dc|9<n|s�t
jt|�dfd	t
j�}|d|dd�df<|d|dd�df<|d|dd�df<|d
|dd�df<|d|dd�df<|d|dd�df<|dkr�|Sg|D]}t|�^q�S|jt
j�S(s*
    Parse the historical data in file handle fh from yahoo finance.

    *adjusted*
      If True (default) replace open, close, high, and low prices with
      their adjusted values. The adjustment is by a scale factor, S =
      adjusted_close/close. Adjusted prices are actual prices
      multiplied by S.

      Volume is not adjusted as it is already backward split adjusted
      by Yahoo. If you want to compute dollars traded, multiply volume
      by the adjusted close, regardless of whether you choose adjusted
      = True|False.


    *asobject*
      If False (default for compatibility with earlier versions)
      return a list of tuples containing

        d, open, close, high, low, volume

      If None (preferred alternative to False), return
      a 2-D ndarray corresponding to the list of tuples.

      Otherwise return a numpy recarray with

        date, year, month, day, d, open, close, high, low,
        volume, adjusted_close

      where d is a floating poing representation of date,
      as returned by date2num, and date is a python standard
      library datetime.date instance.

      The name of this kwarg is a historical artifact.  Formerly,
      True returned a cbook Bunch
      holding 1-D ndarrays.  The behavior of a numpy recarray is
      very similar to the Bunch.

    s%Y-%m-%dit,iit-iitdtypeRRRRRRNiiiR(t	readlinestsplittlentdatetimeRtintRtfloattappendRRRtreversetnptarraytstock_dttnantisinftzerostNonettupletviewtrecarray(tfhtadjustedtasobjecttlinestresultstdatefmttlinetvalstdatestrtvaltdttdnumRRRRRRRtscaletrettrow((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytparse_yahoo_historical-sH)
12 
$c
Cs�|j�}t|�r:|dd|d|df}n|jd|j|jf}t|�r�|dd|d|df}n|jd|j|jf}d}||d|d|d|d|d|d|f}|d	kr
tjjt	t
|�j��}ntjj|�rEt
|�}tjd||f�n�tjjt	�sgtjt	�nt|�}	t
|d�}|j|	j��|j�tjd||f�t
|d�}|S(
s�
    Fetch historical data for ticker between date1 and date2.  date1 and
    date2 are date or datetime instances, or (year, month, day) sequences.

    Ex:
    fh = fetch_historical_yahoo('^GSPC', (2000, 1, 1), (2001, 12, 31))

    cachename is the name of the local file cache.  If None, will
    default to the md5 hash or the url (which incorporates the ticker
    and date range)

    a file handle is returned
    iiis_http://table.finance.yahoo.com/table.csv?a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&s=%s&y=0&g=d&ignore=.csvsUsing cachefile %s for %stwsSaved %s data to cache file %strN(tupperRRRRR*tostpathtjointcachedirRt	hexdigesttexiststfileRtreporttisdirtmkdirRtwritetreadR(
ttickertdate1tdate2t	cachenametd1td2turlFmtturlR.turlfh((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytfetch_historical_yahoo�s0""$
c	Cszt||||�}y2t|d|d|�}t|�dkrFdSWn,tk
ru}tjd|jd�dSX|S(s�
    Get historical data for ticker between date1 and date2.  date1 and
    date2 are datetime instances or (year, month, day) sequences.

    See :func:`parse_yahoo_historical` for explanation of output formats
    and the *asobject* and *adjusted* kwargs.

    Ex:
    sp = f.quotes_historical_yahoo('^GSPC', d1, d2,
                                asobject=True, adjusted=True)
    returns = (sp.open[1:] - sp.open[:-1])/sp.open[1:]
    [n,bins,patches] = hist(returns, 100)
    mu = mean(returns)
    sigma = std(returns)
    x = normpdf(bins, mu, sigma)
    plot(bins, x, color='red', lw=2)

    cachename is the name of the local file cache.  If None, will
    default to the md5 hash or the url (which incorporates the ticker
    and date range)
    R0R/is
fh failure
%siN(RVR=RR*tIOErrortwarningstwarntstrerror(	RMRNROR0R/RPR.R;texc((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytquotes_historical_yahoo�s	itkR?cCs5g}x|D]}|d \}}}	}
}|	|krA|}n|}td||fd||
fd|dt�}
td||fd||fd|dtdtd|�}td||fd|	|	fd|dtd|dt�}|j|
||f�|j|
�|j|�|j|�q
W|j�|S(s,
    quotes is a sequence of (time, open, close, high, low, ...) sequences

    Represent the time, open, close, high, low as a vertical line
    ranging from low to high.  The left tick is the open and the right
    tick is the close.

    time must be in float date format - see date2num

    ax          : an Axes instance to plot to
    ticksize    : open/close tick marker in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    return value is a list of lines added
    itxdatatydatatcolortantialiasedtmarkert
markersize(R	tFalseR
Rtextendtadd_linetautoscale_view(taxtquotestticksizetcolorupt	colordownR1tqttRRRRR`tvlinetolinetcline((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytplot_day_summary�s8
				


g�������?g�?cCs4|d}g}g}x|D]�}	|	d \}
}}}
}||kra|}|}||}n|}|}||}td|
|
fd||
fddddd	t�}td
|
||fd|d|d
|d|�}|j|�|j|�|j|�|j|�|j|�qW|j�||fS(s�

    quotes is a sequence of (time, open, close, high, low, ...) sequences.
    As long as the first 5 elements are these values,
    the record can be as long as you want (eg it may store volume).

    time must be in float days format - see date2num

    Plot the time, open, close, high, low as a vertical line ranging
    from low to high.  Use a rectangular bar to represent the
    open-close span.  If close >= open, use colorup to color the bar,
    otherwise use colordown

    ax          : an Axes instance to plot to
    width       : fraction of a day for the rectangle width
    colorup     : the color of the rectangle where close >= open
    colordown   : the color of the rectangle where close <  open
    alpha       : the rectangle alpha level

    return value is lines, patches where lines is a list of lines
    added and patches is a list of the rectangle patches added

    g@iR^R_R`R]t	linewidthg�?Ratxytwidththeightt	facecolort	edgecolor(R	tTrueRt	set_alphaR"Rft	add_patchRg(RhRiRuRkRltalphatOFFSETR1tpatchesRmRnRRRRR`tlowerRvRotrect((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytcandlestick!s<



		




ic#CsTgttt|��||�D]3\}}	}
|	dkr||	f||
ff^q}|dfdfg}d
|dffg}
gttt|��|�D]$\}}|dkr�||f^q�}gttt|��|�D]$\}}|dkr�||f^q�}|jjdd}t�j|d�}tj|�\}}}|||df}tj|�\}}}|||df}i|t	6|t
6}gt||�D]4\}}|dkr�|dkr�|||k^q�}d}d}t|d|d|d	|�}t|d|d	|d|d
|d|j�}|j
|�t|
d|d	|d|d
|d|j�}|j
|�dt|�}}tg|D]}	|	dkr�|	^q��} tg|D]}
|
dkr�|
^q��}!|| f||!ff}"|j|"�|j�|j|�|j|�|j|�|||fS(s�

    Represent the time, open, close, high, low as a vertical line
    ranging from low to high.  The left tick is the open and the right
    tick is the close.

    ax          : an Axes instance to plot to
    ticksize    : size of open and close ticks in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open

    return value is a list of lines added
    i����ig�?gR@gitcolorst
linewidthstantialiasedstoffsetsttransOffset(ii(ii(i(i(tziptxrangeRtfiguretdpiR
R:Rtto_rgbRyRdRt	transDatat
set_transformtmintmaxtupdate_datalimRgtadd_collection(#RhtopenstclosesthighstlowsRjRkRltiRRt
rangeSegmentstopenSegmentst
closeSegmentsRtoffsetsOpenRtoffsetsCloseR:t
tickTransformR?tgtbtcolordR�tuseAAtlwtrangeCollectiontopenCollectiontcloseCollectiontminpytmaxxtminytmaxytcorners((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytplot_day_summary2fsXXFF

J			
	
++




g�?c	
Cs�|d}	gttt|��||�D]a\}
}}|dkr)|dkr)|
|	|f|
|	|f|
|	|f|
|	|ff^q)}
gttt|��||�D]3\}
}}|dkr�|
|f|
|ff^q�}tj|�\}}}||||f}tj|�\}}}||||f}i|t6|t6}gt||�D]4\}}|dkr`|dkr`|||k^q`}d}d}t|ddd|d|�}t|
d	|d
dd|d|�}dt|�}}t	g|D]}|dkr|^q�}t
g|D]}|dkr0|^q0�}||f||ff}|j|�|j�|j
|�|j
|�||fS(s�

    Represent the open, close as a bar line and high low range as a
    vertical line.


    ax          : an Axes instance to plot to
    width       : the bar width in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    alpha       : bar transparency

    return value is lineCollection, barCollection
    g@i����ig�?R�iR�R�t
facecolorst
edgecolors(i(g�?(iiii((iiii(iiii((iiii(R�R�RRR�RyRdRRR�R�R�RgR�(RhR�R�R�R�RuRkRlR|tdeltaR�RRtbarVertsRRR�R?R�R�R�R�R�R�R�t
barCollectiontminxR�R�R�R�((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytcandlestick2�s<
�X

J				++



c
Cs~tj|�\}}	}
||	|
|f}tj|�\}}	}
||	|
|f}i|t6|t6}gt||�D]4\}}
|dkrx|
dkrx|||
k^qx}|d}gt|�D]R\}}|dkr�||df|||f|||f||dff^q�}t|d|dddddd
�}dt|�t|�ff}|j	|�|j
�|S(s�
    Add a volume overlay to the current axes.  The opens and closes
    are used to determine the color of the bar.  -1 is missing.  If a
    value is missing on one it must be missing on all

    ax          : an Axes instance to plot to
    width       : the bar width in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    alpha       : bar transparency


    i����g@iR�R�iR�R�g�?(iiii((iiii(i(g�?(ii(RR�RyRdR�t	enumerateRRR�R�Rg(RhR�R�tvolumesRkRlRuR|R?R�R�R�RRR�R�R�tvtbarsR�R�((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlay	s$

J
e		

c	Cs+t||d |d|d||||�S(s
    Add a volume overlay to the current axes.  The closes are used to
    determine the color of the bar.  -1 is missing.  If a value is
    missing on one it must be missing on all

    ax          : an Axes instance to plot to
    width       : the bar width in points
    colorup     : the color of the lines where close >= open
    colordown   : the color of the lines where close <  open
    alpha       : bar transparency

    nb: first point is not displayed - it is used only for choosing the
    right color

    i����i(R�(RhR�R�RkRlRuR|((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlay25sc(Cs�tj|�\}}}||||f}tj|�\}}}||||f}i|t6|t6}	t|�\}
}}}
}}gt|d |d�D]4\}}|dkr�|dkr�|	||k^q�}|jd|	|d|dk�|d}|d}g|D]B\}}}}}}|df||f||f|dff^q}|jjdd}|jj	|j
j	}t�j||�}g|D]\}}}}}}|^q�}
g|
D]}|df^q�}d} d}!t
|d|d	dd
| d|!d|d
|j�}"|"j|�t|
�t|
�}#}$d}%tg|D]\}}}}}}|^q\�}&|#|%f|$|&ff}'|j|'�|j|"�|j�|"S(s�
    Add a volume overlay to the current axes.  quotes is a list of (d,
    open, close, high, low, volume) and close-open is used to
    determine the color of the bar

    kwarg
    width       : the bar width in points
    colorup     : the color of the lines where close1 >= close0
    colordown   : the color of the lines where close1 <  close0
    alpha       : bar transparency


    i����iig@g�?gR@g�?R�R�R�R�R�R�(i(g�?(iiii((iiii(RR�RyRdR�tinsertR�R�tbboxRvtviewLimR
R:RR�R�R�R�R�R�Rg((RhRiRkRlRuR|R?R�R�R�tdatesR�R�R�R�R�tclose0tclose1R�trighttleftRRRRRRR�tsxtsytbarTransformtoffsetsBarsR�R�R�R�R�R�R�R�((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlay3KsF

R"
O+	
1


R�tlcCs�tj||�f}tj||�f}|d}|d}	g|D]<}
|
dkrF|	df|	|
f||
f|dff^qF}|jjdd}|jj|jj}
t�j||
�}gt	|�D]$\}}
|
dkr�|df^q�}t
|d|d|dd
d	dd|d|j�}|j|�dt
|�}}d}tg|D]}
|
dkra|
^qa�}||f||ff}|j|�|j�|j|�|S(s�
    Add a bar collection graph with height vals (-1 is missing).

    ax          : an Axes instance to plot to
    width       : the bar width in points
    alpha       : bar transparency


    g@i����ig�?gR@R�R�R�R�g�?R�R�(i(g�?(Rtto_rgbaR�R�R�RvR�R
R:R�RR�R�RR�R�RgR�(RhR5RwRxRuR|R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pyt	index_bar�s2

I7	
+


(7t__doc__RARXturllib2RthashlibRtImportErrorRtnumpyR$t
matplotlibRRtmatplotlib.datesRtmatplotlib.cbookRtmatplotlib.collectionsRRtmatplotlib.colorsRtmatplotlib.linesR	R
Rtmatplotlib.patchesRtmatplotlib.transformsR
t	configdirRBRCRDRtobjecttint16tint8R!R&RyRdR=R*RVR\RrR�R�R�R�R�R�R�(((sE/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/finance.pyt<module>sd
	Z6(:	D\E+H