You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1012 B
Python
28 lines
1012 B
Python
"""Shared Stock Oracle client helpers for ORB/intraday workflows."""
|
|
from __future__ import annotations
|
|
|
|
from libs.common.config import Settings
|
|
from libs.oracle_client import OracleClient
|
|
|
|
|
|
_INTRADAY_ORACLE_MIN_TIMEOUT = 90.0
|
|
|
|
|
|
def intraday_oracle_timeout(settings: Settings) -> float:
|
|
"""Return a safer timeout for heavy ORB historical bulk requests.
|
|
|
|
Oracle may spend tens of seconds inside upstream Alpaca retries. The global
|
|
default timeout (`stock_oracle_timeout=30`) is fine for lighter PIT lookups
|
|
but too short for ORB multi-ticker intraday batches, which can trigger
|
|
client-side timeouts and singleton retry cascades.
|
|
"""
|
|
return max(float(settings.stock_oracle_timeout), _INTRADAY_ORACLE_MIN_TIMEOUT)
|
|
|
|
|
|
def make_intraday_oracle_client(settings: Settings) -> OracleClient:
|
|
"""Build an Oracle client tuned for ORB/intraday research workloads."""
|
|
return OracleClient(
|
|
base_url=settings.stock_oracle_url,
|
|
timeout=intraday_oracle_timeout(settings),
|
|
)
|