condensed strategy methods down to 2

This commit is contained in:
Sam Germain
2021-08-18 04:19:17 -06:00
parent d4a7d2d444
commit 092780df9d
22 changed files with 451 additions and 773 deletions

View File

@@ -130,6 +130,19 @@ class DefaultStrategy(IStrategy):
),
'buy'] = 1
dataframe.loc[
(
(dataframe['rsi'] > 65) &
(dataframe['fastd'] > 65) &
(dataframe['adx'] < 70) &
(dataframe['plus_di'] < 0.5) # TODO-lev: What to do here
) |
(
(dataframe['adx'] < 35) &
(dataframe['plus_di'] < 0.5) # TODO-lev: What to do here
),
'enter_short'] = 1
return dataframe
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
@@ -153,37 +166,7 @@ class DefaultStrategy(IStrategy):
(dataframe['minus_di'] > 0.5)
),
'sell'] = 1
return dataframe
def populate_short_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Based on TA indicators, populates the short signal for the given dataframe
:param dataframe: DataFrame
:param metadata: Additional information, like the currently traded pair
:return: DataFrame with short column
"""
dataframe.loc[
(
(dataframe['rsi'] > 65) &
(dataframe['fastd'] > 65) &
(dataframe['adx'] < 70) &
(dataframe['plus_di'] < 0.5) # TODO-lev: What to do here
) |
(
(dataframe['adx'] < 35) &
(dataframe['plus_di'] < 0.5) # TODO-lev: What to do here
),
'short'] = 1
return dataframe
def populate_exit_short_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Based on TA indicators, populates the exit_short signal for the given dataframe
:param dataframe: DataFrame
:param metadata: Additional information, like the currently traded pair
:return: DataFrame with exit_short column
"""
dataframe.loc[
(
(
@@ -198,4 +181,5 @@ class DefaultStrategy(IStrategy):
(dataframe['minus_di'] < 0.5) # TODO-lev: what to do here
),
'exit_short'] = 1
return dataframe

View File

@@ -60,7 +60,7 @@ class HyperoptableStrategy(IStrategy):
'sell_minusdi': 0.4
}
short_params = {
enter_short_params = {
'short_rsi': 65,
}
@@ -87,8 +87,8 @@ class HyperoptableStrategy(IStrategy):
})
return prot
short_rsi = IntParameter([50, 100], default=70, space='sell')
short_plusdi = RealParameter(low=0, high=1, default=0.5, space='sell')
enter_short_rsi = IntParameter([50, 100], default=70, space='sell')
enter_short_plusdi = RealParameter(low=0, high=1, default=0.5, space='sell')
exit_short_rsi = IntParameter(low=0, high=50, default=30, space='buy')
exit_short_minusdi = DecimalParameter(low=0, high=1, default=0.4999, decimals=3, space='buy',
load=False)
@@ -175,6 +175,19 @@ class HyperoptableStrategy(IStrategy):
),
'buy'] = 1
dataframe.loc[
(
(dataframe['rsi'] > self.enter_short_rsi.value) &
(dataframe['fastd'] > 65) &
(dataframe['adx'] < 70) &
(dataframe['plus_di'] < self.enter_short_plusdi.value)
) |
(
(dataframe['adx'] < 35) &
(dataframe['plus_di'] < self.enter_short_plusdi.value)
),
'enter_short'] = 1
return dataframe
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
@@ -198,37 +211,7 @@ class HyperoptableStrategy(IStrategy):
(dataframe['minus_di'] > self.sell_minusdi.value)
),
'sell'] = 1
return dataframe
def populate_short_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Based on TA indicators, populates the short signal for the given dataframe
:param dataframe: DataFrame
:param metadata: Additional information, like the currently traded pair
:return: DataFrame with short column
"""
dataframe.loc[
(
(dataframe['rsi'] > self.short_rsi.value) &
(dataframe['fastd'] > 65) &
(dataframe['adx'] < 70) &
(dataframe['plus_di'] < self.short_plusdi.value)
) |
(
(dataframe['adx'] < 35) &
(dataframe['plus_di'] < self.short_plusdi.value)
),
'short'] = 1
return dataframe
def populate_exit_short_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Based on TA indicators, populates the exit_short signal for the given dataframe
:param dataframe: DataFrame
:param metadata: Additional information, like the currently traded pair
:return: DataFrame with exit_short column
"""
dataframe.loc[
(
(
@@ -243,4 +226,5 @@ class HyperoptableStrategy(IStrategy):
(dataframe['minus_di'] < self.exit_short_minusdi.value)
),
'exit_short'] = 1
return dataframe

View File

@@ -84,35 +84,5 @@ class TestStrategyLegacy(IStrategy):
(dataframe['volume'] > 0)
),
'sell'] = 1
return dataframe
def populate_short_trend(self, dataframe: DataFrame) -> DataFrame:
"""
Based on TA indicators, populates the buy signal for the given dataframe
:param dataframe: DataFrame
:return: DataFrame with buy column
"""
dataframe.loc[
(
(dataframe['adx'] > 30) &
(dataframe['tema'] > dataframe['tema'].shift(1)) &
(dataframe['volume'] > 0)
),
'buy'] = 1
return dataframe
def populate_exit_short_trend(self, dataframe: DataFrame) -> DataFrame:
"""
Based on TA indicators, populates the sell signal for the given dataframe
:param dataframe: DataFrame
:return: DataFrame with buy column
"""
dataframe.loc[
(
(dataframe['adx'] > 70) &
(dataframe['tema'] < dataframe['tema'].shift(1)) &
(dataframe['volume'] > 0)
),
'sell'] = 1
return dataframe