Skip to content

Commit

Permalink
Merge pull request freqtrade#4282 from pan-long/patch-1
Browse files Browse the repository at this point in the history
Fix a bug when compare sell_profit_offset
  • Loading branch information
xmatthias authored Feb 2, 2021
2 parents a69fde3 + 3d9b403 commit fa8156b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions freqtrade/strategy/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ def should_sell(self, trade: Trade, rate: float, date: datetime, buy: bool,
current_time=date))

if (ask_strategy.get('sell_profit_only', False)
and trade.calc_profit(rate=rate) <= ask_strategy.get('sell_profit_offset', 0)):
# Negative profits and sell_profit_only - ignore sell signal
and current_profit <= ask_strategy.get('sell_profit_offset', 0)):
# sell_profit_only and profit doesn't reach the offset - ignore sell signal
sell_signal = False
else:
sell_signal = sell and not buy and ask_strategy.get('use_sell_signal', True)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_freqtradebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3159,9 +3159,9 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order, limit_buy
mocker.patch.multiple(
'freqtrade.exchange.Exchange',
fetch_ticker=MagicMock(return_value={
'bid': 0.00002172,
'ask': 0.00002173,
'last': 0.00002172
'bid': 0.00001172,
'ask': 0.00001173,
'last': 0.00001172
}),
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
Expand Down

0 comments on commit fa8156b

Please sign in to comment.