Track timedout orders
This commit is contained in:
parent
17d748dd4c
commit
644442e2f9
@ -62,6 +62,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.
|
* 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_sell()` to find custom exit points.
|
* Call `custom_stoploss()` and `custom_sell()` to find custom exit points.
|
||||||
* For sells based on sell-signal and custom-sell: Call `custom_exit_price()` to determine exit price (Prices are moved to be within the closing candle).
|
* For sells based on sell-signal and custom-sell: 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.
|
||||||
* Generate backtest report output
|
* Generate backtest report output
|
||||||
|
|
||||||
!!! Note
|
!!! Note
|
||||||
|
@ -467,7 +467,8 @@ class AwesomeStrategy(IStrategy):
|
|||||||
'sell': 60 * 25
|
'sell': 60 * 25
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool:
|
def check_buy_timeout(self, pair: str, trade: Trade, order: dict,
|
||||||
|
current_time: datetime, **kwargs) -> bool:
|
||||||
ob = self.dp.orderbook(pair, 1)
|
ob = self.dp.orderbook(pair, 1)
|
||||||
current_price = ob['bids'][0][0]
|
current_price = ob['bids'][0][0]
|
||||||
# Cancel buy order if price is more than 2% above the order.
|
# Cancel buy order if price is more than 2% above the order.
|
||||||
@ -476,7 +477,8 @@ class AwesomeStrategy(IStrategy):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool:
|
def check_sell_timeout(self, pair: str, trade: Trade, order: dict,
|
||||||
|
current_time: datetime, **kwargs) -> bool:
|
||||||
ob = self.dp.orderbook(pair, 1)
|
ob = self.dp.orderbook(pair, 1)
|
||||||
current_price = ob['asks'][0][0]
|
current_price = ob['asks'][0][0]
|
||||||
# Cancel sell order if price is more than 2% below the order.
|
# Cancel sell order if price is more than 2% below the order.
|
||||||
|
@ -233,6 +233,7 @@ class Backtesting:
|
|||||||
PairLocks.reset_locks()
|
PairLocks.reset_locks()
|
||||||
Trade.reset_trades()
|
Trade.reset_trades()
|
||||||
self.rejected_trades = 0
|
self.rejected_trades = 0
|
||||||
|
self.timedout_orders = 0
|
||||||
self.dataprovider.clear_cache()
|
self.dataprovider.clear_cache()
|
||||||
if enable_protections:
|
if enable_protections:
|
||||||
self._load_protections(self.strategy)
|
self._load_protections(self.strategy)
|
||||||
@ -646,6 +647,7 @@ class Backtesting:
|
|||||||
|
|
||||||
timedout = self.strategy.ft_check_timed_out(order.side, trade, order, current_time)
|
timedout = self.strategy.ft_check_timed_out(order.side, trade, order, current_time)
|
||||||
if timedout:
|
if timedout:
|
||||||
|
self.timedout_orders += 1
|
||||||
if order.side == 'buy':
|
if order.side == 'buy':
|
||||||
if trade.nr_of_successful_buys == 0:
|
if trade.nr_of_successful_buys == 0:
|
||||||
# Remove trade due to buy timeout expiration.
|
# Remove trade due to buy timeout expiration.
|
||||||
@ -796,6 +798,8 @@ class Backtesting:
|
|||||||
'config': self.strategy.config,
|
'config': self.strategy.config,
|
||||||
'locks': PairLocks.get_all_locks(),
|
'locks': PairLocks.get_all_locks(),
|
||||||
'rejected_signals': self.rejected_trades,
|
'rejected_signals': self.rejected_trades,
|
||||||
|
# TODO: timedout_orders should be shown as part of results.
|
||||||
|
# 'timedout_orders': self.timedout_orders,
|
||||||
'final_balance': self.wallets.get_total(self.strategy.config['stake_currency']),
|
'final_balance': self.wallets.get_total(self.strategy.config['stake_currency']),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user