Skip to content

Commit 6ee38ad

Browse files
committed
fix: round open_rate to tradable precisionThis prevents odd display issues with 16 decimals in case of multiple entries.
1 parent 6f3dca4 commit 6ee38ad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

freqtrade/persistence/trade_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,11 @@ def recalc_trade_from_orders(self, *, is_closing: bool = False):
12491249
if current_amount_tr > 0.0:
12501250
# Trade is still open
12511251
# Leverage not updated, as we don't allow changing leverage through DCA at the moment.
1252-
self.open_rate = float(current_stake / current_amount)
1252+
self.open_rate = price_to_precision(
1253+
float(current_stake / current_amount),
1254+
self.price_precision,
1255+
self.precision_mode_price,
1256+
)
12531257
self.amount = current_amount_tr
12541258
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
12551259
self.fee_open_cost = self.fee_open * float(self.max_stake_amount)

tests/persistence/test_persistence.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from freqtrade.constants import CUSTOM_TAG_MAX_LENGTH, DATETIME_PRINT_FORMAT
99
from freqtrade.enums import TradingMode
1010
from freqtrade.exceptions import DependencyException
11+
from freqtrade.exchange.exchange_utils import TICK_SIZE
1112
from freqtrade.persistence import LocalTrade, Order, Trade, init_db
1213
from freqtrade.util import dt_now
1314
from tests.conftest import (
@@ -2833,6 +2834,8 @@ def test_recalc_trade_from_orders_dca(data) -> None:
28332834
is_short=False,
28342835
leverage=1.0,
28352836
trading_mode=TradingMode.SPOT,
2837+
price_precision=0.001,
2838+
precision_mode_price=TICK_SIZE,
28362839
)
28372840
Trade.session.add(trade)
28382841

0 commit comments

Comments
 (0)