feat(protocol): dispatcher temporal features (hour) in compiler
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user