Add Oracle health pre-check in run_pre_screen to warn before bar-fetch timeout

If Oracle is unreachable at 09:20 ET, without this check the pre-screen silently
waits through 5 chunks × 15s timeout (75s) before logging the empty-bars warning.
The new 3s probe logs a CRITICAL warning immediately so the operator can restart
Oracle before the market opens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
I Luk Kim 4 months ago
parent 65afc95c7e
commit 04bb11f9bb

@ -129,6 +129,22 @@ class ORBTradingEngine:
self._session.session_id, date_str, phase="pre_screen" self._session.session_id, date_str, phase="pre_screen"
) )
# Cheap Oracle health probe — warns early so the operator can restart Oracle
# before the bar-fetch loop (5 chunks × 15s timeout) burns 75s silently.
try:
import httpx as _httpx
from libs.oracle_client.alpaca import _base_url as _oracle_base_url
_oracle_health_url = _oracle_base_url() + "/api/v1/health"
_r = _httpx.get(_oracle_health_url, timeout=3.0)
_ok = _r.status_code < 400
except Exception:
_ok = False
if not _ok:
self._log(
"CRITICAL: Oracle is unreachable — bar fetches will likely fail. "
"Start Oracle before 09:20 ET on live trading days."
)
universe_source = getattr(self._params, "_universe_source", "midlarge") universe_source = getattr(self._params, "_universe_source", "midlarge")
universe_symbols_file = getattr(self._params, "_universe_symbols_file", None) universe_symbols_file = getattr(self._params, "_universe_symbols_file", None)
tickers = load_universe(universe_source, universe_symbols_file) tickers = load_universe(universe_source, universe_symbols_file)

Loading…
Cancel
Save