diff --git a/docs/bot-basics.md b/docs/bot-basics.md index abc0e7b16..9fdbdc8a8 100644 --- a/docs/bot-basics.md +++ b/docs/bot-basics.md @@ -24,7 +24,7 @@ By default, loop runs every few seconds (`internals.process_throttle_secs`) and * Fetch open trades from persistence. * Calculate current list of tradable pairs. -* Download OHLCV data for the pairlist including all [informative pairs](strategy-customization.md#get-data-for-non-tradeable-pairs) +* Download OHLCV data for the pairlist including all [informative pairs](strategy-customization.md#get-data-for-non-tradeable-pairs) This step is only executed once per Candle to avoid unnecessary network traffic. * Call `bot_loop_start()` strategy callback. * Analyze strategy per pair. diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 462cf604f..a58878ee7 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -719,14 +719,17 @@ class DigDeeperStrategy(IStrategy): The `adjust_entry_price()` callback may be used by strategy developer to refresh/replace limit orders upon arrival of new candles. Be aware that `custom_entry_price()` is still the one dictating initial entry limit order price target at the time of entry trigger. -!!! Note "Simple Order Cancelation" - This also allows simple cancelation without an replacement order. This behavior occurs when `None` is returned. +Orders can ba cancelled out of this callback by returning `None`. -!!! Note "Maintaining Order" - Maintaining existing order on exchange is facilitated. This behavior occurs when `order.price` is returned. +Returning `current_order_rate` will keep the order on the exchange "as is". +Returning any other price will cancel the existing order, and replace it with a new order. -!!! Warning - Entry `unfilledtimeout` mechanism takes precedence over this. Be sure to update timeout values to match your expectancy. +The trade open-date (`trade.open_date_utc`) will remain at the time of the very first order placed. +Please makes sure to be aware of this - and eventually adjust your logic in other callbacks to account for this, and use the date of the first filled order instead. + +!!! Warning "Regular timeout" + Entry `unfilledtimeout` mechanism (as well as `check_entry_timeout()`) takes precedence over this. + Entry Orders that are cancelled via the above methods will not have this callback called. Be sure to update timeout values to match your expectations. ```python from freqtrade.persistence import Trade @@ -741,7 +744,7 @@ class AwesomeStrategy(IStrategy): entry_tag: Optional[str], side: str, **kwargs) -> float: """ Entry price re-adjustment logic, returning the user desired limit price. - This only executes when a order was already placed, still open(unfilled fully or partially) + This only executes when a order was already placed, still open (unfilled fully or partially) and not timed out on subsequent candles after entry trigger. When not implemented by a strategy, returns current_order_rate as default. diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index aadda6dbd..86dcb1094 100755 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -813,9 +813,6 @@ class Backtesting: cost=stake_amount + trade.fee_open, ) if pos_adjust and self._get_order_filled(order.price, row): - # Update trade open_rate on first filled order - # this is for cases where adjust_entry_order might have replaced the - # initial order from trade opening order.close_bt_order(current_time, trade) else: trade.open_order_id = str(self.order_id_counter) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 367097d71..26efd74a9 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -476,7 +476,7 @@ class IStrategy(ABC, HyperStrategyMixin): entry_tag: Optional[str], side: str, **kwargs) -> float: """ Entry price re-adjustment logic, returning the user desired limit price. - This only executes when a order was already placed, still open(unfilled fully or partially) + This only executes when a order was already placed, still open (unfilled fully or partially) and not timed out on subsequent candles after entry trigger. For full documentation please go to https://www.freqtrade.io/en/latest/strategy-callbacks/ diff --git a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 index 7f9671bb1..014e97cc0 100644 --- a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 +++ b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 @@ -35,7 +35,7 @@ def adjust_entry_price(self, trade: Trade, order: Optional[Order], pair: str, entry_tag: Optional[str], side: str, **kwargs) -> float: """ Entry price re-adjustment logic, returning the user desired limit price. - This only executes when a order was already placed, still open(unfilled fully or partially) + This only executes when a order was already placed, still open (unfilled fully or partially) and not timed out on subsequent candles after entry trigger. For full documentation please go to https://www.freqtrade.io/en/latest/strategy-callbacks/