Remove dataframe parameter from docs.
This commit is contained in:
parent
cdfa6adbe5
commit
6af4de8fe8
@ -60,7 +60,8 @@ from freqtrade.strategy import IStrategy, timeframe_to_prev_date
|
|||||||
|
|
||||||
class AwesomeStrategy(IStrategy):
|
class AwesomeStrategy(IStrategy):
|
||||||
def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float,
|
def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float,
|
||||||
current_profit: float, dataframe: DataFrame, **kwargs):
|
current_profit: float, **kwargs):
|
||||||
|
dataframe = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||||
trade_open_date = timeframe_to_prev_date(self.timeframe, trade.open_date_utc)
|
trade_open_date = timeframe_to_prev_date(self.timeframe, trade.open_date_utc)
|
||||||
trade_row = dataframe.loc[dataframe['date'] == trade_open_date].squeeze()
|
trade_row = dataframe.loc[dataframe['date'] == trade_open_date].squeeze()
|
||||||
|
|
||||||
@ -105,8 +106,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
"""
|
"""
|
||||||
Custom stoploss logic, returning the new distance relative to current_rate (as ratio).
|
Custom stoploss logic, returning the new distance relative to current_rate (as ratio).
|
||||||
e.g. returning -0.05 would create a stoploss 5% below current_rate.
|
e.g. returning -0.05 would create a stoploss 5% below current_rate.
|
||||||
@ -156,8 +156,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
# Make sure you have the longest interval first - these conditions are evaluated from top to bottom.
|
# Make sure you have the longest interval first - these conditions are evaluated from top to bottom.
|
||||||
if current_time - timedelta(minutes=120) > trade.open_date_utc:
|
if current_time - timedelta(minutes=120) > trade.open_date_utc:
|
||||||
@ -183,8 +182,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
if pair in ('ETH/BTC', 'XRP/BTC'):
|
if pair in ('ETH/BTC', 'XRP/BTC'):
|
||||||
return -0.10
|
return -0.10
|
||||||
@ -210,8 +208,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
if current_profit < 0.04:
|
if current_profit < 0.04:
|
||||||
return -1 # return a value bigger than the inital stoploss to keep using the inital stoploss
|
return -1 # return a value bigger than the inital stoploss to keep using the inital stoploss
|
||||||
@ -250,8 +247,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
# evaluate highest to lowest, so that highest possible stop is used
|
# evaluate highest to lowest, so that highest possible stop is used
|
||||||
if current_profit > 0.40:
|
if current_profit > 0.40:
|
||||||
@ -293,8 +289,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
# Default return value
|
# Default return value
|
||||||
result = 1
|
result = 1
|
||||||
@ -302,6 +297,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
# Using current_time directly would only work in backtesting. Live/dry runs need time to
|
# Using current_time directly would only work in backtesting. Live/dry runs need time to
|
||||||
# be rounded to previous candle to be used as dataframe index. Rounding must also be
|
# be rounded to previous candle to be used as dataframe index. Rounding must also be
|
||||||
# applied to `trade.open_date(_utc)` if it is used for `dataframe` indexing.
|
# applied to `trade.open_date(_utc)` if it is used for `dataframe` indexing.
|
||||||
|
dataframe = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||||
current_time = timeframe_to_prev_date(self.timeframe, current_time)
|
current_time = timeframe_to_prev_date(self.timeframe, current_time)
|
||||||
current_row = dataframe.loc[dataframe['date'] == current_time].squeeze()
|
current_row = dataframe.loc[dataframe['date'] == current_time].squeeze()
|
||||||
if 'atr' in current_row:
|
if 'atr' in current_row:
|
||||||
|
@ -631,8 +631,7 @@ Stoploss values returned from `custom_stoploss` must specify a percentage relati
|
|||||||
use_custom_stoploss = True
|
use_custom_stoploss = True
|
||||||
|
|
||||||
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float, dataframe: DataFrame,
|
current_rate: float, current_profit: float, **kwargs) -> float:
|
||||||
**kwargs) -> float:
|
|
||||||
|
|
||||||
# once the profit has risen above 10%, keep the stoploss at 7% above the open price
|
# once the profit has risen above 10%, keep the stoploss at 7% above the open price
|
||||||
if current_profit > 0.10:
|
if current_profit > 0.10:
|
||||||
|
@ -296,7 +296,6 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
:param current_time: datetime object, containing the current datetime
|
:param current_time: datetime object, containing the current datetime
|
||||||
:param current_rate: Rate, calculated based on pricing settings in ask_strategy.
|
:param current_rate: Rate, calculated based on pricing settings in ask_strategy.
|
||||||
:param current_profit: Current profit (as ratio), calculated based on current_rate.
|
:param current_profit: Current profit (as ratio), calculated based on current_rate.
|
||||||
:param dataframe: Analyzed dataframe for this pair. Can contain future data in backtesting.
|
|
||||||
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
||||||
:return float: New stoploss value, relative to the currentrate
|
:return float: New stoploss value, relative to the currentrate
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user