Added short and exit_short to strategy
This commit is contained in:
@@ -154,3 +154,48 @@ class DefaultStrategy(IStrategy):
|
||||
),
|
||||
'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[
|
||||
(
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['rsi'], 30)) |
|
||||
(qtpylib.crossed_below(dataframe['fastd'], 30))
|
||||
) &
|
||||
(dataframe['adx'] < 90) &
|
||||
(dataframe['minus_di'] < 0) # TODO-lev: what to do here
|
||||
) |
|
||||
(
|
||||
(dataframe['adx'] > 30) &
|
||||
(dataframe['minus_di'] < 0.5) # TODO-lev: what to do here
|
||||
),
|
||||
'exit_short'] = 1
|
||||
return dataframe
|
||||
|
@@ -60,6 +60,15 @@ class HyperoptableStrategy(IStrategy):
|
||||
'sell_minusdi': 0.4
|
||||
}
|
||||
|
||||
short_params = {
|
||||
'short_rsi': 65,
|
||||
}
|
||||
|
||||
exit_short_params = {
|
||||
'exit_short_rsi': 26,
|
||||
'exit_short_minusdi': 0.6
|
||||
}
|
||||
|
||||
buy_rsi = IntParameter([0, 50], default=30, space='buy')
|
||||
buy_plusdi = RealParameter(low=0, high=1, default=0.5, space='buy')
|
||||
sell_rsi = IntParameter(low=50, high=100, default=70, space='sell')
|
||||
@@ -78,6 +87,12 @@ 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')
|
||||
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)
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
@@ -167,7 +182,7 @@ class HyperoptableStrategy(IStrategy):
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
:return: DataFrame with sell column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
@@ -184,3 +199,48 @@ class HyperoptableStrategy(IStrategy):
|
||||
),
|
||||
'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[
|
||||
(
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['rsi'], self.exit_short_rsi.value)) |
|
||||
(qtpylib.crossed_below(dataframe['fastd'], 30))
|
||||
) &
|
||||
(dataframe['adx'] < 90) &
|
||||
(dataframe['minus_di'] < 0) # TODO-lev: What should this be
|
||||
) |
|
||||
(
|
||||
(dataframe['adx'] < 30) &
|
||||
(dataframe['minus_di'] < self.exit_short_minusdi.value)
|
||||
),
|
||||
'exit_short'] = 1
|
||||
return dataframe
|
||||
|
@@ -85,3 +85,34 @@ class TestStrategyLegacy(IStrategy):
|
||||
),
|
||||
'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
|
||||
|
Reference in New Issue
Block a user