From 2014ed381546fafe7743dadb8ff4c29df5ad10c5 Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Mon, 11 May 2026 17:02:02 +0200 Subject: [PATCH] test(protocol): compiler semantica minute_of_hour su 1h --- tests/unit/test_protocol_compiler.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/test_protocol_compiler.py b/tests/unit/test_protocol_compiler.py index d17dbcf..04de7ba 100644 --- a/tests/unit/test_protocol_compiler.py +++ b/tests/unit/test_protocol_compiler.py @@ -183,3 +183,28 @@ def test_compile_is_weekend_returns_zero_one(ohlcv: pd.DataFrame) -> None: weekdays = signal[signal.index.dayofweek < 5] assert (weekend == Side.LONG).all() assert (weekdays == Side.FLAT).all() + + +def test_compile_minute_of_hour_zero_on_1h_timeframe(ohlcv: pd.DataFrame) -> None: + # Fixture has freq=1h, so minute_of_hour is 0 on every row. + # eq(minute_of_hour, 0.0) -> LONG on every row. + src = json.dumps( + { + "rules": [ + { + "condition": { + "op": "eq", + "args": [ + {"kind": "feature", "name": "minute_of_hour"}, + {"kind": "literal", "value": 0.0}, + ], + }, + "action": "entry-long", + } + ] + } + ) + ast = parse_strategy(src) + fn = compile_strategy(ast) + signal = fn(ohlcv) + assert (signal == Side.LONG).all()