mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
Merge pull request #2786 from freqtrade/fix/stoploss_on_exchange_dryrun
Fix/stoploss on exchange dryrun
This commit is contained in:
commit
d54b1dade3
|
@ -389,9 +389,11 @@ class IStrategy(ABC):
|
|||
trade.adjust_stop_loss(high or current_rate, stop_loss_value)
|
||||
|
||||
# evaluate if the stoploss was hit if stoploss is not on exchange
|
||||
# in Dry-Run, this handles stoploss logic as well, as the logic will not be different to
|
||||
# regular stoploss handling.
|
||||
if ((self.stoploss is not None) and
|
||||
(trade.stop_loss >= current_rate) and
|
||||
(not self.order_types.get('stoploss_on_exchange'))):
|
||||
(not self.order_types.get('stoploss_on_exchange') or self.config['dry_run'])):
|
||||
|
||||
sell_type = SellType.STOP_LOSS
|
||||
|
||||
|
|
|
@ -1318,6 +1318,14 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
|
|||
rate=0.00002344 * 0.95 * 0.99,
|
||||
stop_price=0.00002344 * 0.95)
|
||||
|
||||
# price fell below stoploss, so dry-run sells trade.
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', MagicMock(return_value={
|
||||
'bid': 0.00002144,
|
||||
'ask': 0.00002146,
|
||||
'last': 0.00002144
|
||||
}))
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
|
||||
|
||||
def test_handle_stoploss_on_exchange_trailing_error(mocker, default_conf, fee, caplog,
|
||||
limit_buy_order, limit_sell_order) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user