KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux server112.speedpacket.com 3.10.0-962.3.2.lve1.5.36.el7.x86_64 #1 SMP Mon May 18 02:16:06 EDT 2020 x86_64
User : equistyl ( 1341)
PHP Version : 8.1.30
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/matplotlib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/matplotlib/finance.pyc
�
r`]c
@ s�dZddlmZmZddlZddlZddlZddlmZej	ddkrvddl
mZnddl
Z
d�ZddlZddl
Zdd	lmZmZdd
lmZddlmZmZddlmZmZdd
lmZddlmZmZmZddl m!Z!ddl"m#Z#e�Z$ej%j&e$d�Z'ej(de)fdej*fdej+fdej+fdej,fdej,fdej,fdej,fdej,fdej,fdej,fg�Z-e.e/d�Z0de/d�Z2e/e.dd�Z3dd d!d"�Z4d#d d!d$d%�Z5d&d d!d'�Z6d&d d!d(d)�Z7d d!d&d$d*�Z8d d!d&d$d+�Z9d d!d&d$d,�Z:d-d.d&d$d/�Z;dS(0so
A collection of modules for collecting, analyzing and plotting
financial data.   User contributions welcome!

i����(tdivisiontprint_functionN(turlopenii(tmd5cC stj|j��S(N(thashlibRtencode(tx((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pyt<lambda>s(tverboset
get_configdir(tdate2num(titerabletmkdirs(tLineCollectiontPolyCollection(tcolorConverter(tLine2DtTICKLEFTt	TICKRIGHT(t	Rectangle(tAffine2Ds
finance.cachetdatetyeartmonthtdaytdtopentclosethightlowtvolumetaclosec
C s�|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	readlinestsplittlentdatetimeRtintR
tfloattappendRRRtreversetnptarraytstock_dttnantisinftzerostNonettupletviewtrecarray(tfhtadjustedtasobjecttlinestresultstdatefmttlinetvalstdatestrtvaltdttdnumRRRRRRRtscaletrettrow((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytparse_yahoo_historical/sH)
12 
$c	C s�|j�}t|�r:|dd|d|df}n|jd|j|jf}t|�r�|dd|d|df}n|jd|j|jf}|r�d}tjd�nd}d}||d|d|d|d|d|d||f}	|dkr2tj	j
tt|	�j
��}ntj	j|�rjt|�}
tjd||f�nhtt�t|	�}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)
    
    set dividends=True to return dividends instead of price data.  With
    this option set, parse functions will not work

    a file handle is returned
    iiitvs&Retrieving dividends instead of pricesRs`http://table.finance.yahoo.com/table.csv?a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&s=%s&y=0&g=%s&ignore=.csvsUsing cachefile %s for %stwbsSaved %s data to cache file %strN(tupperRRRRRtreportR1tostpathtjointcachedirRt	hexdigesttexistsRRRtwritetreadR(ttickertdate1tdate2t	cachenamet	dividendstd1td2tgturlFmtturlR5turlfh((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytfetch_historical_yahoo�s6"""$

c	C szt||||�}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)
    R7R6is
fh failure
%siN(R]RDR%R1tIOErrortwarningstwarntstrerror(	RRRSRTR7R6RUR5RBtexc((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytquotes_historical_yahoo�s	tkRGcC s5g}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(RtFalseRRtextendtadd_linetautoscale_view(taxtquotestticksizetcolorupt	colordownR8tqttRRRRRgtvlinetolinetcline((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytplot_day_summary�s8
				


g�������?g�?cC s4|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@iReRfRgRdt	linewidthg�?Rhtxytwidththeightt	facecolort	edgecolor(RtTrueRt	set_alphaR)Rmt	add_patchRn(RoRpR|RrRstalphatOFFSETR8tpatchesRtRuRRRRRgtlowerR}Rvtrect((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytcandlestick+s<



		




ic#C s�gttt|��||�D]3\}}	}
|	dkr||	f||
ff^q}|dfdfg}d
|dffg}
gttt|��|�D]$\}}|dkr�||f^q�}gttt|��|�D]$\}}|dkr�||f^q�}|jjd}t�j|d�}tj|�\}}}|||df}tj|�\}}}|||df}i|t	6|t
6}gt||�D]4\}}|dkr�|dkr�|||k^q�}t|�t|�kst�t|�t|�ks"t�t|�t|�ks@t�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(iig�q�q�?(i(i(tziptxrangeR%tfiguretdpiRRARtto_rgbR�RktAssertionErrorR
t	transDatat
set_transformtmintmaxtupdate_datalimRntadd_collection(#RotopenstclosesthighstlowsRqRrRstiRRt
rangeSegmentstopenSegmentst
closeSegmentsRtoffsetsOpenRtoffsetsCloseRAt
tickTransformRGRYtbtcolordR�tuseAAtlwtrangeCollectiontopenCollectiontcloseCollectiontminpytmaxxtminytmaxytcorners((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytplot_day_summary2ps^XFF

J			
	
++




g�?c	
C s�|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`}t|
�t|�ks�t�d}d}t|ddd|d|�}t	|
d	|d
dd|d|�}dt|�}}t
g|D]}|dkr#|^q#�}tg|D]}|dkrN|^qN�}||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�R%RR�R�RkR�R
RR�R�R�RnR�(RoR�R�R�R�R|RrRsR�tdeltaR�RRtbarVertsRRR�RGRYR�R�R�R�R�R�t
barCollectiontminxR�R�R�R�((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytcandlestick2�s>
�X

J				++



c
C s~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�R�RkR�t	enumerateRR%R�R�Rn(RoR�R�tvolumesRrRsR|R�RGRYR�R�RRR�R�R�REtbarsR�R�((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlays$

J
e		

c	C s+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�(RoR�R�RrRsR|R�((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlay2?sc(C s�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}|jjd}|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]\}}}}}}|^qX�}&|#|%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�g�q�q�?(i(g�?(iiii((iiii(RR�R�RkR�tinsertR�R�tbboxR}tviewLimRRARR�R�R�R�R�R�Rn((RoRpRrRsR|R�RGRYR�R�tdatesR�R�R�R�R�tclose0tclose1R�trighttleftRRRRRRR�tsxtsytbarTransformtoffsetsBarsR�R�R�R�R�R�R�R�((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pytvolume_overlay3UsF

R"
O+	
1


R�tlcC s�tj||�f}tj||�f}|d}|d}	g|D]<}
|
dkrF|	df|	|
f||
f|dff^qF}|jjd
}|jj|jj}
t�j||
�}gt	|�D]$\}}
|
dkr�|df^q�}t
|d|d|ddd	dd|d|j�}|j|�dt
|�}}d}tg|D]}
|
dkr]|
^q]�}||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�g�q�q�?(i(g�?(Rtto_rgbaR�R�R�R}R�RRAR�RR�R�R%R�R�RnR�(RoR<R~RR|R�R�R�R�R�RER�R�R�R�R�R�R�R�R�R�R�R�((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pyt	index_bar�s2

I7	
+


(<t__doc__t
__future__RRRJtsysR_turllib2Rtversion_infoRRR&tnumpyR+t
matplotlibRR	tmatplotlib.datesR
tmatplotlib.cbookRRtmatplotlib.collectionsR
Rtmatplotlib.colorsRtmatplotlib.linesRRRtmatplotlib.patchesRtmatplotlib.transformsRt	configdirRKRLRMR"tobjecttint16tint8R(R-R�RkRDR1R]RcRyR�R�R�R�R�R�R�(((s8/usr/lib64/python2.7/site-packages/matplotlib/finance.pyt<module>sf$		Z>(:	D\E+H

Anon7 - 2021