From 0da060083614588875784b44889ebdddc70388b5 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 20 Aug 2022 11:24:49 +0200 Subject: [PATCH] Have backtesting respect tradable size closes #7161 --- freqtrade/optimize/backtesting.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 6528481d5..2a96037ac 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -821,7 +821,12 @@ class Backtesting: if stake_amount and (not min_stake_amount or stake_amount > min_stake_amount): self.order_id_counter += 1 base_currency = self.exchange.get_pair_base_currency(pair) - amount = round((stake_amount / propose_rate) * leverage, 8) + 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))) + # Backcalculate actual stake amount. + stake_amount = amount * propose_rate / leverage + is_short = (direction == 'short') # Necessary for Margin trading. Disabled until support is enabled. # interest_rate = self.exchange.get_interest_rate()