mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 20:01:18 +00:00
Update merge to "left" to avoid creating non-existing mark candles
This commit is contained in:
@@ -2887,7 +2887,7 @@ class Exchange:
|
|||||||
else:
|
else:
|
||||||
# Fill up missing funding_rate candles with fallback value
|
# Fill up missing funding_rate candles with fallback value
|
||||||
combined = mark_rates.merge(
|
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)
|
combined['open_fund'] = combined['open_fund'].fillna(futures_funding_rate)
|
||||||
return combined
|
return combined
|
||||||
|
|||||||
@@ -4314,8 +4314,8 @@ def test_combine_funding_and_mark(
|
|||||||
assert len(df) == 1
|
assert len(df) == 1
|
||||||
|
|
||||||
# Empty funding rates
|
# Empty funding rates
|
||||||
funding_rates = DataFrame([], columns=['date', 'open'])
|
funding_rates2 = DataFrame([], columns=['date', 'open'])
|
||||||
df = exchange.combine_funding_and_mark(funding_rates, mark_rates, futures_funding_rate)
|
df = exchange.combine_funding_and_mark(funding_rates2, mark_rates, futures_funding_rate)
|
||||||
if futures_funding_rate is not None:
|
if futures_funding_rate is not None:
|
||||||
assert len(df) == 3
|
assert len(df) == 3
|
||||||
assert df.iloc[0]['open_fund'] == futures_funding_rate
|
assert df.iloc[0]['open_fund'] == futures_funding_rate
|
||||||
@@ -4324,6 +4324,12 @@ def test_combine_funding_and_mark(
|
|||||||
else:
|
else:
|
||||||
assert len(df) == 0
|
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', [
|
@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),
|
('binance', 0, 2, "2021-09-01 01:00:00", "2021-09-01 04:00:00", 30.0, 0.0),
|
||||||
|
|||||||
Reference in New Issue
Block a user