Fix live runner next-cycle timestamp parsing
This commit is contained in:
parent
8d1eaafebb
commit
99e48144aa
@ -156,6 +156,19 @@ def _last_execution_anchor(state: dict, mode: str) -> str | None:
|
|||||||
return state.get("last_run") or state.get("last_sip_ts")
|
return state.get("last_run") or state.get("last_sip_ts")
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_market_timestamp(value: str | None) -> datetime | None:
|
||||||
|
if not value:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
parsed = datetime.fromisoformat(value)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
market_tz = market_now().tzinfo
|
||||||
|
if parsed.tzinfo is None:
|
||||||
|
return parsed.replace(tzinfo=market_tz)
|
||||||
|
return parsed.astimezone(market_tz)
|
||||||
|
|
||||||
|
|
||||||
def _pause_for_auth_expiry(
|
def _pause_for_auth_expiry(
|
||||||
user_id: str,
|
user_id: str,
|
||||||
run_id: str,
|
run_id: str,
|
||||||
@ -330,9 +343,9 @@ def _engine_loop(config, stop_event: threading.Event):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if last_run and not is_first_run:
|
if last_run and not is_first_run:
|
||||||
next_run = datetime.fromisoformat(last_run) + delta
|
parsed_last_run = _parse_market_timestamp(last_run)
|
||||||
next_run = align_to_market_open(next_run)
|
next_run = align_to_market_open(parsed_last_run + delta) if parsed_last_run else None
|
||||||
if now < next_run:
|
if next_run is not None and now < next_run:
|
||||||
wait_seconds = 5 if unit == "minutes" else 60
|
wait_seconds = 5 if unit == "minutes" else 60
|
||||||
log_event(
|
log_event(
|
||||||
event="SIP_WAITING",
|
event="SIP_WAITING",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user