
    /iI                     |   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j2        de3de3de3de3de4de3de4dej2        fdZ5	 	 	 dd
ej2        de3de3de3de4de3de4dej2        fdZ6	 	 	 dd
ej2        de3de3de3de4de3de4dej2        fdZ7	 	 	 dd
ej2        de3de3de3de3de4de3de4dej2        fdZ8	 	 dd
ej2        de3de4de3dej2        f
dZ9	 	 	 dd
ej2        de3de3de3de3de3de4de3de4dej2        f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                    t          | |         | |         | |         | |         |                                          | | d<   t          | |         | |         |                                          | | d<   t	          | |         | |         | |         | |         |                                          | | d<   t          | |         | |         d|                                          | | d<   t          | |         | |         | |         d	|
          }|	                                | | d<   |
                                | | d<   t          | |         | |         |                                          | | d<   t          | |         | |         | |         | |         d	|                                          | | d<   |s{t          | |         | |         | |         | |         d	|                                          | | d<   t#          | |         | |         |                                          | | 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/   r0   r1   r2   r3   
volume_adi)r1   r2   r3   
volume_obv
volume_cmf   )r1   r2   windowr3   	volume_fi   )r/   r0   r2   r<   r3   	volume_emvolume_sma_em
volume_vpt)r/   r0   r1   r2   r<   r3   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/   r0   r1   r2   r3   r4   r5   indicator_eoms	            P/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ta/wrapper.pyadd_volume_tarQ   @   s   6 $9X2c7"U)BvJv$ $ $n ) 
 $<i6
6$ $ $ ) 
 $=X2c7"U)BvJv$ $ $ ) 
 #6i6
2f# # #kmm )
 ,X2c72f:b  M #0"@"@"B"BB)&3&H&H&J&JB)"""# $=i6
6$ $ $ ) 
 %?XsGi&z% % % $#%% )   !  "'3D3U)f:(
 (
 (
 


 	i###$ (DU)BvJv(
 (
 (



!
! 	i###$ I    c                    t          | |         dd|          }|                                | | d<   |                                | | d<   |                                | | d<   |                                | | d<   |                                | | d<   |                                | | d	<   |                                | | d
<   t          | |         | |         | |         d|          }|	                                | | d<   |
                                | | d<   |                                | | d<   |                                | | d<   |                                | | d<   |                                | | d<   |                                | | d<   t!          | |         | |         | |         dd|          }	|	                                | | d<   |	                                | | d<   |	                                | | d<   |	                                | | d<   |	                                | | d<   |snt-          | |         | |         | |         d|                                          | | d<   t1          | |         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.
          )r1   r<   
window_devr3   volatility_bbmvolatility_bbhvolatility_bblvolatility_bbwvolatility_bbpvolatility_bbhivolatility_bbli
   )r1   r/   r0   r<   r3   volatility_kccvolatility_kchvolatility_kclvolatility_kcwvolatility_kcpvolatility_kchivolatility_kclir   )r/   r0   r1   r<   offsetr3   volatility_dclvolatility_dchvolatility_dcmvolatility_dcwvolatility_dcpvolatility_atrr>   r1   r<   r3   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/   r0   r1   r3   r4   r5   indicator_bbindicator_kcindicator_dcs
             rP   add_volatility_tar      sg   2 "iq  L (4'B'B'D'DB)###$'3'C'C'E'EB)###$'3'C'C'E'EB)###$'3'C'C'E'EB)###$'3'C'C'E'EB)###$(4(N(N(P(PB)$$$%(4(N(N(P(PB)$$$% "ibhBsGBv  L (4'I'I'K'KB)###$'3'I'I'K'KB)###$'3'I'I'K'KB)###$'3'I'I'K'KB)###$'3'I'I'K'KB)###$(4(T(T(V(VB)$$$%(4(T(T(V(VB)$$$% #X2c7"U)BqQW  L (4'J'J'L'LB)###$'3'J'J'L'LB)###$'3'J'J'L'LB)###$'3'J'J'L'LB)###$'3'J'J'L'LB)###$ 	+;U)"T(36,
 ,
 ,

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

+-- 	i&&&' IrR   c                 
   t          | |         ddd|          }|                                | | d<   |                                | | d<   |                                | | d<   t	          | |         d|                                          | | d	<   t	          | |         d|                                          | | d
<   t          | |         d|                                          | | d<   t          | |         d|                                          | | d<   t          | |         | |         | |         d|          }|	                                | | d<   |
                                | | d<   |                                | | d<   t          | |         d|                                          | | d<   t          | |         | |         dd|                                          | | d<   t!          | |         d|                                          | | d<   t%          | |         ddddddddd|          }	|	                                | | d<   |	                                | | d<   |	                                | | d<   t-          | |         | |         dddd |!          }
|
                                | | d"<   |
                                | | d#<   |
                                | | d$<   |
                                | | d%<   t7          | |         d&d'dd(d(|)                                          | | d*<   |st;          | |         | |         | |         d|          }|                                | | d+<   |                                | | d,<   |                                 | | d-<   tC          | |         | |         | |         dd.|/          "                                | | d0<   t-          | |         | |         dddd1|!          }|                                | | d2<   |                                | | d3<   tG          | |         | |         d|4          }|$                                | | d5<   |%                                | | d6<   |&                                | | d7<   tO          | |         | |         | |         d8d9|:          }|(                                | | 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.
          	   r1   window_slowwindow_fastwindow_signr3   
trend_macdtrend_macd_signaltrend_macd_diffrm   trend_sma_fasttrend_sma_slowtrend_ema_fasttrend_ema_slowr>   )r/   r0   r1   r<   r3   trend_vortex_ind_postrend_vortex_ind_negtrend_vortex_ind_diff   
trend_trix   )r/   r0   r   r   r3   trend_mass_indexrT   	trend_dpor^      )r1   roc1roc2roc3roc4window1window2window3window4nsigr3   	trend_ksttrend_kst_sigtrend_kst_diff4   F)r/   r0   r   r   r   visualr3   trend_ichimoku_convtrend_ichimoku_basetrend_ichimoku_atrend_ichimoku_b2         )r1   r   r   cyclesmooth1smooth2r3   	trend_stc	trend_adxtrend_adx_postrend_adx_neggQ?)r/   r0   r1   r<   constantr3   	trend_cciTtrend_visual_ichimoku_atrend_visual_ichimoku_b)r/   r0   r<   r3   trend_aroon_uptrend_aroon_downtrend_aroon_indg{Gz?g?)r/   r0   r1   stepmax_stepr3   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/   r0   r1   r3   r4   r5   indicator_macdindicator_vortexindicator_kstindicator_ichiindicator_adxindicator_ichi_visualindicator_aroonindicator_psars                  rP   add_trend_tar      s   2 iRRQv  N $2#6#6#8#8B) *8*D*D*F*FB)&&&'(6(@(@(B(BB)$$$% (4i6( ( (moo )###$ (4i6( ( (moo )###$
 (4i6( ( (moo )###$ (4i6( ( (moo )###$
 'X2c7"U)Bv   .>-R-R-T-TB))))*-=-R-R-T-TB))))*.>.T.T.V.VB)***+ $1i6$ $ $
dff ) 
 *3X2c7r&* * *jll )%%%&
 #/i6# # #	cee )
 !i  M #0"3"3"5"5B)&3&;&;&=&=B)"""#'4'='='?'?B)###$ 'XsG  N -;,S,S,U,UB)(((),:,M,M,O,OB)((())7)B)B)D)DB)%%%&)7)B)B)D)DB)%%%& #/i# # # 
cee )  71$Dr#wbi6
 
 
 '4&7&7&9&9i"""#*7*?*?*A*Ai&&&'*7*?*?*A*Ai&&&' '3D3U)'
 '
 '
 #%% 	i"""# !2D3!
 !
 !
 5J4T4T4V4Vi00014I4T4T4V4Vi0001 )Dr#wr&
 
 
 ,;+C+C+E+Ei'''(-<-G-G-I-Ii)))*,;,K,K,M,Mi((() 'D3U)
 
 
 +9*@*@*B*Bi&&&',:,D,D,F,Fi((()4B4T4T4V4Vi0001 ..00 	333	
 IrR   c                 (   t          | |         d|                                          | | d<   t          | |         ddd|          }|                                | | d<   |                                | | d<   |                                | | d<   t          | |         d	d
|                                          | | d<   t          | |         | |         | |         dddddd|
  
        	                                | | d<   t          | |         | |         | |         dd|          }	|	                                | | d<   |	                                | | d<   t          | |         | |         | |         d|                                          | | d<   t          | |         | |         dd|                                          | | d<   t#          | |         d|                                          | | d<   t'          | |         ddd |!          }
|
                                | | d"<   |
                                | | d#<   |
                                | | d$<   t/          | |         ddd |%          }|                                | | d&<   |                                | | d'<   |                                | | d(<   |s2t7          | |         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>   rm   momentum_rsir   )r1   r<   r   r   r3   momentum_stoch_rsimomentum_stoch_rsi_kmomentum_stoch_rsi_dr   r;   )r1   r   r   r3   momentum_tsi      g      @g       @g      ?)
r/   r0   r1   r   r   r   weight1weight2weight3r3   momentum_uo)r/   r0   r1   r<   smooth_windowr3   momentum_stochmomentum_stoch_signal)r/   r0   r1   lbpr3   momentum_wr   "   )r/   r0   r   r   r3   momentum_aor   momentum_rocr   r   r   momentum_ppomomentum_ppo_signalmomentum_ppo_hist)r2   r   r   r   r3   momentum_pvomomentum_pvo_signalmomentum_pvo_histr^   rU   r   )r1   r<   pow1pow2r3   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/   r0   r1   r2   r3   r4   r5   indicator_srsiindicator_soindicator_ppoindicator_pvos               rP   add_momentum_tar$    s   6 &2i6& & &	cee )!!!"
 'iAq  N ,:+B+B+D+DB)'''(-;-F-F-H-HB))))*-;-F-F-H-HB))))* &2iRR& & &	cee )!!!"
 %7XsGi% % %  )   ! (XsGi  L (4'9'9';';B)###$.:.G.G.I.IB)***+ %7X2c7"U)F% % %jll )   !
 %?X2c7Ar&% % % )   !
 &2i6& & &	cee )!!!"
 .iRRQv  M &3%6%6%8%8B)!!!",9,D,D,F,FB)((()*7*@*@*B*BB)&&&' /&zrrqQW  M &3%6%6%8%8B)!!!",9,D,D,F,FB)((()*7*@*@*B*BB)&&&' *7U)BQR+
 +
 +

$&& 	i&&&' IrR   c                     t          | |         |                                          | | d<   t          | |         |                                          | | d<   t	          | |         |                                          | | 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.
    )r1   r3   	others_dr
others_dlr	others_cr)r   daily_returnr   daily_log_returnr   cumulative_returnr.   r1   r3   r4   s       rP   add_others_tar-    s    $ #7i# # #lnn )
 $;i$ $ $ ) 
 #<i# # # ) IrR   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/   r0   r1   r2   r3   r4   r5   )r.   r/   r0   r1   r3   r4   r5   r,  )rQ   r   r   r$  r-  )	r.   r.  r/   r0   r1   r2   r3   r4   r5   s	            rP   add_all_ta_featuresr0    s    6 
	
 	
 	
B 

 
 
B 

 
 
B 
	
 	
 	
B 
"E&I	N	N	NBIrR   )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boolrQ   r   r   r$  r-  r0   rR   rP   <module>r=     s:                                         
                                             
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
& T T
T
T 
T 	T
 T T T T \T T T Tx E E
E
E 
E 	E
 E E E \E E E EZ l l
l
l 
l 	l
 l l l \l l l lj k k
k
k 
k 	k
 k k k k \k k k kb 	   
     	 
 \       T B B
B
B B 
	B
 B B B B B \B B B B B BrR   