fix: round open_rate to tradable precisionThis prevents odd display issues with 16 decimals in case of multiple entries.

This commit is contained in:
Matthias
2024-12-27 19:18:10 +01:00
parent 6f3dca44a3
commit 6ee38adbb5
2 changed files with 8 additions and 1 deletions

View File

@@ -1249,7 +1249,11 @@ class LocalTrade:
if current_amount_tr > 0.0:
# Trade is still open
# Leverage not updated, as we don't allow changing leverage through DCA at the moment.
self.open_rate = float(current_stake / current_amount)
self.open_rate = price_to_precision(
float(current_stake / current_amount),
self.price_precision,
self.precision_mode_price,
)
self.amount = current_amount_tr
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
self.fee_open_cost = self.fee_open * float(self.max_stake_amount)

View File

@@ -8,6 +8,7 @@ from sqlalchemy import select
from freqtrade.constants import CUSTOM_TAG_MAX_LENGTH, DATETIME_PRINT_FORMAT
from freqtrade.enums import TradingMode
from freqtrade.exceptions import DependencyException
from freqtrade.exchange.exchange_utils import TICK_SIZE
from freqtrade.persistence import LocalTrade, Order, Trade, init_db
from freqtrade.util import dt_now
from tests.conftest import (
@@ -2833,6 +2834,8 @@ def test_recalc_trade_from_orders_dca(data) -> None:
is_short=False,
leverage=1.0,
trading_mode=TradingMode.SPOT,
price_precision=0.001,
precision_mode_price=TICK_SIZE,
)
Trade.session.add(trade)