o
    OÊÆhÌI  ã                   @   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�< |sÎt| | | | | | | | 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   úW/var/www/html/HyperOracle/crypto_trader/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�< |süt| | | | | | 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*�< |�sôt| | | | | | d|d�}| ¡ | |› d+�< | ¡ | |› d,�< |  ¡ | |› d-�< t!| | | | | | dd.|d/� "¡ | |› d0�< t| | | | dddd1|d!�}| ¡ | |› d2�< | ¡ | |› d3�< t#| | d|d�}| $¡ | |› d4�< | %¡ | |› d5�< | &¡ | |› d6�< t'| | | | | | d7d8|d9�}| (¡ | |› 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_diffé4   F)r.   r/   r    r¡   r¢   Úvisualr2   Útrend_ichimoku_convÚtrend_ichimoku_baseÚtrend_ichimoku_aÚtrend_ichimoku_bé2   é   é   )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Útrend_aroon_upÚtrend_aroon_downÚtrend_aroon_indg{®Gáz”?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  sT   ø
ù	ù	ø
ÿ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ùÿþýüûúù
ø 2øÿþýüûúùø	
÷qüÿþýü
û*÷ÿþýüûúùø	÷
ö