buy/short -> entry order, sell/exit_short -> exit order

This commit is contained in:
Sam Germain 2021-09-09 02:10:12 -06:00
parent 695a8fc73b
commit f5b01443ad
2 changed files with 15 additions and 15 deletions

View File

@ -352,7 +352,7 @@ class FreqtradeBot(LoggingMixin):
def enter_positions(self) -> int: def enter_positions(self) -> int:
""" """
Tries to execute long buy/short sell orders for new trades (positions) Tries to execute entry orders for new trades (positions)
""" """
trades_created = 0 trades_created = 0
@ -600,7 +600,7 @@ class FreqtradeBot(LoggingMixin):
def _notify_buy(self, trade: Trade, order_type: str) -> None: def _notify_buy(self, trade: Trade, order_type: str) -> None:
""" """
Sends rpc notification when a buy/short occurred. Sends rpc notification when a entry order occurred.
""" """
msg = { msg = {
'trade_id': trade.id, 'trade_id': trade.id,
@ -623,7 +623,7 @@ class FreqtradeBot(LoggingMixin):
def _notify_buy_cancel(self, trade: Trade, order_type: str, reason: str) -> None: def _notify_buy_cancel(self, trade: Trade, order_type: str, reason: str) -> None:
""" """
Sends rpc notification when a buy/short cancel occurred. Sends rpc notification when a entry order cancel occurred.
""" """
current_rate = self.exchange.get_rate(trade.pair, refresh=False, side="buy") current_rate = self.exchange.get_rate(trade.pair, refresh=False, side="buy")
@ -669,7 +669,7 @@ class FreqtradeBot(LoggingMixin):
def exit_positions(self, trades: List[Any]) -> int: def exit_positions(self, trades: List[Any]) -> int:
""" """
Tries to execute sell/exit_short orders for open trades (positions) Tries to execute exit orders for open trades (positions)
""" """
trades_closed = 0 trades_closed = 0
for trade in trades: for trade in trades:
@ -1012,7 +1012,7 @@ class FreqtradeBot(LoggingMixin):
def handle_cancel_sell(self, trade: Trade, order: Dict, reason: str) -> str: def handle_cancel_sell(self, trade: Trade, order: Dict, reason: str) -> str:
""" """
Sell/exit_short cancel - cancel order and update trade exit order cancel - cancel order and update trade
:return: Reason for cancel :return: Reason for cancel
""" """
# if trade is not partially completed, just cancel the order # if trade is not partially completed, just cancel the order

View File

@ -168,7 +168,7 @@ class IStrategy(ABC, HyperStrategyMixin):
""" """
Check buy enter timeout function callback. Check buy enter timeout function callback.
This method can be used to override the enter-timeout. This method can be used to override the enter-timeout.
It is called whenever a limit buy/short order has been created, It is called whenever a limit entry order has been created,
and is not yet fully filled. and is not yet fully filled.
Configuration options in `unfilledtimeout` will be verified before this, Configuration options in `unfilledtimeout` will be verified before this,
so ensure to set these timeouts high enough. so ensure to set these timeouts high enough.
@ -178,7 +178,7 @@ class IStrategy(ABC, HyperStrategyMixin):
:param trade: trade object. :param trade: trade object.
:param order: Order dictionary as returned from CCXT. :param order: Order dictionary as returned from CCXT.
: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 bool: When True is returned, then the buy/short-order is cancelled. :return bool: When True is returned, then the entry order is cancelled.
""" """
return False return False
@ -212,7 +212,7 @@ class IStrategy(ABC, HyperStrategyMixin):
def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time: datetime, **kwargs) -> bool: time_in_force: str, current_time: datetime, **kwargs) -> bool:
""" """
Called right before placing a buy/short order. Called right before placing a entry order.
Timing for this function is critical, so avoid doing heavy computations or Timing for this function is critical, so avoid doing heavy computations or
network requests in this method. network requests in this method.
@ -236,7 +236,7 @@ class IStrategy(ABC, HyperStrategyMixin):
rate: float, time_in_force: str, sell_reason: str, rate: float, time_in_force: str, sell_reason: str,
current_time: datetime, **kwargs) -> bool: current_time: datetime, **kwargs) -> bool:
""" """
Called right before placing a regular sell/exit_short order. Called right before placing a regular exit order.
Timing for this function is critical, so avoid doing heavy computations or Timing for this function is critical, so avoid doing heavy computations or
network requests in this method. network requests in this method.
@ -410,7 +410,7 @@ class IStrategy(ABC, HyperStrategyMixin):
Checks if a pair is currently locked Checks if a pair is currently locked
The 2nd, optional parameter ensures that locks are applied until the new candle arrives, The 2nd, optional parameter ensures that locks are applied until the new candle arrives,
and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap
of 2 seconds for a buy/short to happen on an old signal. of 2 seconds for an entry order to happen on an old signal.
:param pair: "Pair to check" :param pair: "Pair to check"
:param candle_date: Date of the last candle. Optional, defaults to current date :param candle_date: Date of the last candle. Optional, defaults to current date
:returns: locking state of the pair in question. :returns: locking state of the pair in question.
@ -426,7 +426,7 @@ class IStrategy(ABC, HyperStrategyMixin):
def analyze_ticker(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def analyze_ticker(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
""" """
Parses the given candle (OHLCV) data and returns a populated DataFrame Parses the given candle (OHLCV) data and returns a populated DataFrame
add several TA indicators and buy/short signal to it add several TA indicators and entry order signal to it
:param dataframe: Dataframe containing data from exchange :param dataframe: Dataframe containing data from exchange
:param metadata: Metadata dictionary with additional data (e.g. 'pair') :param metadata: Metadata dictionary with additional data (e.g. 'pair')
:return: DataFrame of candle (OHLCV) data with indicator data and signals added :return: DataFrame of candle (OHLCV) data with indicator data and signals added
@ -541,7 +541,7 @@ class IStrategy(ABC, HyperStrategyMixin):
dataframe: DataFrame dataframe: DataFrame
) -> Tuple[bool, bool, Optional[str]]: ) -> Tuple[bool, bool, Optional[str]]:
""" """
Calculates current signal based based on the buy/short or sell/exit_short Calculates current signal based based on the entry order or exit order
columns of the dataframe. columns of the dataframe.
Used by Bot to get the signal to buy, sell, short, or exit_short Used by Bot to get the signal to buy, sell, short, or exit_short
:param pair: pair in format ANT/BTC :param pair: pair in format ANT/BTC
@ -606,7 +606,7 @@ class IStrategy(ABC, HyperStrategyMixin):
sell: bool, low: float = None, high: float = None, sell: bool, low: float = None, high: float = None,
force_stoploss: float = 0) -> SellCheckTuple: force_stoploss: float = 0) -> SellCheckTuple:
""" """
This function evaluates if one of the conditions required to trigger a sell/exit_short This function evaluates if one of the conditions required to trigger an exit order
has been reached, which can either be a stop-loss, ROI or exit-signal. has been reached, which can either be a stop-loss, ROI or exit-signal.
:param low: Only used during backtesting to simulate (long)stoploss/(short)ROI :param low: Only used during backtesting to simulate (long)stoploss/(short)ROI
:param high: Only used during backtesting, to simulate (short)stoploss/(long)ROI :param high: Only used during backtesting, to simulate (short)stoploss/(long)ROI
@ -810,7 +810,7 @@ class IStrategy(ABC, HyperStrategyMixin):
def advise_buy(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def advise_buy(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
""" """
Based on TA indicators, populates the buy/short signal for the given dataframe Based on TA indicators, populates the entry order signal for the given dataframe
This method should not be overridden. This method should not be overridden.
:param dataframe: DataFrame :param dataframe: DataFrame
:param metadata: Additional information dictionary, with details like the :param metadata: Additional information dictionary, with details like the
@ -829,7 +829,7 @@ class IStrategy(ABC, HyperStrategyMixin):
def advise_sell(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def advise_sell(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
""" """
Based on TA indicators, populates the sell/exit_short signal for the given dataframe Based on TA indicators, populates the exit order signal for the given dataframe
This method should not be overridden. This method should not be overridden.
:param dataframe: DataFrame :param dataframe: DataFrame
:param metadata: Additional information dictionary, with details like the :param metadata: Additional information dictionary, with details like the