diff --git a/user_data/strategies/DevilStra.py b/user_data/strategies/DevilStra.py index 97929aa..775ad56 100644 --- a/user_data/strategies/DevilStra.py +++ b/user_data/strategies/DevilStra.py @@ -1,14 +1,24 @@ # DevilStra Strategy -# 𝔇𝔒𝔳𝔦𝔩 𝔦𝔰 π”žπ”©π”΄π”žπ”Άπ”° 𝔰𝔱𝔯𝔬𝔫𝔀𝔒𝔯 𝔱π”₯π”žπ”« π”Šπ”¬π”‘. -# 𝔅𝔲𝔱 𝔱π”₯𝔒 𝔬𝔫𝔩𝔢 𝔬𝔫𝔒 𝔴π”₯𝔬 π”₯π”žπ”° 𝔱π”₯𝔒 π”žπ”Ÿπ”¦π”©π”¦π”±π”Ά -# 𝔱𝔬 π” π”―π”’π”žπ”±π”’ 𝔫𝔒𝔴 π” π”―π”’π”žπ”±π”²π”―π”’π”° 𝔦𝔰 π”Šπ”¬π”‘. -# 𝔄𝔫𝔑 𝔱π”₯𝔒 𝔑𝔒𝔳𝔦𝔩 π”ͺπ”žπ”¨π”’π”° 𝔭𝔬𝔴𝔒𝔯𝔣𝔲𝔩 𝔰𝔭𝔒𝔩𝔩𝔰 -# 𝔣𝔯𝔬π”ͺ 𝔱π”₯𝔦𝔰 𝔰π”ͺπ”žπ”©π”© π” π”―π”’π”žπ”±π”²π”―π”’π”° (𝔩𝔦𝔨𝔒 𝔣𝔯𝔬𝔀𝔰, 𝔒𝔱𝔠.) -# 𝔱𝔬 π”ͺπ”žπ”¨π”’ π”₯𝔦𝔰 𝔰𝔭𝔒𝔩𝔩𝔰 𝔴𝔦𝔱π”₯ π”‰π”―π”žπ”€π”ͺπ”’π”«π”±π”žπ”±π”¦π”¬π”« π”žπ”«π”‘ π”ͺ𝔦𝔡𝔦𝔫𝔀 𝔱π”₯𝔒π”ͺ. +# 𝔇𝔒𝔳𝔦𝔩 𝔦𝔰 π”žπ”©π”΄π”žπ”Άπ”° 𝔰𝔱𝔯𝔬𝔫𝔀𝔒𝔯 𝔱π”₯π”žπ”« π”Šπ”¬π”‘. +# 𝔅𝔲𝔱 𝔱π”₯𝔒 𝔬𝔫𝔩𝔢 𝔬𝔫𝔒 𝔴π”₯𝔬 π”₯π”žπ”° 𝔱π”₯𝔒 π”žπ”Ÿπ”¦π”©π”¦π”±π”Ά +# 𝔗𝔬 π” π”―π”’π”žπ”±π”’ 𝔫𝔒𝔴 π” π”―π”’π”žπ”±π”²π”―π”’π”° 𝔦𝔰 π”Šπ”¬π”‘. +# 𝔄𝔫𝔑 𝔱π”₯𝔒 𝔇𝔒𝔳𝔦𝔩 π”ͺπ”žπ”¨π”’π”° 𝔭𝔬𝔴𝔒𝔯𝔣𝔲𝔩 𝔰𝔭𝔒𝔩𝔩𝔰 +# 𝔉𝔯𝔬π”ͺ 𝔱π”₯𝔦𝔰 𝔰π”ͺπ”žπ”©π”© π” π”―π”’π”žπ”±π”²π”―π”’π”° (𝔩𝔦𝔨𝔒 𝔣𝔯𝔬𝔀𝔰, 𝔒𝔱𝔠.) +# π”šπ”¦π”±π”₯ π”£π”―π”žπ”€π”ͺπ”’π”«π”±π”žπ”±π”¦π”¬π”« π”žπ”«π”‘ π”ͺ𝔦𝔡𝔦𝔫𝔀 𝔱π”₯𝔒π”ͺ. # Author: @Mablue (Masoud Azizi) # github: https://github.com/mablue/ -# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy sell --strategy GodStraNew +# * IMPORTANT: You Need An "STATIC" Pairlist On Your Config.json ! +# * IMPORTANT: First set PAIR_LIST_LENGHT={pair_whitelist size} +# * And re-hyperopt the Sell strategy And paste result in exact +# * place(lines 535~564) + +# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces buy sell -s π•―π–Šπ–›π–Žπ–‘π•Ύπ–™π–—π–† + # --- Do not remove these libs --- +import numpy as np +from functools import reduce +import freqtrade.vendor.qtpylib.indicators as qtpylib +import talib.abstract as ta import random from freqtrade.strategy.hyper import CategoricalParameter, DecimalParameter, IntParameter @@ -16,37 +26,29 @@ from numpy.lib import math from freqtrade.strategy.interface import IStrategy from pandas import DataFrame -# -------------------------------- - -# Add your lib to import here -# TODO: talib is fast but have not more indicators -import talib.abstract as ta -import freqtrade.vendor.qtpylib.indicators as qtpylib -from functools import reduce -import numpy as np -# TODO: this gene is removed 'MAVP' cuz or error on periods - -########################### SETTINGS ############################## -# you can find exact value of is inside GodStra +# ########################## SETTINGS ############################## +# pairlist lenght(use exact count of pairs you used in whitelist size+1): +PAIR_LIST_LENGHT = 269 +# you can find exact value of this inside GodStraNew TREND_CHECK_CANDLES = 4 -# Set the pain range of devil(2~infinite) -PAIN_RANGE = 30000 -# Add GodStra Generated Results As spells inside SPELLS. +# Set the pain range of devil(2~9999) +PAIN_RANGE = 1000 +# Add "GodStraNew" Generated Results As spells inside SPELLS. # Set them unic phonemes like 'Zi' 'Gu' or 'Lu'! -# * Use below replacement on GodStra results to +# * Use below replacement on GodStraNew results to # * Change God Generated Creatures to Spells: -# +--------------------------+----------------------+ -# | GodStra Hyperopt Results | DevilStra Spells | -# +--------------------------+----------------------+ -# | | "phonem" : { | -# | buy_params = { | "buy_params" : { | -# | ... | ... | -# | } | }, | -# | sell_params = { | "sell_params" : { | -# | ... | ... | -# | } | } | -# | | }, | -# +--------------------------+----------------------+ +# +-----------------------------+----------------------+ +# | GodStraNew Hyperopt Results | DevilStra Spells | +# +-----------------------------+----------------------+ +# | | "phonem" : { | +# | buy_params = { | "buy_params" : { | +# | ... | ... | +# | } | }, | +# | sell_params = { | "sell_params" : { | +# | ... | ... | +# | } | } | +# | | }, | +# +-----------------------------+----------------------+ SPELLS = { "Zi": { "buy_params": { @@ -138,7 +140,7 @@ SPELLS = { "sell_real_num2": 0.8467, } }, - "A": { + "La": { "buy_params": { "buy_crossed_indicator0": "WMA-14", "buy_crossed_indicator1": "MAMA-1-14", @@ -319,7 +321,7 @@ SPELLS = { } } } -######################### END SETTINGS ############################ +# ######################## END SETTINGS ############################ def spell_finder(index, space): @@ -406,11 +408,13 @@ def condition_generator(dataframe, operator, indicator, crossed_indicator, real_ # TODO : it ill callculated in populate indicators. dataframe[indicator] = gene_calculator(dataframe, indicator) - dataframe[crossed_indicator] = gene_calculator(dataframe, crossed_indicator) + dataframe[crossed_indicator] = gene_calculator( + dataframe, crossed_indicator) indicator_trend_sma = f"{indicator}-SMA-{TREND_CHECK_CANDLES}" if operator in ["UT", "DT", "OT", "CUT", "CDT", "COT"]: - dataframe[indicator_trend_sma] = gene_calculator(dataframe, indicator_trend_sma) + dataframe[indicator_trend_sma] = gene_calculator( + dataframe, indicator_trend_sma) if operator == ">": condition = ( @@ -427,11 +431,13 @@ def condition_generator(dataframe, operator, indicator, crossed_indicator, real_ elif operator == "C": condition = ( (qtpylib.crossed_below(dataframe[indicator], dataframe[crossed_indicator])) | - (qtpylib.crossed_above(dataframe[indicator], dataframe[crossed_indicator])) + (qtpylib.crossed_above( + dataframe[indicator], dataframe[crossed_indicator])) ) elif operator == "CA": condition = ( - qtpylib.crossed_above(dataframe[indicator], dataframe[crossed_indicator]) + qtpylib.crossed_above( + dataframe[indicator], dataframe[crossed_indicator]) ) elif operator == "CB": condition = ( @@ -456,7 +462,8 @@ def condition_generator(dataframe, operator, indicator, crossed_indicator, real_ ) elif operator == "/=R": condition = ( - np.isclose(dataframe[indicator].div(dataframe[crossed_indicator]), real_num) + np.isclose(dataframe[indicator].div( + dataframe[crossed_indicator]), real_num) ) elif operator == "/ DataFrame: + return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: pairs = self.dp.current_whitelist() + pairs_len = len(pairs) pair_index = pairs.index(metadata['pair']) - buy_params_index = self.buy_spell.value[pair_index] + + buy_spells = self.buy_spell.value.split(",") + buy_spells_len = len(buy_spells) + + if pairs_len > buy_spells_len: + print( + f"First set PAIR_LIST_LENGHT={pairs_len + 1} And re-hyperopt the") + print("Buy strategy And paste result in exact place(lines 535~564)") + print("IMPORTANT: You Need An 'STATIC' Pairlist On Your Config.json !!!") + exit() + + buy_params_index = buy_spells[pair_index] params = spell_finder(buy_params_index, 'buy') conditions = list() @@ -613,7 +647,7 @@ class DevilStra(IStrategy): if conditions: dataframe.loc[ reduce(lambda x, y: x & y, conditions), - 'buy'] = 1 + 'buy']=1 # print(len(dataframe.keys())) @@ -622,8 +656,20 @@ class DevilStra(IStrategy): def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: pairs = self.dp.current_whitelist() + pairs_len = len(pairs) pair_index = pairs.index(metadata['pair']) - sell_params_index = self.sell_spell.value[pair_index] + + sell_spells = self.sell_spell.value.split(",") + sell_spells_len = len(sell_spells) + + if pairs_len > sell_spells_len: + print( + f"First set PAIR_LIST_LENGHT={pairs_len + 1} And re-hyperopt the") + print("Sell strategy And paste result in exact place(lines 535~564)") + print("IMPORTANT: You Need An 'STATIC' Pairlist On Your Config.json !!!") + exit() + + sell_params_index = sell_spells[pair_index] params = spell_finder(sell_params_index, 'sell')