test: Improved test setup

This commit is contained in:
Matthias
2026-02-01 16:34:54 +01:00
parent ea6d23bd2d
commit 93b6c52aad
+7 -5
View File
@@ -2910,7 +2910,7 @@ def test_close_rate_for_roi(fee, is_short, lev, trading_mode):
""" """
Ensure calc_close_rate_for_roi is consistent with calc_profit_ratio. Ensure calc_close_rate_for_roi is consistent with calc_profit_ratio.
""" """
open_dt = datetime.fromisoformat("1970-01-01 00:00:00") open_dt = datetime.fromisoformat("2022-01-01 00:00:00")
trade_duration = timedelta(days=10) trade_duration = timedelta(days=10)
trade = Trade( trade = Trade(
id=2, id=2,
@@ -2928,8 +2928,10 @@ def test_close_rate_for_roi(fee, is_short, lev, trading_mode):
leverage=lev, leverage=lev,
trading_mode=trading_mode, trading_mode=trading_mode,
interest_rate=0.0005, interest_rate=0.0005,
funding_fees=0.1234,
) )
trade.funding_fee_running = 0.1234 for roi in [0.1337, 0.5, -0.1, 0.25]:
roi = 0.1337 close_rate = trade.calc_close_rate_for_roi(roi)
close_rate = trade.calc_close_rate_for_roi(roi) assert roi == trade.calc_profit_ratio(close_rate), (
assert roi == trade.calc_profit_ratio(close_rate) f"Failed for ROI {roi}, close_rate {close_rate}"
)