test(protocol): compiler semantica minute_of_hour su 1h
This commit is contained in:
@@ -183,3 +183,28 @@ def test_compile_is_weekend_returns_zero_one(ohlcv: pd.DataFrame) -> None:
|
|||||||
weekdays = signal[signal.index.dayofweek < 5]
|
weekdays = signal[signal.index.dayofweek < 5]
|
||||||
assert (weekend == Side.LONG).all()
|
assert (weekend == Side.LONG).all()
|
||||||
assert (weekdays == Side.FLAT).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()
|
||||||
|
|||||||
Reference in New Issue
Block a user