Update buy_timeout and sell_timeout methods
This commit is contained in:
@@ -32,8 +32,8 @@ By default, loop runs every few seconds (`internals.process_throttle_secs`) and
|
||||
* Call `populate_entry_trend()`
|
||||
* Call `populate_exit_trend()`
|
||||
* Check timeouts for open orders.
|
||||
* Calls `check_buy_timeout()` strategy callback for open entry orders.
|
||||
* Calls `check_sell_timeout()` strategy callback for open exit orders.
|
||||
* Calls `check_entry_timeout()` strategy callback for open entry orders.
|
||||
* Calls `check_exit_timeout()` strategy callback for open exit orders.
|
||||
* Verifies existing positions and eventually places exit orders.
|
||||
* Considers stoploss, ROI and exit-signal, `custom_exit()` and `custom_stoploss()`.
|
||||
* Determine exit-price based on `ask_strategy` configuration setting or by using the `custom_exit_price()` callback.
|
||||
@@ -64,7 +64,7 @@ This loop will be repeated again and again until the bot is stopped.
|
||||
* Check position adjustments for open trades if enabled and call `adjust_trade_position()` to determine if an additional order is requested.
|
||||
* Call `custom_stoploss()` and `custom_exit()` to find custom exit points.
|
||||
* For exits based on exit-signal and custom-exit: Call `custom_exit_price()` to determine exit price (Prices are moved to be within the closing candle).
|
||||
* Check for Order timeouts, either via the `unfilledtimeout` configuration, or via `check_buy_timeout()` / `check_sell_timeout()` strategy callbacks.
|
||||
* Check for Order timeouts, either via the `unfilledtimeout` configuration, or via `check_entry_timeout()` / `check_exit_timeout()` strategy callbacks.
|
||||
* Generate backtest report output
|
||||
|
||||
!!! Note
|
||||
|
@@ -12,7 +12,7 @@ Currently available callbacks:
|
||||
* [`custom_exit()`](#custom-exit-signal)
|
||||
* [`custom_stoploss()`](#custom-stoploss)
|
||||
* [`custom_entry_price()` and `custom_exit_price()`](#custom-order-price-rules)
|
||||
* [`check_buy_timeout()` and `check_sell_timeout()`](#custom-order-timeout-rules)
|
||||
* [`check_entry_timeout()` and `check_exit_timeout()`](#custom-order-timeout-rules)
|
||||
* [`confirm_trade_entry()`](#trade-entry-buy-order-confirmation)
|
||||
* [`confirm_trade_exit()`](#trade-exit-sell-order-confirmation)
|
||||
* [`adjust_trade_position()`](#adjust-trade-position)
|
||||
@@ -408,7 +408,7 @@ However, freqtrade also offers a custom callback for both order types, which all
|
||||
### Custom order timeout example
|
||||
|
||||
Called for every open order until that order is either filled or cancelled.
|
||||
`check_buy_timeout()` is called for trade entries, while `check_sell_timeout()` is called for trade exit orders.
|
||||
`check_entry_timeout()` is called for trade entries, while `check_exit_timeout()` is called for trade exit orders.
|
||||
|
||||
A simple example, which applies different unfilled-timeouts depending on the price of the asset can be seen below.
|
||||
It applies a tight timeout for higher priced assets, while allowing more time to fill on cheap coins.
|
||||
@@ -429,8 +429,8 @@ class AwesomeStrategy(IStrategy):
|
||||
'sell': 60 * 25
|
||||
}
|
||||
|
||||
def check_buy_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
||||
return True
|
||||
elif trade.open_rate > 10 and trade.open_date_utc < current_time - timedelta(minutes=3):
|
||||
@@ -440,7 +440,7 @@ class AwesomeStrategy(IStrategy):
|
||||
return False
|
||||
|
||||
|
||||
def check_sell_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
def check_exit_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
||||
return True
|
||||
@@ -470,8 +470,8 @@ class AwesomeStrategy(IStrategy):
|
||||
'sell': 60 * 25
|
||||
}
|
||||
|
||||
def check_buy_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
def check_entry_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
ob = self.dp.orderbook(pair, 1)
|
||||
current_price = ob['bids'][0][0]
|
||||
# Cancel buy order if price is more than 2% above the order.
|
||||
@@ -480,7 +480,7 @@ class AwesomeStrategy(IStrategy):
|
||||
return False
|
||||
|
||||
|
||||
def check_sell_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
def check_exit_timeout(self, pair: str, trade: Trade, order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
ob = self.dp.orderbook(pair, 1)
|
||||
current_price = ob['asks'][0][0]
|
||||
|
@@ -11,6 +11,8 @@ If you intend on using markets other than spot markets, please migrate your stra
|
||||
* `populate_buy_trend()` -> `populate_entry_trend()`
|
||||
* `populate_sell_trend()` -> `populate_exit_trend()`
|
||||
* `custom_sell()` -> `custom_exit()`
|
||||
* `check_buy_timeout()` -> `check_entry_timeout()`
|
||||
* `check_sell_timeout()` -> `check_exit_timeout()`
|
||||
* Dataframe columns:
|
||||
* `buy` -> `enter_long`
|
||||
* `sell` -> `exit_long`
|
||||
@@ -124,6 +126,32 @@ class AwesomeStrategy(IStrategy):
|
||||
# ...
|
||||
```
|
||||
|
||||
### `custom_entry_timeout`
|
||||
|
||||
`check_buy_timeout()` has been renamed to `check_entry_timeout()`, and `check_sell_timeout()` has been renamed to `check_exit_timeout()`.
|
||||
|
||||
``` python hl_lines="2 6"
|
||||
class AwesomeStrategy(IStrategy):
|
||||
def check_buy_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
return False
|
||||
|
||||
def check_sell_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
return False
|
||||
```
|
||||
|
||||
``` python hl_lines="2 6"
|
||||
class AwesomeStrategy(IStrategy):
|
||||
def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
return False
|
||||
|
||||
def check_exit_timeout(self, pair: str, trade: 'Trade', order: dict,
|
||||
current_time: datetime, **kwargs) -> bool:
|
||||
return False
|
||||
```
|
||||
|
||||
### Custom-stake-amount
|
||||
|
||||
New string argument `side` - which can be either `"long"` or `"short"`.
|
||||
|
Reference in New Issue
Block a user