
    5iI                        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jd                  d	e3d
e3de3de3de4de3de4dejd                  fdZ5	 	 	 ddejd                  d	e3d
e3de3de4de3de4dejd                  fdZ6	 	 	 ddejd                  d	e3d
e3de3de4de3de4dejd                  fdZ7	 	 	 ddejd                  d	e3d
e3de3de3de4de3de4dejd                  fdZ8	 	 ddejd                  de3de4de3dejd                  f
dZ9	 	 	 ddejd                  de3d	e3d
e3de3de3de4de3de4dejd                  fdZ:y)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VolumeWeightedAveragePricedfhighlowclosevolumefillna	colprefix
vectorizedreturnc                 Z   t        | |   | |   | |   | |   |      j                         | | d<   t        | |   | |   |      j                         | | d<   t	        | |   | |   | |   | |   |      j                         | | d<   t        | |   | |   d|      j                         | | d<   t        | |   | |   | |   d	|
      }|j                         | | d<   |j                         | | d<   t        | |   | |   |      j                         | | d<   t        | |   | |   | |   | |   d	|      j                         | | d<   |sYt        | |   | |   | |   | |   d	|      j!                         | | d<   t#        | |   | |   |      j%                         | | 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_eoms	            H/var/www/app/trading-bot/venv/lib/python3.12/site-packages/ta/wrapper.pyadd_volume_tarP   @   s?   6 $9X2c7"U)BvJv$n )J 
 $<i6
6$ )J 
 $=X2c7"U)BvJv$ )J 
 #6i6
2f#km )I
 ,X2c72f:bM #0"@"@"BB)I&3&H&H&JB)M"# $=i6
6$ )J 
 %?XsGi&z% $#% )K ! '3D3U)f:(
 

 	i[
#$ (DU)BvJv(



! 	i[
#$ I    c                 |   t        | |   dd|      }|j                         | | d<   |j                         | | d<   |j                         | | d<   |j	                         | | d<   |j                         | | d<   |j                         | | d	<   |j                         | | d
<   t        | |   | |   | |   d|      }|j                         | | d<   |j                         | | d<   |j                         | | d<   |j                         | | d<   |j                         | | d<   |j                         | | d<   |j                         | | d<   t!        | |   | |   | |   dd|      }	|	j#                         | | d<   |	j%                         | | d<   |	j'                         | | d<   |	j)                         | | d<   |	j+                         | | d<   |sRt-        | |   | |   | |   d|      j/                         | | d<   t1        | |   d|      j3                         | | 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_dcs
             rO   add_volatility_tar      s   2 "iqL (4'B'B'DB)N#$'3'C'C'EB)N#$'3'C'C'EB)N#$'3'C'C'EB)N#$'3'C'C'EB)N#$(4(N(N(PB)O$%(4(N(N(PB)O$% "ibhBsGBvL (4'I'I'KB)N#$'3'I'I'KB)N#$'3'I'I'KB)N#$'3'I'I'KB)N#$'3'I'I'KB)N#$(4(T(T(VB)O$%(4(T(T(VB)O$% #X2c7"U)BqQWL (4'J'J'LB)N#$'3'J'J'LB)N#$'3'J'J'LB)N#$'3'J'J'LB)N#$'3'J'J'LB)N#$+;U)"T(36,



 	i['(
 +5U)Bv+

+- 	i[&' IrQ   c                    t        | |   ddd|      }|j                         | | d<   |j                         | | d<   |j                         | | d<   t	        | |   d|      j                         | | d	<   t	        | |   d|      j                         | | d
<   t        | |   d|      j                         | | d<   t        | |   d|      j                         | | d<   t        | |   | |   | |   d|      }|j                         | | d<   |j                         | | d<   |j                         | | d<   t        | |   d|      j                         | | d<   t        | |   | |   dd|      j                         | | d<   t!        | |   d|      j#                         | | d<   t%        | |   ddddddddd|      }	|	j'                         | | d<   |	j)                         | | d<   |	j+                         | | d<   t-        | |   | |   dddd |!      }
|
j/                         | | d"<   |
j1                         | | d#<   |
j3                         | | d$<   |
j5                         | | d%<   t7        | |   d&d'dd(d(|)      j9                         | | d*<   |st;        | |   | |   | |   d|      }|j=                         | | d+<   |j?                         | | d,<   |jA                         | | d-<   tC        | |   | |   | |   dd.|/      jE                         | | d0<   t-        | |   | |   dddd1|!      }|j3                         | | d2<   |j5                         | | d3<   tG        | |   | |   d|4      }|jI                         | | d5<   |jK                         | | d6<   |jM                         | | d7<   tO        | |   | |   | |   d8d9|:      }|jQ                         | | d;<   |jS                         | | d<<   |jU                         | | d=<   |jW                         | | 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_diffrl   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_indexrS   	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_psars                  rO   add_trend_tar      s   2 iRRQvN $2#6#6#8B)J *8*D*D*FB)%&'(6(@(@(BB)O$% (4i6(mo )N#$ (4i6(mo )N#$
 (4i6(mo )N#$ (4i6(mo )N#$
 'X2c7"U)Bv .>-R-R-TB)()*-=-R-R-TB)()*.>.T.T.VB))*+ $1i6$
df )J 
 *3X2c7r&*jl )$%&
 #/i6#	ce )I
 !iM #0"3"3"5B)I&3&;&;&=B)M"#'4'='='?B)N#$ 'XsGN -;,S,S,UB)'(),:,M,M,OB)'())7)B)B)DB)$%&)7)B)B)DB)$%& #/i# 
ce )I $Dr#wbi6
 '4&7&7&9i[	"#*7*?*?*Ai[&'*7*?*?*Ai[&' '3D3U)'
 #% 	i[	"# !2D3!
 5J4T4T4Vi[/014I4T4T4Vi[/01 )Dr#wr&
 ,;+C+C+Ei['(-<-G-G-Ii[()*,;,K,K,Mi[() 'D3U)
 +9*@*@*Bi[&',:,D,D,Fi[()4B4T4T4Vi[/01 ..0 	k23	
 IrQ   c                    t        | |   d|      j                         | | d<   t        | |   ddd|      }|j                         | | d<   |j	                         | | d<   |j                         | | d<   t        | |   d	d
|      j                         | | d<   t        | |   | |   | |   dddddd|
      j                         | | d<   t        | |   | |   | |   dd|      }	|	j                         | | d<   |	j                         | | d<   t        | |   | |   | |   d|      j                         | | d<   t        | |   | |   dd|      j!                         | | d<   t#        | |   d|      j%                         | | d<   t'        | |   ddd |!      }
|
j)                         | | d"<   |
j+                         | | d#<   |
j-                         | | d$<   t/        | |   ddd |%      }|j1                         | | d&<   |j3                         | | d'<   |j5                         | | d(<   |s't7        | |   d)d*d+|,      j9                         | | 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=   rl   momentum_rsir   )r0   r;   r   r   r2   momentum_stoch_rsimomentum_stoch_rsi_kmomentum_stoch_rsi_dr   r:   )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]   rT   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_pvos               rO   add_momentum_tar#    s.   6 &2i6&	ce )L!"
 'iAqN ,:+B+B+DB)&'(-;-F-F-HB)()*-;-F-F-HB)()* &2iRR&	ce )L!"
 %7XsGi%  )K ! (XsGiL (4'9'9';B)N#$.:.G.G.IB))*+ %7X2c7"U)F%jl )K !
 %?X2c7Ar&% )K !
 &2i6&	ce )L!"
 .iRRQvM &3%6%6%8B)L!",9,D,D,FB)'()*7*@*@*BB)%&' /&zrrqQWM &3%6%6%8B)L!",9,D,D,FB)'()*7*@*@*BB)%&'*7U)BQR+

$& 	i[&' IrQ   c                     t        | |   |      j                         | | d<   t        | |   |      j                         | | d<   t	        | |   |      j                         | | 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   s       rO   add_others_tar,    s    $ #7i#ln )I
 $;i$ )J 
 #<i# )I IrQ   openc	           
          t        | |||||||      } t        | ||||||      } t        | ||||||      } t        | |||||||      } t	        | |||      } | 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   s	            rO   add_all_ta_featuresr/    s    6 
	
B 

B 

B 
	
B 
"E&I	NBIrQ   )F F)Fr0  );__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/   rQ   rO   <module>r=     s       
     
 
 
& T
T
T 
T 	T
 T T T T \\Tx E
E
E 
E 	E
 E E E \\EZ l
l
l 
l 	l
 l l l \\lj k
k
k 
k 	k
 k k k k \\kb 	 
     	 
 \\ T B
B
B B 
	B
 B B B B B \\BrQ   