fix: align daily matrix ranking universe
This commit is contained in:
@@ -1127,6 +1127,53 @@ def test_replay_ticker_candidates_carry_gate_fields():
|
||||
assert all(c["ranking_period"][0] == "date" for c in daily_cands)
|
||||
|
||||
|
||||
def test_slim_replay_can_retain_shorts_for_ranking_universe(monkeypatch):
|
||||
setup = {
|
||||
"entry": 100.0,
|
||||
"stop": 95.0,
|
||||
"target": 110.0,
|
||||
"rr": 2.0,
|
||||
"confidence": 80.0,
|
||||
"primary_prob": 0.6,
|
||||
"best_prob": 0.7,
|
||||
"momentum": 0.1,
|
||||
"meets_core": True,
|
||||
"action": "BUY_MODERATE",
|
||||
"risk_level": "MEDIUM",
|
||||
}
|
||||
monkeypatch.setattr(
|
||||
bt,
|
||||
"_window_setups",
|
||||
lambda *_args, **_kwargs: [
|
||||
{**setup, "direction": "long"},
|
||||
{**setup, "direction": "short", "stop": 105.0, "target": 90.0},
|
||||
],
|
||||
)
|
||||
count = bt.MIN_LOOKBACK + bt.HORIZON
|
||||
first_ord = date(2025, 1, 1).toordinal()
|
||||
columns = (
|
||||
list(range(first_ord, first_ord + count)),
|
||||
[100.0] * count,
|
||||
[101.0] * count,
|
||||
[99.0] * count,
|
||||
[100.0] * count,
|
||||
[1_000_000] * count,
|
||||
)
|
||||
|
||||
long_only = bt._replay_candidates_for_period(
|
||||
"AAA", columns, {}, {}, None, date.min, "daily"
|
||||
)
|
||||
full_ranking_universe = bt._replay_candidates_for_period(
|
||||
"AAA", columns, {}, {}, None, date.min, "daily", True
|
||||
)
|
||||
|
||||
assert [row["direction"] for row in long_only] == ["long"]
|
||||
assert {row["direction"] for row in full_ranking_universe} == {
|
||||
"long",
|
||||
"short",
|
||||
}
|
||||
|
||||
|
||||
def test_daily_replay_uses_exact_date_ranking_periods():
|
||||
candidates = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user