# Zeus Strategy: First Generation of GodStra Strategy with maximum # AVG/MID profit in USDT # Author: @Mablue (Masoud Azizi) # github: https://github.com/mablue/ # IMPORTANT: INSTALL TA BEFOUR RUN(pip install ta) # freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy sell roi --strategy Zeus # --- Do not remove these libs --- from freqtrade.strategy.parameters import CategoricalParameter, DecimalParameter from freqtrade.strategy.interface import IStrategy from pandas import DataFrame # -------------------------------- # Add your lib to import here import ta from functools import reduce import numpy as np import talib.abstract as talib from freqtrade.strategy.strategy_helper import merge_informative_pair import freqtrade.vendor.qtpylib.indicators as qtpylib class Zeus(IStrategy): # * 1/43: 86 trades. 72/6/8 Wins/Draws/Losses. Avg profit 12.66%. Median profit 11.99%. Total profit 0.10894395 BTC ( 108.94Σ%). Avg duration 3 days, 0:31:00 min. Objective: -48.48793 # "max_open_trades": 10, # "stake_currency": "BTC", # "stake_amount": 0.01, # "tradable_balance_ratio": 0.99, # "timeframe": "4h", # "dry_run_wallet": 0.1, # Buy hyperspace params: buy_params = { "buy_cat": "R", "=R", "R", "=R", " DataFrame: # Add all ta features dataframe['trend_ichimoku_base'] = ta.trend.ichimoku_base_line( dataframe['high'], dataframe['low'], window1=9, window2=26, visual=False, fillna=False ) KST = ta.trend.KSTIndicator( close=dataframe['close'], roc1=10, roc2=15, roc3=20, roc4=30, window1=10, window2=10, window3=10, window4=15, nsig=9, fillna=False ) dataframe['trend_kst_diff'] = KST.kst_diff() dataframe['pct_change'] = dataframe['close'].pct_change(5) dataframe['min10'] = talib.MIN(dataframe['close'], timeperiod=10) dataframe['min20'] = talib.MIN(dataframe['close'], timeperiod=20) dataframe['min50'] = talib.MIN(dataframe['close'], timeperiod=50) dataframe['min200'] = talib.MIN(dataframe['close'], timeperiod=200) # Normalization tib = dataframe['trend_ichimoku_base'] dataframe['trend_ichimoku_base'] = (tib-tib.min())/(tib.max()-tib.min()) tkd = dataframe['trend_kst_diff'] dataframe['trend_kst_diff'] = (tkd-tkd.min())/(tkd.max()-tkd.min()) informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe="1d") informative["rsi"] = talib.RSI(informative) informative["max3"] = talib.MAX(informative['close'], timeperiod=3) informative["min3"] = talib.MIN(informative['close'], timeperiod=3) informative['pct_change_1'] = informative['close'].pct_change(1) informative['pct_change_3'] = informative['close'].pct_change(3) informative['pct_change_5'] = informative['close'].pct_change(5) bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(informative), window=20, stds=2) informative['bb_lowerband'] = bollinger['lower'] informative['bb_middleband'] = bollinger['mid'] informative['bb_upperband'] = bollinger['upper'] informative["bb_percent"] = ( (informative["close"] - informative["bb_lowerband"]) / (informative["bb_upperband"] - informative["bb_lowerband"]) ) informative["bb_width"] = ( (informative["bb_upperband"] - informative["bb_lowerband"]) / informative["bb_middleband"] ) dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True) return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: conditions = [] IND = 'trend_ichimoku_base' REAL = self.buy_real.value OPR = self.buy_cat.value DFIND = dataframe[IND] # print(DFIND.mean()) if OPR == ">R": conditions.append(DFIND > REAL) elif OPR == "=R": conditions.append(np.isclose(DFIND, REAL)) elif OPR == " self.buy_pct_1.value) & (dataframe['pct_change_3_1d'] > self.buy_pct_3.value) & (dataframe['pct_change_5_1d'] > self.buy_pct_5.value) #& (dataframe['close_1d'] < dataframe['bb_lowerband_1d'] * self.buy_bb_lowerband.value) & (dataframe['bb_width_1d'] >= self.buy_bb_width.value) , 'buy'] = 1 return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # conditions = [] # IND = 'trend_kst_diff' # REAL = self.sell_real.value # OPR = self.sell_cat.value # DFIND = dataframe[IND] # # print(DFIND.mean()) # # if OPR == ">R": # conditions.append(DFIND > REAL) # elif OPR == "=R": # conditions.append(np.isclose(DFIND, REAL)) # elif OPR == "