diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index d1ac47df4..d17b442ab 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2887,7 +2887,7 @@ class Exchange: else: # Fill up missing funding_rate candles with fallback value combined = mark_rates.merge( - funding_rates, on='date', how="outer", suffixes=["_mark", "_fund"] + funding_rates, on='date', how="left", suffixes=["_mark", "_fund"] ) combined['open_fund'] = combined['open_fund'].fillna(futures_funding_rate) return combined diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 168cf512d..34d4ca4c6 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -4314,8 +4314,8 @@ def test_combine_funding_and_mark( assert len(df) == 1 # Empty funding rates - funding_rates = DataFrame([], columns=['date', 'open']) - df = exchange.combine_funding_and_mark(funding_rates, mark_rates, futures_funding_rate) + funding_rates2 = DataFrame([], columns=['date', 'open']) + df = exchange.combine_funding_and_mark(funding_rates2, mark_rates, futures_funding_rate) if futures_funding_rate is not None: assert len(df) == 3 assert df.iloc[0]['open_fund'] == futures_funding_rate @@ -4324,6 +4324,12 @@ def test_combine_funding_and_mark( else: assert len(df) == 0 + # Empty mark candles + mark_candles = DataFrame([], columns=['date', 'open']) + df = exchange.combine_funding_and_mark(funding_rates, mark_candles, futures_funding_rate) + + assert len(df) == 0 + @pytest.mark.parametrize('exchange,rate_start,rate_end,d1,d2,amount,expected_fees', [ ('binance', 0, 2, "2021-09-01 01:00:00", "2021-09-01 04:00:00", 30.0, 0.0),