
    ^iC                         d dl Zd dlZd dlmZmZmZ d dlmZ d dl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mZmZ d dlmZ d dlm Z   G d de          Z!dS )	    N)datetime	timedeltatimezone)	DataFrame)OptionalUnion)	IStrategyTradeOrder	PairLocksinformativeBooleanParameterCategoricalParameterDecimalParameterIntParameterRealParametertimeframe_to_minutestimeframe_to_next_datetimeframe_to_prev_datemerge_informative_pairstoploss_from_absolutestoploss_from_open)qtpylibc                   n   e Zd ZU dZdZdZeed<   ddddZd	Z	dZ
d
ZdZdZdZdZ edddddd          Z edddddd          Z edddddd          Z edddddd          ZdZeed<   dddddZdddZi ddiddd idd!id"d#dd$iid%d&Zd' Zd(ed)ed*efd+Zd(ed)ed*efd,Zd(ed)ed*efd-Zd.S )/SampleStrategyaq  
    This is a sample strategy to inspire you.
    More information in https://www.freqtrade.io/en/latest/strategy-customization/

    You can:
        :return: a Dataframe with all mandatory indicators for the strategies
    - Rename the class name (Do not forget to update class_name)
    - Add any methods you want to build your strategy
    - Add any lib you need to build your strategy

    You must keep:
    - the lib in the section "Do not remove these libs"
    - the methods: populate_indicators, populate_entry_trend, populate_exit_trend
    You should keep:
    - timeframe, minimal_roi, stoploss, trailing_*
       F	can_shortg{Gz?g{Gz?g{Gz?)60300g5mT   2      buy)lowhighdefaultspaceoptimizeloadd   F   sell3   exit   startup_candle_countlimitmarket)entryr0   stoplossstoploss_on_exchangeGTC)r5   r0   colorwhite)temasarblueorange)macd
macdsignalrsired)MACDRSI)	main_plotsubplotsc                     g S )a  
        Define additional, informative pair/interval combinations to be cached from the exchange.
        These pair/interval combinations are non-tradeable, unless they are part
        of the whitelist as well.
        For more information, please consult the documentation
        :return: List of tuples in the format (pair, interval)
            Sample: return [("ETH/USDT", "5m"),
                            ("BTC/USDT", "15m"),
                            ]
         )selfs    Y/var/www/html/cicciotrading.cuttalo.com/freqtrade/user_data/strategies/sample_strategy.pyinformative_pairsz SampleStrategy.informative_pairs   s	     	    	dataframemetadatareturnc                    t          j        |          |d<   t          j        |          |d<   t          j        |          }|d         |d<   |d         |d<   t          j        |          }|d         |d<   |d         |d<   |d         |d<   t          j        |          |d<   t          j        t          j        |          d	d
          }|d         |d<   |d         |d<   |d         |d<   |d         |d         z
  |d         |d         z
  z  |d<   |d         |d         z
  |d         z  |d<   t          j	        |          |d<   t          j
        |d          |d<   t          j        |          }|d         |d<   |d         |d<   	 |S )a:  
        Adds several different TA indicators to the given DataFrame

        Performance Note: For the best performance be frugal on the number of indicators
        you are using. Let uncomment only the indicator you are using in your strategies
        or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
        :param dataframe: Dataframe with data from the exchange
        :param metadata: Additional information, like the currently traded pair
        :return: a Dataframe with all mandatory indicators for the strategies
        adxrA   fastdfastkr?   r@   macdhistmfi      )windowstdslowerbb_lowerbandmidbb_middlebandupperbb_upperbandclose
bb_percentbb_widthr<   	   )
timeperiodr;   sinehtsineleadsine
htleadsine)taADXrD   STOCHFrC   MFIr   bollinger_bandstypical_priceSARTEMAHT_SINE)rI   rM   rN   
stoch_fastr?   	bollingerhilberts          rJ   populate_indicatorsz"SampleStrategy.populate_indicators   s     6),,	%N 6),,	% Yy))
'0	''0	' wy!! L	&"&|"4	, $Z 0	* 6),,	% +G,A),L,LUW^_```	$-g$6	.!%.u%5	/"$-g$6	.!#,W#5	.8Q#Qn%	.(AA#
	, "+>!:Y~=V!VZc[
 !
	*J 6),,	% GI!<<<	&
 *Y''%fo	(")*"5	,t	 rL   c                    d|j         t          j        |d         | j        j                  |d         |d         k    z  |d         |d                             d          k    z  |d         dk    z  df<   d|j         t          j        |d         | j        j                  |d         |d         k    z  |d         |d                             d          k     z  |d         dk    z  df<   |S )	a  
        Based on TA indicators, populates the entry signal for the given dataframe
        :param dataframe: DataFrame
        :param metadata: Additional information, like the currently traded pair
        :return: DataFrame with entry columns populated
        r"   rA   r;   r]   volumer   
enter_longenter_short)locr   crossed_abovebuy_rsivalueshift	short_rsirI   rM   rN   s      rJ   populate_entry_trendz#SampleStrategy.populate_entry_trendn  s      	 &y'79KLLV$	/(BBDV$y'8'>'>q'A'AAC X&*,
 		
(  	 &y'79MNNV$y'AACV$y'8'>'>q'A'AAC X&*,
 		
 rL   c                    d|j         t          j        |d         | j        j                  |d         |d         k    z  |d         |d                             d          k     z  |d         dk    z  df<   d|j         t          j        |d         | j        j                  |d         |d         k    z  |d         |d                             d          k    z  |d         dk    z  df<   |S )	a  
        Based on TA indicators, populates the exit signal for the given dataframe
        :param dataframe: DataFrame
        :param metadata: Additional information, like the currently traded pair
        :return: DataFrame with exit columns populated
        r"   rA   r;   r]   rw   r   	exit_long
exit_short)rz   r   r{   sell_rsir}   r~   exit_short_rsir   s      rJ   populate_exit_trendz"SampleStrategy.populate_exit_trend  s!      	 &y'79LMMV$y'AACV$y'8'>'>q'A'AAC X&*,
 		
,  	 &y'79L9RSS 6"i&@@B V$y'8'>'>q'A'AA	C
 X&*, 		
 rL   N) __name__
__module____qualname____doc__INTERFACE_VERSIONr   bool__annotations__minimal_roir6   trailing_stop	timeframeprocess_only_new_candlesuse_exit_signalexit_profit_onlyignore_roi_if_entry_signalr   r|   r   r   r   r2   intorder_typesorder_time_in_forceplot_configrK   r   dictru   r   r   rH   rL   rJ   r   r   (   s(         &  It 	 K H M I  $ O!& lqr2UTX\]]]G|bQU\`aaaH#rRV]abbbI!\B&4d  N
 !$####  %	 K %*599 W%
 
 !&)&1 
 '
 
 K   ZY Z$ Z9 Z Z Z Zxi 4 I    >Y $ 9      rL   r   )"numpynppandaspdr   r   r   r   typingr   r   freqtrade.strategyr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   talib.abstractabstractri   	technicalr   r   rH   rL   rJ   <module>r      s  
         2 2 2 2 2 2 2 2 2 2       " " " " " " " "                                   0            D D D D DY D D D D DrL   