Merge pull request #211 from mablue/addMinimalRoi

Add minimal roi
This commit is contained in:
Matthias
2021-08-17 06:57:44 +02:00
committed by GitHub
4 changed files with 89 additions and 48 deletions
+55 -31
View File
@@ -72,9 +72,11 @@ all_god_genes = {
'PLUS_DM', # Plus Directional Movement
'PPO', # Percentage Price Oscillator
'ROC', # Rate of change : ((price/prevPrice)-1)*100
'ROCP', # Rate of change Percentage: (price-prevPrice)/prevPrice
# Rate of change Percentage: (price-prevPrice)/prevPrice
'ROCP',
'ROCR', # Rate of change ratio: (price/prevPrice)
'ROCR100', # Rate of change ratio 100 scale: (price/prevPrice)*100
# Rate of change ratio 100 scale: (price/prevPrice)*100
'ROCR100',
'RSI', # Relative Strength Index
'STOCH-0', # Stochastic
'STOCH-1', # Stochastic
@@ -82,7 +84,8 @@ all_god_genes = {
'STOCHF-1', # Stochastic Fast
'STOCHRSI-0', # Stochastic Relative Strength Index
'STOCHRSI-1', # Stochastic Relative Strength Index
'TRIX', # 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
# 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
'TRIX',
'ULTOSC', # Ultimate Oscillator
'WILLR', # Williams' %R
},
@@ -166,7 +169,8 @@ all_god_genes = {
'CDLSPINNINGTOP', # Spinning Top
'CDLSTALLEDPATTERN', # Stalled Pattern
'CDLSTICKSANDWICH', # Stick Sandwich
'CDLTAKURI', # Takuri (Dragonfly Doji with very long lower shadow)
# Takuri (Dragonfly Doji with very long lower shadow)
'CDLTAKURI',
'CDLTASUKIGAP', # Tasuki Gap
'CDLTHRUSTING', # Thrusting Pattern
'CDLTRISTAR', # Tristar Pattern
@@ -191,15 +195,15 @@ all_god_genes = {
god_genes = set()
########################### SETTINGS ##############################
god_genes = {'SMA'}
# god_genes |= all_god_genes['Overlap Studies']
# god_genes |= all_god_genes['Momentum Indicators']
# god_genes |= all_god_genes['Volume Indicators']
# god_genes |= all_god_genes['Volatility Indicators']
# god_genes |= all_god_genes['Price Transform']
# god_genes |= all_god_genes['Cycle Indicators']
# god_genes |= all_god_genes['Pattern Recognition']
# god_genes |= all_god_genes['Statistic Functions']
# god_genes = {'SMA'}
god_genes |= all_god_genes['Overlap Studies']
god_genes |= all_god_genes['Momentum Indicators']
god_genes |= all_god_genes['Volume Indicators']
god_genes |= all_god_genes['Volatility Indicators']
god_genes |= all_god_genes['Price Transform']
god_genes |= all_god_genes['Cycle Indicators']
god_genes |= all_god_genes['Pattern Recognition']
god_genes |= all_god_genes['Statistic Functions']
timeperiods = [5, 6, 12, 15, 50, 55, 100, 110]
operators = [
@@ -328,11 +332,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 = (
@@ -349,11 +355,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 = (
@@ -378,7 +386,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 == "/<R":
condition = (
@@ -450,6 +459,18 @@ def condition_generator(dataframe, operator, indicator, crossed_indicator, real_
class GodStraNew(IStrategy):
# #################### RESULTS PASTE PLACE ####################
# ROI table:
minimal_roi = {
"0": 0.598,
"644": 0.166,
"3269": 0.115,
"7289": 0
}
# Stoploss:
stoploss = -0.128
# Buy hypers
timeframe = '4h'
# #################### END OF RESULT PLACE ####################
@@ -473,9 +494,12 @@ class GodStraNew(IStrategy):
buy_operator1 = CategoricalParameter(operators, default="<R", space='buy')
buy_operator2 = CategoricalParameter(operators, default="CB", space='buy')
buy_real_num0 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.89009, space='buy')
buy_real_num1 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.56953, space='buy')
buy_real_num2 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.38365, space='buy')
buy_real_num0 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.89009, space='buy')
buy_real_num1 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.56953, space='buy')
buy_real_num2 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.38365, space='buy')
# Sell Hyperoptable Parameters/Spaces.
sell_crossed_indicator0 = CategoricalParameter(
@@ -492,18 +516,18 @@ class GodStraNew(IStrategy):
sell_indicator2 = CategoricalParameter(
god_genes_with_timeperiod, default="CDL2CROWS-5", space='sell')
sell_operator0 = CategoricalParameter(operators, default="<R", space='sell')
sell_operator0 = CategoricalParameter(
operators, default="<R", space='sell')
sell_operator1 = CategoricalParameter(operators, default="D", space='sell')
sell_operator2 = CategoricalParameter(operators, default="/>R", space='sell')
sell_operator2 = CategoricalParameter(
operators, default="/>R", space='sell')
sell_real_num0 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.09731, space='sell')
sell_real_num1 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.81657, space='sell')
sell_real_num2 = DecimalParameter(0, 1, decimals=DECIMALS, default=0.87267, space='sell')
# Stoploss:
stoploss = -1
# Buy hypers
timeframe = '4h'
sell_real_num0 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.09731, space='sell')
sell_real_num1 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.81657, space='sell')
sell_real_num2 = DecimalParameter(
0, 1, decimals=DECIMALS, default=0.87267, space='sell')
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
'''
+6 -6
View File
@@ -36,13 +36,13 @@ class MultiMa(IStrategy):
}
# Stoploss:
stoploss = -0.1
stoploss = -0.128
# Buy hypers
timeframe = '4h'
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# We will dinamicly generate the indicators
# cuz this method just run one time in hyperopts
# if you have static timeframes you can move first loop of buy and sell trends populators inside this method
@@ -50,11 +50,11 @@ class MultiMa(IStrategy):
return dataframe
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
for i in self.buy_ma_count.range:
dataframe[f'buy-ma-{i+1}'] = ta.SMA(dataframe,
timeperiod=int((i+1) * self.buy_ma_gap.value))
timeperiod=int((i+1) * self.buy_ma_gap.value))
conditions = []
for i in self.buy_ma_count.range:
@@ -75,7 +75,7 @@ class MultiMa(IStrategy):
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
for i in self.sell_ma_count.range:
dataframe[f'sell-ma-{i+1}'] = ta.SMA(dataframe,
timeperiod=int((i+1) * self.sell_ma_gap.value))
timeperiod=int((i+1) * self.sell_ma_gap.value))
conditions = []
+22 -10
View File
@@ -14,27 +14,39 @@ import talib.abstract as ta
class mabStra(IStrategy):
# #################### RESULTS PASTE PLACE ####################
# ROI table:
minimal_roi = {
"0": 0.05,
"0": 0.598,
"644": 0.166,
"3269": 0.115,
"7289": 0
}
# Stoploss:
stoploss = -0.128
# Buy hypers
timeframe = '4h'
# #################### END OF RESULT PLACE ####################
# buy params
buy_mojo_ma_timeframe = IntParameter(2, 100, default=7, space='buy')
buy_fast_ma_timeframe = IntParameter(2, 100, default=14, space='buy')
buy_slow_ma_timeframe = IntParameter(2, 100, default=28, space='buy')
buy_div_max = DecimalParameter(0, 2, decimals=4, default=2.25446, space='buy')
buy_div_min = DecimalParameter(0, 2, decimals=4, default=0.29497, space='buy')
buy_div_max = DecimalParameter(
0, 2, decimals=4, default=2.25446, space='buy')
buy_div_min = DecimalParameter(
0, 2, decimals=4, default=0.29497, space='buy')
# sell params
sell_mojo_ma_timeframe = IntParameter(2, 100, default=7, space='sell')
sell_fast_ma_timeframe = IntParameter(2, 100, default=14, space='sell')
sell_slow_ma_timeframe = IntParameter(2, 100, default=28, space='sell')
sell_div_max = DecimalParameter(0, 2, decimals=4, default=1.54593, space='sell')
sell_div_min = DecimalParameter(0, 2, decimals=4, default=2.81436, space='sell')
stoploss = -0.1
# Optimal timeframe use it in your config
timeframe = '4h'
sell_div_max = DecimalParameter(
0, 2, decimals=4, default=1.54593, space='sell')
sell_div_min = DecimalParameter(
0, 2, decimals=4, default=2.81436, space='sell')
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# SMA - ex Moving Average
+6 -1
View File
@@ -64,7 +64,12 @@ class wtc(IStrategy):
"sell_min0": 0.0628,
"sell_min1": 0.4461,
}
minimal_roi = {
"0": 0.30873,
"569": 0.16689,
"3211": 0.06473,
"7617": 0
}
stoploss = -0.128
############################## END SETTINGS ##############################
timeframe = '30m'