From 6bd5535d6c3476d36bafdf73d02926c562546fc6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 21 May 2022 08:31:34 +0200 Subject: [PATCH] Use exchange method to combine funding and mark candles --- freqtrade/exchange/exchange.py | 2 +- freqtrade/optimize/backtesting.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index d2766cd6d..65d9909c6 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2420,7 +2420,7 @@ class Exchange: :param mark_rates: Dataframe containing Mark rates (Type mark_ohlcv_price) """ - return funding_rates.merge(mark_rates, on='date', how="inner", suffixes=["_fund", "_mark"]) + return mark_rates.merge(funding_rates, on='date', how="inner", suffixes=["_mark", "_fund"]) def calculate_funding_fees( self, diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 99bddbf8a..3041136a3 100755 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -296,9 +296,10 @@ class Backtesting: how="outer", suffixes=["_mark", "_fund"])['open_fund'].fillna( self.config.get('futures_funding_rate')) else: - self.futures_data[pair] = mark_rates_dict[pair].merge( - funding_rates_dict[pair], on='date', - how="inner", suffixes=["_mark", "_fund"]) + self.futures_data[pair] = self.exchange.combine_funding_and_mark( + funding_rates=funding_rates_dict[pair], + mark_rates=mark_rates_dict[pair] + ) if unavailable_pairs: raise OperationalException(