Add OperatingHoursCfg (enabled/timezone/weekdays/start_hhmm/stop_hhmm) so
the run loop can align with NYSE session hours instead of the user's
local wall clock (fixes DST drift between NY and Europe/Bucharest).
- Config parses [options.operating_hours] and resolves ZoneInfo at load,
fail-fast on invalid tz or weekday names. The tz is cached on
_tz_cache so the detection loop pays zero per-tick cost.
- LifecycleState tracks user_paused + last_window_state across ticks.
- Module-scope _should_skip(now, state, cfg, canary) returns skip reason
or None. Weekday check uses datetime.weekday() + a fixed MON..SUN list
(locale-free; strftime('%a') is localized).
- _maybe_log_transition emits market_open / market_closed once per edge.
R2: when last_window_state is None (startup), just seed — do not send
a spurious market_open alert when run_live_async launches in-window.
- _run_tick consults the lifecycle guard before scheduling the heavy
detection thread, so drain + transition logging still happen when the
tick is skipped.
- CLI flags --tz / --weekdays / --oh-start / --oh-stop override TOML.
(Kept distinct from the existing --start-at/--stop-at sleep-until-time
semantics to avoid breaking current deployments — deviation noted.)
- configs/example.toml documents the new [options.operating_hours] table.
Tests: parametrized window matrix (tests #8), transition logging (#9),
notification side-effect (#10), R2 #20 startup suppression, R2 #22
locale-independent weekday, plus guards for user_paused / canary
precedence and config-parse error paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
110 lines
2.6 KiB
TOML
110 lines
2.6 KiB
TOML
# ATM example config — populated by `atm calibrate`.
|
|
# Copy to configs/YYYY-MM-DD-HHMM.toml and set configs/current.txt to filename.
|
|
|
|
window_title = "TradeStation 10"
|
|
|
|
[dot_roi]
|
|
x = 800
|
|
y = 920
|
|
w = 320
|
|
h = 40
|
|
|
|
[chart_roi]
|
|
x = 80
|
|
y = 100
|
|
w = 1300
|
|
h = 800
|
|
|
|
[colors.turquoise]
|
|
rgb = [64, 224, 208]
|
|
tolerance = 30.0
|
|
|
|
[colors.yellow]
|
|
rgb = [255, 215, 0]
|
|
tolerance = 30.0
|
|
|
|
[colors.dark_green]
|
|
rgb = [0, 100, 0]
|
|
tolerance = 30.0
|
|
|
|
[colors.dark_red]
|
|
rgb = [139, 0, 0]
|
|
tolerance = 30.0
|
|
|
|
[colors.light_green]
|
|
rgb = [0, 230, 118]
|
|
tolerance = 30.0
|
|
|
|
[colors.light_red]
|
|
rgb = [255, 82, 82]
|
|
tolerance = 30.0
|
|
|
|
[colors.gray]
|
|
rgb = [128, 128, 128]
|
|
tolerance = 25.0
|
|
|
|
[colors.background]
|
|
rgb = [18, 18, 18]
|
|
tolerance = 15.0
|
|
|
|
[y_axis]
|
|
# Two reference (pixel_y, price) pairs from a stable bar close.
|
|
p1_y = 150
|
|
p1_price = 485.50
|
|
p2_y = 750
|
|
p2_price = 483.50
|
|
|
|
[canary]
|
|
baseline_phash = "0000000000000000000000000000000000000000000000000000000000000000"
|
|
drift_threshold = 8
|
|
|
|
[canary.roi]
|
|
x = 1450
|
|
y = 100
|
|
w = 100
|
|
h = 50
|
|
|
|
[discord]
|
|
webhook_url = "https://discord.com/api/webhooks/REPLACE_ME"
|
|
|
|
[telegram]
|
|
bot_token = "REPLACE_ME"
|
|
chat_id = "REPLACE_ME"
|
|
|
|
[options]
|
|
debounce_depth = 1
|
|
loop_interval_s = 5.0
|
|
heartbeat_min = 30
|
|
lockout_s = 240
|
|
low_conf_threshold = 0.2
|
|
low_conf_run = 3
|
|
phaseb_timeout_s = 600
|
|
dead_letter_path = "logs/dead_letter.jsonl"
|
|
|
|
# Alert-behavior toggles (not screenshot-attachment; see attach_screenshots below).
|
|
# fire_on_phase_skip: emit a backstop "PHASE SKIP" alert when the FSM observes
|
|
# ARMED → light_green/light_red directly (skipping the dark prime). Default on
|
|
# because missing a fire is worse than a false-positive phase-skip alert.
|
|
[options.alerts]
|
|
fire_on_phase_skip = true
|
|
|
|
# Operating hours — detection only runs on allowed weekdays + HH:MM window.
|
|
# Timezone is the source of truth (NYSE local); the runtime converts tick
|
|
# timestamps to this zone so DST rollovers stay aligned with the exchange.
|
|
# Override from CLI with --tz / --weekdays / --oh-start / --oh-stop.
|
|
[options.operating_hours]
|
|
enabled = false
|
|
timezone = "America/New_York"
|
|
weekdays = ["MON", "TUE", "WED", "THU", "FRI"]
|
|
start_hhmm = "09:30"
|
|
stop_hhmm = "16:00"
|
|
|
|
# Per-kind screenshot-attach toggles. All default to true on upgrade.
|
|
# Accepts either a bare bool (legacy: attach_screenshots = true) or this table.
|
|
[options.attach_screenshots]
|
|
late_start = true # screenshot on startup-late alerts
|
|
catchup = true # screenshot on mid-session catchup arm + prime
|
|
arm = true # screenshot on normal arm (turquoise/yellow) — noisiest
|
|
prime = true # screenshot on normal prime (dark_green/dark_red)
|
|
trigger = true # screenshot on FIRE
|