-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_opening_range_profile.py
More file actions
46 lines (38 loc) · 1.4 KB
/
run_opening_range_profile.py
File metadata and controls
46 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Run a named opening-range profile through the public runtime."""
from __future__ import annotations
from datetime import datetime
import os
from cutebacktests import IntradayOptionsBacktestConfig, IntradayOptionsBacktester, get_opening_range_profile
from cutebacktests.providers import CuteMarketsProvider
from cutebacktests.settings import Settings
from cutebacktests.storage import DataStore
def main() -> None:
settings = Settings.from_env(".env")
profile_name = os.environ.get("CUTEBACKTESTS_PROFILE", "c4_long_only_rr15").strip()
profile = get_opening_range_profile(profile_name)
store = DataStore(settings.db_path)
try:
backtester = IntradayOptionsBacktester(
store=store,
cutemarkets_provider=CuteMarketsProvider(settings),
)
config = IntradayOptionsBacktestConfig(
start=datetime(2025, 1, 1),
end=datetime(2025, 1, 31),
ticker="SPY",
return_trade_log=True,
**profile.to_intraday_strategy_kwargs(),
)
result = backtester.run(config)
print(
{
"profile_name": profile.name,
"strategy_variant": profile.strategy_variant,
"trades": result.get("trades"),
"total_return": result.get("total_return"),
}
)
finally:
store.close()
if __name__ == "__main__":
main()