From d299b18666362e7f7dd9dbb718db54d94d6aa72b Mon Sep 17 00:00:00 2001 From: Masoud Azizi Date: Tue, 18 May 2021 22:09:58 +0430 Subject: [PATCH] zeus hyperoptable strategy is up --- user_data/strategies/Zeus.py | 149 +++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 user_data/strategies/Zeus.py diff --git a/user_data/strategies/Zeus.py b/user_data/strategies/Zeus.py new file mode 100644 index 0000000..64dd4c5 --- /dev/null +++ b/user_data/strategies/Zeus.py @@ -0,0 +1,149 @@ +# 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 trailing --strategy Zeus +# --- Do not remove these libs --- +import logging +from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter + +from numpy.lib import math +from freqtrade.strategy.interface import IStrategy +from pandas import DataFrame +# -------------------------------- + +# Add your lib to import here +# import talib.abstract as ta +import pandas as pd +import ta +from ta.utils import dropna +import freqtrade.vendor.qtpylib.indicators as qtpylib +from functools import reduce +import numpy as np + + +class Zeus(IStrategy): + + # 53/167: 167 trades. 96/66/5 Wins/Draws/Losses. Avg profit 3.00%. Median profit 2.70%. Total profit 0.16479843 BTC ( 164.80Σ%). Avg duration 22:04:00 min. Objective: -63.49577 + + # Buy hyperspace params: + buy_params = { + "buy_cat": "R", "=R", "R", "=R", " DataFrame: + # Add all ta features + # Clean NaN values + dataframe = dropna(dataframe) + + 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() + + # 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()) + 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 == " 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 == "