o
    ?BiI                     @   s&  d Z ddlZddlmZmZmZmZmZm	Z	m
Z
mZmZmZmZ ddlmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 				d d
ej2de3de3de3de3de4de3de4dej2fddZ5				d d
ej2de3de3de3de4de3de4dej2fddZ6				d d
ej2de3de3de3de4de3de4dej2fddZ7				d d
ej2de3de3de3de3de4de3de4dej2fddZ8			d!d
ej2de3de4de3dej2f
ddZ9				d d
ej2de3de3de3de3de3de4de3de4dej2fddZ:dS )"zm
.. module:: wrapper
   :synopsis: Wrapper of Indicators.

.. moduleauthor:: Dario Lopez Padial (Bukosabino)
    N)AwesomeOscillatorIndicatorKAMAIndicatorPercentagePriceOscillatorPercentageVolumeOscillatorROCIndicatorRSIIndicatorStochasticOscillatorStochRSIIndicatorTSIIndicatorUltimateOscillatorWilliamsRIndicator)CumulativeReturnIndicatorDailyLogReturnIndicatorDailyReturnIndicator)MACDADXIndicatorAroonIndicatorCCIIndicatorDPOIndicatorEMAIndicatorIchimokuIndicatorKSTIndicator	MassIndexPSARIndicatorSMAIndicatorSTCIndicatorTRIXIndicatorVortexIndicator)AverageTrueRangeBollingerBandsDonchianChannelKeltnerChannel
UlcerIndex)	AccDistIndexIndicatorChaikinMoneyFlowIndicatorEaseOfMovementIndicatorForceIndexIndicatorMFIIndicatorNegativeVolumeIndexIndicatorOnBalanceVolumeIndicatorVolumePriceTrendIndicatorVolumeWeightedAveragePriceF dfhighlowclosevolumefillna	colprefix
vectorizedreturnc           	      C   s  t | | | | | | | | |d | | d< t| | | | |d | | d< t| | | | | | | | |d | | d< t| | | | d|d | | d< t| | | | | | d	|d
}|	 | | d< |
 | | d< t| | | | |d | | d< t| | | | | | | | d	|d | | d< |st| | | | | | | | d	|d | | d< t| | | | |d | | d< | S )a/  Add volume technical analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        high (str): Name of 'high' column.
        low (str): Name of 'low' column.
        close (str): Name of 'close' column.
        volume (str): Name of 'volume' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted
        vectorized(bool): if True, use only vectorized functions indicators

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
    )r.   r/   r0   r1   r2   
volume_adi)r0   r1   r2   
volume_obv
volume_cmf   )r0   r1   windowr2   	volume_fi   )r.   r/   r1   r:   r2   	volume_emvolume_sma_em
volume_vpt)r.   r/   r0   r1   r:   r2   volume_vwap
volume_mfi
volume_nvi)r#   acc_dist_indexr)   on_balance_volumer$   chaikin_money_flowr&   force_indexr%   ease_of_movementsma_ease_of_movementr*   volume_price_trendr+   volume_weighted_average_pricer'   money_flow_indexr(   negative_volume_index)	r-   r.   r/   r0   r1   r2   r3   r4   indicator_eom rN   J/var/www/html/Trade-python/venv/lib/python3.10/site-packages/ta/wrapper.pyadd_volume_ta@   sr   	
rP   c           
      C   s  t | | dd|d}| | | d< | | | d< | | | d< | | | d< | | | d< | | | d	< | | | d
< t| | | | | | d|d}|	 | | d< |
 | | d< | | | d< | | | d< | | | d< | | | d< | | | d< t| | | | | | dd|d}	|	 | | d< |	 | | d< |	 | | d< |	 | | d< |	 | | d< |st| | | | | | d|d | | d< t| | d|d | | d< | S )a  Add volatility technical analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        high (str): Name of 'high' column.
        low (str): Name of 'low' column.
        close (str): Name of 'close' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted
        vectorized(bool): if True, use only vectorized functions indicators

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
          )r0   r:   
window_devr2   volatility_bbmvolatility_bbhvolatility_bblvolatility_bbwvolatility_bbpvolatility_bbhivolatility_bbli
   )r0   r.   r/   r:   r2   volatility_kccvolatility_kchvolatility_kclvolatility_kcwvolatility_kcpvolatility_kchivolatility_kclir   )r.   r/   r0   r:   offsetr2   volatility_dclvolatility_dchvolatility_dcmvolatility_dcwvolatility_dcpvolatility_atrr<   r0   r:   r2   volatility_ui)r   bollinger_mavgbollinger_hbandbollinger_lbandbollinger_wbandbollinger_pbandbollinger_hband_indicatorbollinger_lband_indicatorr!   keltner_channel_mbandkeltner_channel_hbandkeltner_channel_lbandkeltner_channel_wbandkeltner_channel_pbandkeltner_channel_hband_indicatorkeltner_channel_lband_indicatorr    donchian_channel_lbanddonchian_channel_hbanddonchian_channel_mbanddonchian_channel_wbanddonchian_channel_pbandr   average_true_ranger"   ulcer_index)
r-   r.   r/   r0   r2   r3   r4   indicator_bbindicator_kcindicator_dcrN   rN   rO   add_volatility_ta   sP   
r   c                 C   s  t | | ddd|d}| | | d< | | | d< | | | d< t| | d|d | | d	< t| | d|d | | d
< t| | d|d | | d< t| | d|d | | d< t| | | | | | d|d}|	 | | d< |
 | | d< | | | d< t| | d|d | | d< t| | | | dd|d | | d< t| | d|d | | d< t| | ddddddddd|d}	|	 | | d< |	 | | d< |	 | | d< t| | | | dddd |d!}
|
 | | d"< |
 | | d#< |
 | | d$< |
 | | d%< t| | d&d'dd(d(|d) | | d*< |st| | | | | | d|d}| | | d+< | | | d,< |  | | d-< t!| | | | | | dd.|d/" | | d0< t| | | | dddd1|d!}| | | d2< | | | d3< t#| | | | d|d4}|$ | | d5< |% | | d6< |& | | d7< t'| | | | | | d8d9|d:}|( | | d;< |) | | d<< |* | | d=< |+ | | d>< | S )?a  Add trend technical analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        high (str): Name of 'high' column.
        low (str): Name of 'low' column.
        close (str): Name of 'close' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted
        vectorized(bool): if True, use only vectorized functions indicators

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
          	   r0   window_slowwindow_fastwindow_signr2   
trend_macdtrend_macd_signaltrend_macd_diffrj   trend_sma_fasttrend_sma_slowtrend_ema_fasttrend_ema_slowr<   )r.   r/   r0   r:   r2   trend_vortex_ind_postrend_vortex_ind_negtrend_vortex_ind_diff   
trend_trix   )r.   r/   r   r   r2   trend_mass_indexrQ   	trend_dpor[      )r0   roc1roc2roc3roc4window1window2window3window4nsigr2   	trend_ksttrend_kst_sigtrend_kst_diff4   F)r.   r/   r   r   r   visualr2   trend_ichimoku_convtrend_ichimoku_basetrend_ichimoku_atrend_ichimoku_b2         )r0   r   r   cyclesmooth1smooth2r2   	trend_stc	trend_adxtrend_adx_postrend_adx_neggQ?)r.   r/   r0   r:   constantr2   	trend_cciTtrend_visual_ichimoku_atrend_visual_ichimoku_b)r.   r/   r:   r2   trend_aroon_uptrend_aroon_downtrend_aroon_indg{Gz?g?)r.   r/   r0   stepmax_stepr2   trend_psar_uptrend_psar_downtrend_psar_up_indicatortrend_psar_down_indicator),r   macdmacd_signal	macd_diffr   sma_indicatorr   ema_indicatorr   vortex_indicator_posvortex_indicator_negvortex_indicator_diffr   trixr   
mass_indexr   dpor   kstkst_sigkst_diffr   ichimoku_conversion_lineichimoku_base_line
ichimoku_a
ichimoku_br   stcr   adxadx_posadx_negr   ccir   aroon_up
aroon_downaroon_indicatorr   psar_up	psar_downpsar_up_indicatorpsar_down_indicator)r-   r.   r/   r0   r2   r3   r4   indicator_macdindicator_vortexindicator_kstindicator_ichiindicator_adxindicator_ichi_visualindicator_aroonindicator_psarrN   rN   rO   add_trend_ta   s  





	

		r   c                 C   sB  t | | d|d | | d< t| | ddd|d}| | | d< | | | d< | | | d< t| | d	d
|d | | d< t| | | | | | dddddd|d
	 | | d< t
| | | | | | dd|d}	|	 | | d< |	 | | d< t| | | | | | d|d | | d< t| | | | dd|d | | d< t| | d|d | | d< t| | ddd |d!}
|
 | | d"< |
 | | d#< |
 | | d$< t| | ddd |d%}| | | d&< | | | d'< | | | d(< |st| | d)d*d+|d, | | d-< | S ).a.  Add trend technical analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        high (str): Name of 'high' column.
        low (str): Name of 'low' column.
        close (str): Name of 'close' column.
        volume (str): Name of 'volume' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted
        vectorized(bool): if True, use only vectorized functions indicators

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
    r<   rj   momentum_rsir   )r0   r:   r   r   r2   momentum_stoch_rsimomentum_stoch_rsi_kmomentum_stoch_rsi_dr   r9   )r0   r   r   r2   momentum_tsi      g      @g       @g      ?)
r.   r/   r0   r   r   r   weight1weight2weight3r2   momentum_uo)r.   r/   r0   r:   smooth_windowr2   momentum_stochmomentum_stoch_signal)r.   r/   r0   lbpr2   momentum_wr   "   )r.   r/   r   r   r2   momentum_aor   momentum_rocr   r   r   momentum_ppomomentum_ppo_signalmomentum_ppo_hist)r1   r   r   r   r2   momentum_pvomomentum_pvo_signalmomentum_pvo_histr[   rR   r   )r0   r:   pow1pow2r2   momentum_kama)r   rsir	   stochrsi
stochrsi_k
stochrsi_dr
   tsir   ultimate_oscillatorr   stochstoch_signalr   
williams_rr   awesome_oscillatorr   rocr   ppo
ppo_signalppo_histr   pvo
pvo_signalpvo_histr   kama)r-   r.   r/   r0   r1   r2   r3   r4   indicator_srsiindicator_soindicator_ppoindicator_pvorN   rN   rO   add_momentum_ta  s   

r  c                 C   s^   t | | |d | | d< t| | |d | | d< t| | |d | | d< | S )aV  Add others analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        close (str): Name of 'close' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
    )r0   r2   	others_dr
others_dlr	others_cr)r   daily_returnr   daily_log_returnr   cumulative_returnr-   r0   r2   r3   rN   rN   rO   add_others_ta  s    r'  openc	           	   
   C   sp   t | |||||||d} t| ||||||d} t| ||||||d} t| |||||||d} t| |||d} | S )aW  Add all technical analysis features to dataframe.

    Args:
        df (pandas.core.frame.DataFrame): Dataframe base.
        open (str): Name of 'open' column.
        high (str): Name of 'high' column.
        low (str): Name of 'low' column.
        close (str): Name of 'close' column.
        volume (str): Name of 'volume' column.
        fillna(bool): if True, fill nan values.
        colprefix(str): Prefix column names inserted
        vectorized(bool): if True, use only vectorized functions indicators

    Returns:
        pandas.core.frame.DataFrame: Dataframe with new features.
    )r-   r.   r/   r0   r1   r2   r3   r4   )r-   r.   r/   r0   r2   r3   r4   r&  )rP   r   r   r  r'  )	r-   r(  r.   r/   r0   r1   r2   r3   r4   rN   rN   rO   add_all_ta_features  sP   
		
r)  )Fr,   F)Fr,   );__doc__pandaspdta.momentumr   r   r   r   r   r   r   r	   r
   r   r   	ta.othersr   r   r   ta.trendr   r   r   r   r   r   r   r   r   r   r   r   r   r   ta.volatilityr   r   r    r!   r"   	ta.volumer#   r$   r%   r&   r'   r(   r)   r*   r+   	DataFramestrboolrP   r   r   r  r'  r)  rN   rN   rN   rO   <module>   s   4@,	
\
M
 6	
q
*	
