feat(protocol): dispatcher temporal features (hour) in compiler

This commit is contained in:
2026-05-11 16:59:26 +02:00
parent 0e9489bf88
commit 9d1f97cff3
2 changed files with 33 additions and 0 deletions
+24
View File
@@ -106,3 +106,27 @@ def test_compile_two_rules_priority(ohlcv: pd.DataFrame) -> None:
signals = fn(ohlcv)
last = signals.iloc[-1]
assert last == Side.LONG # close finale e' 120, regola 1 matcha
def test_compile_hour_feature_returns_index_hour(ohlcv: pd.DataFrame) -> None:
src = json.dumps(
{
"rules": [
{
"condition": {
"op": "gt",
"args": [
{"kind": "feature", "name": "hour"},
{"kind": "literal", "value": -1.0},
],
},
"action": "entry-long",
}
]
}
)
ast = parse_strategy(src)
fn = compile_strategy(ast)
signal = fn(ohlcv)
# All rows have hour >= 0 > -1, so all entry-long.
assert (signal == Side.LONG).all()