Don't update trade fees for dry-run orders

This commit is contained in:
Matthias 2021-01-17 20:31:27 +01:00
parent 389db2fe7d
commit a8bae3a381
2 changed files with 17 additions and 0 deletions

View File

@ -268,6 +268,10 @@ class FreqtradeBot(LoggingMixin):
Update closed trades without close fees assigned.
Only acts when Orders are in the database, otherwise the last orderid is unknown.
"""
if self.config['dry_run']:
# Updating open orders in dry-run does not make sense and will fail.
return
trades: List[Trade] = Trade.get_sold_trades_without_assigned_fees()
for trade in trades:

View File

@ -4368,6 +4368,19 @@ def test_update_closed_trades_without_assigned_fees(mocker, default_conf, fee):
freqtrade.update_closed_trades_without_assigned_fees()
# Does nothing for dry-run
trades = Trade.get_trades().all()
assert len(trades) == MOCK_TRADE_COUNT
for trade in trades:
assert trade.fee_open_cost is None
assert trade.fee_open_currency is None
assert trade.fee_close_cost is None
assert trade.fee_close_currency is None
freqtrade.config['dry_run'] = False
freqtrade.update_closed_trades_without_assigned_fees()
trades = Trade.get_trades().all()
assert len(trades) == MOCK_TRADE_COUNT