From fb519a5b39d77fbdb6ab445d472433d258e9f053 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 21 Nov 2021 10:25:58 +0100 Subject: [PATCH] Add comment with reasoning to ignore leverage in min_amount calculation --- freqtrade/freqtradebot.py | 6 ++++-- freqtrade/optimize/backtesting.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 12b9d6f65..4a1f5085f 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -606,12 +606,14 @@ class FreqtradeBot(LoggingMixin): if not enter_limit_requested: raise PricingError(f'Could not determine {side} price.') + # Min-stake-amount should actually include Leverage - this way our "minimal" + # stake- amount might be higher than necessary. + # We do however also need min-stake to determine leverage, therefore this is ignored as + # edge-case for now. min_stake_amount = self.exchange.get_min_pair_stake_amount( pair, enter_limit_requested, self.strategy.stoploss, - # TODO-lev: This is problematic... we need stake-amount to determine max_leverage - # leverage=leverage ) if not self.edge: diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 611d521a3..10d90591c 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -368,6 +368,10 @@ class Backtesting: def _get_sell_trade_entry_for_candle(self, trade: LocalTrade, sell_row: Tuple) -> Optional[LocalTrade]: + # TODO-lev: add interest / funding fees to trade object -> + # Must be done either here, or one level higher -> + # (if we don't want to do it at "detail" level) + sell_candle_time = sell_row[DATE_IDX].to_pydatetime() enter = sell_row[SHORT_IDX] if trade.is_short else sell_row[LONG_IDX] exit_ = sell_row[ESHORT_IDX] if trade.is_short else sell_row[ELONG_IDX]