feat: Add funding_fee to backtest results

closes #11699
This commit is contained in:
Matthias
2025-05-03 14:14:32 +02:00
parent 689da4c479
commit f8a151c2a5
3 changed files with 5 additions and 0 deletions

View File

@@ -52,6 +52,7 @@ BT_DATA_COLUMNS = [
"open_timestamp", "open_timestamp",
"close_timestamp", "close_timestamp",
"orders", "orders",
"funding_fees",
] ]
@@ -356,6 +357,8 @@ def _load_backtest_data_df_compatibility(df: pd.DataFrame) -> pd.DataFrame:
df["max_stake_amount"] = df["stake_amount"] df["max_stake_amount"] = df["stake_amount"]
if "orders" not in df.columns: if "orders" not in df.columns:
df["orders"] = None df["orders"] = None
if "funding_fees" not in df.columns:
df["funding_fees"] = 0.0
return df return df

View File

@@ -828,6 +828,7 @@ def test_backtest_one(default_conf, mocker, testdatadir) -> None:
}, },
], ],
], ],
"funding_fees": [0.0, 0.0],
} }
) )
pd.testing.assert_frame_equal(results, expected) pd.testing.assert_frame_equal(results, expected)

View File

@@ -80,6 +80,7 @@ def test_backtest_position_adjustment(default_conf, fee, mocker, testdatadir) ->
"is_short": [False, False], "is_short": [False, False],
"open_timestamp": [1517251200000, 1517283000000], "open_timestamp": [1517251200000, 1517283000000],
"close_timestamp": [1517263200000, 1517285400000], "close_timestamp": [1517263200000, 1517285400000],
"funding_fees": [0.0, 0.0],
} }
) )
results_no = results.drop(columns=["orders"]) results_no = results.drop(columns=["orders"])