Use hyperopt safe amount precision method

This commit is contained in:
Matthias
2022-08-20 14:13:15 +02:00
parent 52ec0d1046
commit 5b3f031590
2 changed files with 7 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ from freqtrade.enums import (BacktestState, CandleType, ExitCheckTuple, ExitType
TradingMode)
from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds
from freqtrade.exchange.exchange import amount_to_precision
from freqtrade.mixins import LoggingMixin
from freqtrade.optimize.backtest_caching import get_strategy_run_id
from freqtrade.optimize.bt_progress import BTProgress
@@ -822,8 +823,11 @@ class Backtesting:
self.order_id_counter += 1
base_currency = self.exchange.get_pair_base_currency(pair)
amount_p = (stake_amount / propose_rate) * leverage
amount = self.exchange._contracts_to_amount(pair, self.exchange.amount_to_precision(
pair, self.exchange._amount_to_contracts(pair, amount_p)))
amount = self.exchange._contracts_to_amount(
pair, amount_to_precision(
self.exchange._amount_to_contracts(pair, amount_p),
self.exchange.get_precision_amount(pair), self.precision_mode)
)
# Backcalculate actual stake amount.
stake_amount = amount * propose_rate / leverage