fix: round open_rate to tradable precisionThis prevents odd display issues with 16 decimals in case of multiple entries.
This commit is contained in:
@@ -1249,7 +1249,11 @@ class LocalTrade:
|
|||||||
if current_amount_tr > 0.0:
|
if current_amount_tr > 0.0:
|
||||||
# Trade is still open
|
# Trade is still open
|
||||||
# Leverage not updated, as we don't allow changing leverage through DCA at the moment.
|
# 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.amount = current_amount_tr
|
||||||
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
|
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
|
||||||
self.fee_open_cost = self.fee_open * float(self.max_stake_amount)
|
self.fee_open_cost = self.fee_open * float(self.max_stake_amount)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from sqlalchemy import select
|
|||||||
from freqtrade.constants import CUSTOM_TAG_MAX_LENGTH, DATETIME_PRINT_FORMAT
|
from freqtrade.constants import CUSTOM_TAG_MAX_LENGTH, DATETIME_PRINT_FORMAT
|
||||||
from freqtrade.enums import TradingMode
|
from freqtrade.enums import TradingMode
|
||||||
from freqtrade.exceptions import DependencyException
|
from freqtrade.exceptions import DependencyException
|
||||||
|
from freqtrade.exchange.exchange_utils import TICK_SIZE
|
||||||
from freqtrade.persistence import LocalTrade, Order, Trade, init_db
|
from freqtrade.persistence import LocalTrade, Order, Trade, init_db
|
||||||
from freqtrade.util import dt_now
|
from freqtrade.util import dt_now
|
||||||
from tests.conftest import (
|
from tests.conftest import (
|
||||||
@@ -2833,6 +2834,8 @@ def test_recalc_trade_from_orders_dca(data) -> None:
|
|||||||
is_short=False,
|
is_short=False,
|
||||||
leverage=1.0,
|
leverage=1.0,
|
||||||
trading_mode=TradingMode.SPOT,
|
trading_mode=TradingMode.SPOT,
|
||||||
|
price_precision=0.001,
|
||||||
|
precision_mode_price=TICK_SIZE,
|
||||||
)
|
)
|
||||||
Trade.session.add(trade)
|
Trade.session.add(trade)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user