Advertisement
sgarcia150

Untitled

Sep 10th, 2019
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.86 KB | None | 0 0
  1.  
  2. # --- Do not remove these libs ---
  3. from freqtrade.strategy.interface import IStrategy
  4. from pandas import DataFrame
  5. from technical.indicators import accumulation_distribution
  6. from technical.util import resample_to_interval, resampled_merge
  7. # --------------------------------
  8.  
  9. # Add your lib to import here
  10. import talib.abstract as ta
  11. import freqtrade.vendor.qtpylib.indicators as qtpylib
  12. import numpy  # noqa
  13. from technical.indicators import ichimoku
  14.  
  15.  
  16. # This class is a sample. Feel free to customize it.
  17. class ichis(IStrategy):
  18.  
  19.  
  20.     # Minimal ROI designed for the strategy.
  21.     # This attribute will be overridden if the config file contains "minimal_roi"
  22.     minimal_roi = {
  23.  
  24.         "0": 1
  25.     }
  26.  
  27.     # Optimal stoploss designed for the strategy
  28.     # This attribute will be overridden if the config file contains "stoploss"
  29.     stoploss = -0.1
  30.  
  31.     # trailing stoploss
  32.     trailing_stop = True
  33.     trailing_stop_positive = -0.15
  34.     trailing_stop_positive_offset = 0.20 # Disabled / not configured
  35.     trailing_only_offset_is_reached = True
  36.  
  37.     # Optimal ticker interval for the strategy
  38.     ticker_interval = '15m'
  39.  
  40.     # run "populate_indicators" only for new candle
  41.     process_only_new_candles = False
  42.  
  43.     # Experimental settings (configuration will overide these if set)
  44.     use_sell_signal = True
  45.     sell_profit_only = False
  46.     ignore_roi_if_buy_signal = False
  47.  
  48.     # Optional order type mapping
  49.     order_types = {
  50.         'buy': 'limit',
  51.         'sell': 'limit',
  52.         'stoploss': 'market',
  53.         'stoploss_on_exchange': False
  54.     }
  55.  
  56.     # Optional order time in force
  57.     order_time_in_force = {
  58.         'buy': 'gtc',
  59.         'sell': 'gtc'
  60.     }
  61.  
  62.     def informative_pairs(self):
  63.         """
  64.        Define additional, informative pair/interval combinations to be cached from the exchange.
  65.        These pair/interval combinations are non-tradeable, unless they are part
  66.        of the whitelist as well.
  67.        For more information, please consult the documentation
  68.        :return: List of tuples in the format (pair, interval)
  69.            Sample: return [("ETH/USDT", "5m"),
  70.                            ("BTC/USDT", "15m"),
  71.                            ]
  72.        """
  73.         return []
  74.  
  75.     def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
  76.        
  77.         ichi=ichimoku(dataframe)
  78.         dataframe['tenkan']=ichi['tenkan_sen']
  79.         dataframe['kijun']=ichi['kijun_sen']
  80.         dataframe['senkou_a']=ichi['senkou_span_a']
  81.         dataframe['senkou_b']=ichi['senkou_span_b']
  82.         dataframe['cloud_green']=ichi['cloud_green']
  83.         dataframe['cloud_red']=ichi['cloud_red']
  84.  
  85.         return dataframe
  86.  
  87.     def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
  88.         """
  89.        Based on TA indicators, populates the buy signal for the given dataframe
  90.        :param dataframe: DataFrame populated with indicators
  91.        :param metadata: Additional information, like the currently traded pair
  92.        :return: DataFrame with buy column
  93.        """
  94.        
  95.         dataframe.loc[
  96.             (
  97.                 (dataframe['tenkan'].shift(1)<dataframe['kijun'].shift(1)) &
  98.                 (dataframe['tenkan']>dataframe['kijun']) &
  99.                 (dataframe['cloud_red']==True) &
  100.    
  101.             ),
  102.             'buy'] = 1
  103.  
  104.         return dataframe
  105.  
  106.     def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
  107.         """
  108.        Based on TA indicators, populates the sell signal for the given dataframe
  109.        :param dataframe: DataFrame populated with indicators
  110.        :param metadata: Additional information, like the currently traded pair
  111.        :return: DataFrame with buy column
  112.        """
  113.         dataframe.loc[
  114.             (
  115.                
  116.             ),
  117.             'sell'] = 1
  118.  
  119.         return dataframe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement