Add Telegram bot control interface for HuggingFace Spaces deployment
Browse filesThe platform is now controlled through Telegram: app.py starts a FastAPI
webhook server (port 7860) while the polling loop runs in a background
thread managed by a new PlatformController.
New src/telegram_bot/ package:
- server.py: webhook endpoint /webhook/{WEBHOOK_SECRET}, health endpoints,
/set_webhook helper for registering the webhook with Telegram
- telegram_client.py: async httpx client routing all outbound calls through
the Google Apps Script proxy (GOOGLE_APPS_SCRIPT_URL) since HF Spaces
blocks direct api.telegram.org traffic; direct fallback for local dev
- bot_service.py: commands /status /regime /universe /events /telemetry
/subscribe /unsubscribe, plus admin-only /pause /resume /mute /unmute
/interval (restricted to TELEGRAM_CHAT_ID when set)
- controller.py: pause/resume flags, runtime poll-interval override,
ring buffers of recent risk events and regime changes
Core changes:
- Runtime now exposes risk, envelope_store and telemetry for the bot
- TelegramNotifier supports the Apps Script proxy, muting, and broadcast
to dynamically subscribed chats
- RiskEngine.regime property, Telemetry.snapshot()
Files changed (16)
- DockerfileAdded+34
- app.py+7-2
- pyproject.toml+4
- src/core/alerting.py+40-6
- src/core/config.py+3
- src/core/main.py+6
- src/core/risk_engine.py+4
- src/core/telemetry.py+3
- src/telegram_bot/__init__.pyAdded
- src/telegram_bot/bot_service.pyAdded+340
- src/telegram_bot/config.pyAdded+49
- src/telegram_bot/controller.pyAdded+195
- src/telegram_bot/server.pyAdded+114
- src/telegram_bot/telegram_client.pyAdded+93
- src/telegram_bot/tg_models.pyAdded+10
- uv.lock+230
12345678910111213141516171819202122232425262728293031323334FROM python:3.12-slim
# curl for the HEALTHCHECKRUN apt-get update && apt-get install -y --no-install-recommends curl && \ apt-get clean && rm -rf /var/lib/apt/lists/*
# HuggingFace Spaces runs containers as user 1000RUN useradd -m -u 1000 userUSER user
ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONPATH=/home/user/app \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1
WORKDIR $HOME/app
RUN pip install --no-cache-dir --upgrade pip
# Install dependencies first for layer cachingCOPY --chown=user pyproject.toml README.md $HOME/app/RUN pip install --no-cache-dir fastapi httpx lxml numpy pandas pydantic pyyaml requests uvicorn yfinance
COPY --chown=user src/ $HOME/app/src/COPY --chown=user configs/ $HOME/app/configs/COPY --chown=user app.py $HOME/app/
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \ CMD curl --fail http://localhost:7860/health || exit 1
CMD ["python", "app.py"]12345from src.core.main import run_foreverif __name__ == "__main__":run_forever()12345678910"""HuggingFace Spaces entrypoint: Telegram bot webhook server + platform loop.For the headless polling loop without the bot, run `python -m src.core.main`."""from src.telegram_bot.server import mainif __name__ == "__main__":main()
4 unmodified lines567891011121314154 unmodified linesreadme = "README.md"requires-python = ">=3.10,<3.13"dependencies = ["lxml","numpy","pandas","pyyaml","requests","yfinance",]4 unmodified lines56789101112131415161718194 unmodified linesreadme = "README.md"requires-python = ">=3.10,<3.13"dependencies = ["fastapi","httpx","lxml","numpy","pandas","pydantic","pyyaml","requests","uvicorn","yfinance",]
12346 unmodified lines11121314151671 unmodified lines888990919293949596979899100101102103104105106107108from typing import Dict, Listimport loggingimport timeimport uuid6 unmodified linesTIMEFRAMES_MIN,TELEGRAM_BOT_TOKEN_ENV,TELEGRAM_CHAT_ID_ENV,)from .retry_utils import backoff_delay71 unmodified linesclass TelegramNotifier:def __init__(self) -> None:self._token = os.getenv(TELEGRAM_BOT_TOKEN_ENV)self._chat_id = os.getenv(TELEGRAM_CHAT_ID_ENV)def send(self, alert: Dict) -> bool:if not self._token or not self._chat_id:logger.info("telegram credentials missing, alert not delivered: %s", alert["message"])return Trueurl = f"https://api.telegram.org/bot{self._token}/sendMessage"payload = {"chat_id": self._chat_id, "text": alert["message"]}try:resp = requests.post(url, json=payload, timeout=10)return resp.status_code == 200except Exception:logger.warning("telegram send failed: %s", alert["message"])return False12346 unmodified lines1112131415161771 unmodified lines8990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142from typing import Callable, Dict, Iterable, List, Optionalimport loggingimport timeimport uuid6 unmodified linesTIMEFRAMES_MIN,TELEGRAM_BOT_TOKEN_ENV,TELEGRAM_CHAT_ID_ENV,TELEGRAM_PROXY_URL_ENV,)from .retry_utils import backoff_delay71 unmodified linesclass TelegramNotifier:"""Delivers alerts to Telegram, either directly or through a Google AppsScript proxy (HuggingFace Spaces blocks direct api.telegram.org calls).`chat_ids_provider` lets the Telegram bot add dynamically subscribed chatson top of the static TELEGRAM_CHAT_ID; `muted` silences delivery withouttouching the alert pipeline."""def __init__(self) -> None:self._token = os.getenv(TELEGRAM_BOT_TOKEN_ENV)self._chat_id = os.getenv(TELEGRAM_CHAT_ID_ENV)self._proxy_url = os.getenv(TELEGRAM_PROXY_URL_ENV)self.muted = Falseself.chat_ids_provider: Optional[Callable[[], Iterable[str]]] = Nonedef send(self, alert: Dict) -> bool:if self.muted:return Truechat_ids = {str(self._chat_id)} if self._chat_id else set()if self.chat_ids_provider is not None:chat_ids.update(str(chat_id) for chat_id in self.chat_ids_provider())if not self._token or not chat_ids:logger.info("telegram credentials missing, alert not delivered: %s", alert["message"])return Trueok = Truefor chat_id in chat_ids:ok = self._send_one(chat_id, alert["message"]) and okreturn okdef _send_one(self, chat_id: str, text: str) -> bool:try:if self._proxy_url:payload = {"method": "sendMessage","bot_token": self._token,"chat_id": chat_id,"text": text,}resp = requests.post(self._proxy_url, json=payload, timeout=15)else:url = f"https://api.telegram.org/bot{self._token}/sendMessage"resp = requests.post(url, json={"chat_id": chat_id, "text": text}, timeout=10)return resp.status_code == 200except Exception:logger.warning("telegram send failed for chat %s: %s", chat_id, text)return False
114 unmodified lines115116117118119120114 unmodified lines# Telegram bot (no auth on load; uses env vars at runtime)TELEGRAM_BOT_TOKEN_ENV = "TELEGRAM_BOT_TOKEN"TELEGRAM_CHAT_ID_ENV = "TELEGRAM_CHAT_ID"# yfinance backoffYF_MAX_RETRIES = 3114 unmodified lines115116117118119120121122123114 unmodified lines# Telegram bot (no auth on load; uses env vars at runtime)TELEGRAM_BOT_TOKEN_ENV = "TELEGRAM_BOT_TOKEN"TELEGRAM_CHAT_ID_ENV = "TELEGRAM_CHAT_ID"# Google Apps Script proxy for Telegram API calls (HuggingFace Spaces blocks# direct calls to api.telegram.org); empty = call Telegram directlyTELEGRAM_PROXY_URL_ENV = "GOOGLE_APPS_SCRIPT_URL"# yfinance backoffYF_MAX_RETRIES = 3
36 unmodified lines37383940414227 unmodified lines70717273747536 unmodified linesqueue: AlertQueueloader: UniverseLoaderuniverse: Dict[str, List[str]]ingestors: Dict[str, PriceIngestor] = field(default_factory=dict)cycle: int = 027 unmodified linesqueue=queue,loader=UniverseLoader(),universe={},)_load_universe(runtime)return runtime36 unmodified lines37383940414243444527 unmodified lines73747576777879808136 unmodified linesqueue: AlertQueueloader: UniverseLoaderuniverse: Dict[str, List[str]]risk: RiskEngineenvelope_store: RiskEnvelopeStoretelemetry: Telemetryingestors: Dict[str, PriceIngestor] = field(default_factory=dict)cycle: int = 027 unmodified linesqueue=queue,loader=UniverseLoader(),universe={},risk=risk,envelope_store=envelope_store,telemetry=telemetry,)_load_universe(runtime)return runtime
32 unmodified lines33343536373832 unmodified linesself._cycle_worst_drop = 0.0self._cycle_high_severity = 0def on_universe_snapshot(self, universe_snapshot: Dict) -> None:self._universe_id = universe_snapshot.get("universe_id", "unknown")32 unmodified lines3334353637383940414232 unmodified linesself._cycle_worst_drop = 0.0self._cycle_high_severity = 0@propertydef regime(self) -> str:return self._regime.statedef on_universe_snapshot(self, universe_snapshot: Dict) -> None:self._universe_id = universe_snapshot.get("universe_id", "unknown")
33 unmodified lines34353637383933 unmodified linesself._counters[f"risk_regime_to:{to_regime}"] += 1self._maybe_report()def report(self) -> None:if not self._counters:return33 unmodified lines34353637383940414233 unmodified linesself._counters[f"risk_regime_to:{to_regime}"] += 1self._maybe_report()def snapshot(self) -> Dict[str, int]:return dict(self._counters)def report(self) -> None:if not self._counters:return
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340"""Telegram command interface for the market analyzing platform."""
import loggingfrom datetime import datetime, timezone
from .config import BotConfigfrom .controller import PlatformControllerfrom .telegram_client import TelegramClientfrom .tg_models import TelegramUpdate
logger = logging.getLogger(__name__)
STATE_EMOJI = {"running": "🟢", "paused": "⏸", "starting": "⏳", "failed": "🔴"}REGIME_EMOJI = {"normal": "🟢", "tension": "🟡", "stress": "🟠", "panic": "🔴"}
# Commands that change platform behaviour; restricted to the admin chat# (TELEGRAM_CHAT_ID) when one is configured.CONTROL_COMMANDS = {"/pause", "/resume", "/mute", "/unmute", "/interval"}
HELP_TEXT = """🤖 <b>Market Risk Radar — control bot</b>
<b>Monitoring:</b>/status - Platform state, cycle, regime, universe sizes/regime - Current risk regime + trading envelope/universe [venue] - Ticker counts, or tickers of one venue/events [N] - Last N detected risk events (default 10)/telemetry - Event counters since start
<b>Alerts:</b>/subscribe - Receive risk alerts in this chat/unsubscribe - Stop receiving alerts here/mute - Silence all alert delivery/unmute - Re-enable alert delivery
<b>Control:</b>/pause - Pause the polling loop/resume - Resume the polling loop/interval SECONDS - Set poll interval (15-3600)
/help - This message"""
class TelegramBotService: def __init__( self, controller: PlatformController, client: TelegramClient, config: type[BotConfig] = BotConfig, ) -> None: self._controller = controller self._client = client self._config = config
async def process_update(self, update: TelegramUpdate) -> None: try: message = update.message or update.edited_message if not message: logger.debug("update %s has no message, skipping", update.update_id) return
chat_id = message.get("chat", {}).get("id") text = (message.get("text") or "").strip() user_name = message.get("from", {}).get("first_name", "User") if not chat_id: logger.warning("no chat id in update %s", update.update_id) return
logger.info("message %r from %s (chat %s)", text, user_name, chat_id) if text.startswith("/"): await self._handle_command(chat_id, text, user_name) else: await self._client.send_message( chat_id, f"Hello {user_name}! 👋 I control the market risk radar.\n" "Type /help to see what I can do.", ) except Exception: logger.exception("error processing update") message = update.message or update.edited_message chat_id = (message or {}).get("chat", {}).get("id") if chat_id: await self._client.send_message( chat_id, "Sorry, something went wrong. Please try again later." )
async def _handle_command(self, chat_id: int, text: str, user_name: str) -> None: parts = text.split() # Strip the bot-name suffix Telegram adds in groups (/status@MyBot) command = parts[0].lower().split("@")[0] args = parts[1:]
if command in CONTROL_COMMANDS and not self._is_admin(chat_id): await self._client.send_message( chat_id, "⛔ This command is restricted to the admin chat." ) return
handlers = { "/start": self._cmd_start, "/hello": self._cmd_start, "/help": self._cmd_help, "/status": self._cmd_status, "/regime": self._cmd_regime, "/universe": self._cmd_universe, "/events": self._cmd_events, "/telemetry": self._cmd_telemetry, "/subscribe": self._cmd_subscribe, "/unsubscribe": self._cmd_unsubscribe, "/mute": self._cmd_mute, "/unmute": self._cmd_unmute, "/pause": self._cmd_pause, "/resume": self._cmd_resume, "/interval": self._cmd_interval, } handler = handlers.get(command) if handler is None: await self._client.send_message( chat_id, f"❓ Unknown command: {command}\n\nType /help to see available commands." ) return await handler(chat_id, args, user_name)
def _is_admin(self, chat_id: int) -> bool: admin = self._config.ADMIN_CHAT_ID return not admin or str(chat_id) == str(admin)
# -- handlers ----------------------------------------------------------
async def _cmd_start(self, chat_id: int, args: list[str], user_name: str) -> None: await self._client.send_message( chat_id, f"👋 Hello, {user_name}! I'm the control interface of the " f"<b>Market Risk Radar</b> — a platform polling US/EU equities, " f"crypto and commodities for abnormal price moves.\n\n{HELP_TEXT}", )
async def _cmd_help(self, chat_id: int, args: list[str], user_name: str) -> None: await self._client.send_message(chat_id, HELP_TEXT)
async def _cmd_status(self, chat_id: int, args: list[str], user_name: str) -> None: status = self._controller.status() state = status["state"] lines = [ "📊 <b>Platform Status</b>", "", f"{STATE_EMOJI.get(state, '❔')} State: <b>{state}</b>", ] if status["startup_error"]: lines.append(f"❌ Startup error: {status['startup_error']}") lines += [ f"⏱ Uptime: {_fmt_duration(status['uptime_sec'])}", f"🔁 Poll interval: {status['poll_interval_sec']}s", f"🔔 Alerts: {'muted 🔇' if status['muted'] else 'active 🔊'}", f"👥 Subscribed chats: {status['subscribers']}", ] if "cycle" in status: regime = status["regime"] lines += [ f"🔄 Cycles completed: {status['cycle']}", f"{REGIME_EMOJI.get(regime, '❔')} Regime: <b>{regime}</b>", ] if status["last_cycle_duration_sec"] is not None: lines.append(f"⚙️ Last cycle took: {status['last_cycle_duration_sec']}s") lines.append("") lines.append("<b>Universe:</b>") total = 0 for venue, count in sorted(status["universe"].items()): lines.append(f" • {venue}: {count}") total += count lines.append(f" Σ {total} tickers") elif state == "starting": lines.append("\n⏳ Universe is loading, try again in a minute.") await self._client.send_message(chat_id, "\n".join(lines))
async def _cmd_regime(self, chat_id: int, args: list[str], user_name: str) -> None: info = self._controller.regime_info() if info is None: await self._client.send_message(chat_id, "⏳ Platform is still starting, try again soon.") return regime = info["regime"] policy = info["policy"] lines = [ f"{REGIME_EMOJI.get(regime, '❔')} <b>Risk regime: {regime.upper()}</b>", "", "<b>Trading envelope:</b>", f" • Trading allowed: {'✅ yes' if policy.get('allowed') else '🚫 no'}", f" • Max position: ${policy.get('max_position_usd', 0):,.0f}", f" • Max order: ${policy.get('max_order_usd', 0):,.0f}", f" • Max leverage: {policy.get('max_leverage', 0)}", f" • Cooldown: {policy.get('cooldown_seconds', 0)}s", f" • Confidence: {policy.get('confidence', 0)}", ] envelope = info["envelope"] if envelope: valid_until = datetime.fromtimestamp( envelope["valid_until_ms"] / 1000, tz=timezone.utc ).strftime("%H:%M:%S UTC") lines.append(f" • Active envelope valid until: {valid_until}") changes = self._controller.regime_changes() if changes: lines += ["", "<b>Recent regime changes:</b>"] for change in changes: lines.append( f" • {_fmt_ts(change['ts'])} " f"{change['from_regime']} → {change['to_regime']}" ) await self._client.send_message(chat_id, "\n".join(lines))
async def _cmd_universe(self, chat_id: int, args: list[str], user_name: str) -> None: universe = self._controller.universe() if universe is None: await self._client.send_message(chat_id, "⏳ Universe is still loading, try again soon.") return if args: venue = args[0].lower() tickers = universe.get(venue) if tickers is None: await self._client.send_message( chat_id, f"❓ Unknown venue <code>{venue}</code>.\n" f"Known venues: {', '.join(sorted(universe))}", ) return preview = ", ".join(tickers[:50]) more = f" … (+{len(tickers) - 50} more)" if len(tickers) > 50 else "" await self._client.send_long_message( chat_id, f"🌐 <b>{venue}</b> — {len(tickers)} tickers:\n{preview}{more}" ) return lines = ["🌐 <b>Universe</b>", ""] total = 0 for venue, tickers in sorted(universe.items()): lines.append(f" • {venue}: {len(tickers)}") total += len(tickers) lines += ["", f"Σ {total} tickers. Use /universe VENUE to list tickers."] await self._client.send_message(chat_id, "\n".join(lines))
async def _cmd_events(self, chat_id: int, args: list[str], user_name: str) -> None: limit = 10 if args: try: limit = max(1, min(50, int(args[0]))) except ValueError: pass events = self._controller.events(limit) if not events: await self._client.send_message(chat_id, "ℹ️ No risk events detected yet.") return lines = [f"🚨 <b>Last {len(events)} risk events</b>", ""] for event in events: sev_emoji = "🔴" if event.get("severity") == "high" else "🟠" lines.append( f"{sev_emoji} {_fmt_ts(event['ts'])} <b>{event['ticker']}</b> " f"{event['timeframe']} {event['delta_pct']:+.2f}% " f"(thr {event['threshold']:.2f}%)" ) await self._client.send_long_message(chat_id, "\n".join(lines))
async def _cmd_telemetry(self, chat_id: int, args: list[str], user_name: str) -> None: counters = self._controller.telemetry() if counters is None: await self._client.send_message(chat_id, "⏳ Platform is still starting, try again soon.") return if not counters: await self._client.send_message(chat_id, "ℹ️ No telemetry counters yet.") return lines = ["📈 <b>Telemetry</b>", ""] for key, value in sorted(counters.items()): lines.append(f" • {key}: {value}") await self._client.send_long_message(chat_id, "\n".join(lines))
async def _cmd_subscribe(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.subscribe(chat_id): await self._client.send_message( chat_id, "✅ Subscribed — risk alerts will be delivered to this chat." ) else: await self._client.send_message(chat_id, "ℹ️ This chat is already subscribed.")
async def _cmd_unsubscribe(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.unsubscribe(chat_id): await self._client.send_message(chat_id, "✅ Unsubscribed — no more alerts here.") else: await self._client.send_message(chat_id, "ℹ️ This chat was not subscribed.")
async def _cmd_mute(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.set_muted(True): await self._client.send_message(chat_id, "🔇 Alert delivery muted for all chats.") else: await self._client.send_message(chat_id, "⏳ Platform is still starting, try again soon.")
async def _cmd_unmute(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.set_muted(False): await self._client.send_message(chat_id, "🔊 Alert delivery re-enabled.") else: await self._client.send_message(chat_id, "⏳ Platform is still starting, try again soon.")
async def _cmd_pause(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.pause(): await self._client.send_message(chat_id, "⏸ Polling loop paused. /resume to continue.") else: await self._client.send_message(chat_id, "ℹ️ Polling loop is already paused.")
async def _cmd_resume(self, chat_id: int, args: list[str], user_name: str) -> None: if self._controller.resume(): await self._client.send_message(chat_id, "▶️ Polling loop resumed.") else: await self._client.send_message(chat_id, "ℹ️ Polling loop is not paused.")
async def _cmd_interval(self, chat_id: int, args: list[str], user_name: str) -> None: if not args: await self._client.send_message( chat_id, f"ℹ️ Current poll interval: {self._controller.poll_interval}s.\n" "Usage: /interval SECONDS (15-3600)", ) return try: requested = int(args[0]) except ValueError: await self._client.send_message(chat_id, "❌ Interval must be a number of seconds.") return applied = self._controller.set_poll_interval(requested) note = "" if applied == requested else f" (requested {requested}s was clamped)" await self._client.send_message(chat_id, f"✅ Poll interval set to {applied}s{note}.")
def _fmt_duration(seconds: int) -> str: hours, rem = divmod(seconds, 3600) minutes, secs = divmod(rem, 60) if hours: return f"{hours}h {minutes}m" if minutes: return f"{minutes}m {secs}s" return f"{secs}s"
def _fmt_ts(ts_ms: int) -> str: return datetime.fromtimestamp(ts_ms / 1000, tz=timezone.utc).strftime("%m-%d %H:%M")12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"""Telegram bot configuration.
All values come from environment variables at import time — there is no .envfile parsing. On HuggingFace Spaces set these as Space secrets/variables."""
import loggingimport os
logger = logging.getLogger(__name__)
class BotConfig: # Reuses the same env vars as the core alerting pipeline BOT_TOKEN: str = os.getenv("TELEGRAM_BOT_TOKEN", "") ADMIN_CHAT_ID: str = os.getenv("TELEGRAM_CHAT_ID", "")
# Google Apps Script proxy; required on HuggingFace Spaces because direct # calls to api.telegram.org are blocked there. Empty = call Telegram directly. PROXY_URL: str = os.getenv("GOOGLE_APPS_SCRIPT_URL", "")
# Secret path segment of the webhook URL: /webhook/{WEBHOOK_SECRET} WEBHOOK_SECRET: str = os.getenv("WEBHOOK_SECRET", "secret-key")
# Set automatically by HuggingFace Spaces (e.g. "user-space.hf.space") SPACE_HOST: str = os.getenv("SPACE_HOST", "")
PORT: int = int(os.getenv("PORT", "7860"))
@classmethod def webhook_url(cls) -> str: if not cls.SPACE_HOST: return "" return f"https://{cls.SPACE_HOST}/webhook/{cls.WEBHOOK_SECRET}"
@classmethod def validate(cls) -> bool: """Log missing settings; the platform still runs without them.""" ok = True if not cls.BOT_TOKEN: logger.warning("TELEGRAM_BOT_TOKEN is not set — bot cannot send messages") ok = False if not cls.PROXY_URL: logger.warning( "GOOGLE_APPS_SCRIPT_URL is not set — falling back to direct " "Telegram API calls (blocked on HuggingFace Spaces)" ) return ok123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195"""Bridge between the async Telegram bot and the synchronous polling core.
The platform loop (build_runtime/run_once) runs in a daemon thread; the botreads state snapshots and flips thread-safe flags (pause, mute, interval).Consistent with the rest of the POC, subscriber chats and pause state arein-memory only and reset on restart."""
import loggingimport threadingimport timefrom collections import dequefrom typing import Dict, List, Optional
from src.core.config import POLL_INTERVAL_SEC, RISK_ENVELOPE_POLICYfrom src.core.main import Runtime, build_runtime, run_oncefrom src.core.topics import TOPICS
logger = logging.getLogger(__name__)
MIN_POLL_INTERVAL_SEC = 15MAX_POLL_INTERVAL_SEC = 3600
class PlatformController: def __init__(self) -> None: self.runtime: Optional[Runtime] = None self.poll_interval = POLL_INTERVAL_SEC self.started_at = time.time() self.startup_error: Optional[str] = None self.last_cycle_ts: Optional[float] = None self.last_cycle_duration: Optional[float] = None
self.recent_risk_events: deque = deque(maxlen=50) self.recent_regime_changes: deque = deque(maxlen=20)
self._subscribers: set[str] = set() self._subscribers_lock = threading.Lock()
self._paused = threading.Event() self._stop = threading.Event() self._thread: Optional[threading.Thread] = None
# -- lifecycle ---------------------------------------------------------
def start(self) -> None: if self._thread is not None: return self._thread = threading.Thread(target=self._run_loop, name="platform-loop", daemon=True) self._thread.start()
def stop(self) -> None: self._stop.set()
def _run_loop(self) -> None: try: # Universe load hits GitHub/Wikipedia/Binance; may take a while runtime = build_runtime() except Exception as exc: logger.exception("platform runtime failed to build") self.startup_error = str(exc) return
runtime.pubsub.subscribe(TOPICS["risk_event"], self.recent_risk_events.append) runtime.pubsub.subscribe(TOPICS["risk_regime_change"], self.recent_regime_changes.append) runtime.notifier.chat_ids_provider = self.subscribers self.runtime = runtime logger.info("platform runtime ready, entering poll loop")
while not self._stop.is_set(): if not self._paused.is_set(): started = time.time() try: run_once(runtime) except Exception: logger.exception("poll cycle failed") self.last_cycle_ts = time.time() self.last_cycle_duration = self.last_cycle_ts - started # Sleep in small steps so pause/interval changes apply quickly deadline = time.time() + self.poll_interval while time.time() < deadline and not self._stop.is_set(): time.sleep(1)
# -- control commands --------------------------------------------------
def pause(self) -> bool: """Returns False if already paused.""" if self._paused.is_set(): return False self._paused.set() return True
def resume(self) -> bool: if not self._paused.is_set(): return False self._paused.clear() return True
@property def paused(self) -> bool: return self._paused.is_set()
def set_poll_interval(self, seconds: int) -> int: seconds = max(MIN_POLL_INTERVAL_SEC, min(MAX_POLL_INTERVAL_SEC, seconds)) self.poll_interval = seconds return seconds
def set_muted(self, muted: bool) -> bool: """Returns False if the runtime is not ready yet.""" if self.runtime is None: return False self.runtime.notifier.muted = muted return True
@property def muted(self) -> bool: return bool(self.runtime and self.runtime.notifier.muted)
# -- alert subscriptions ----------------------------------------------
def subscribe(self, chat_id: int | str) -> bool: with self._subscribers_lock: before = len(self._subscribers) self._subscribers.add(str(chat_id)) return len(self._subscribers) > before
def unsubscribe(self, chat_id: int | str) -> bool: with self._subscribers_lock: try: self._subscribers.remove(str(chat_id)) return True except KeyError: return False
def subscribers(self) -> List[str]: with self._subscribers_lock: return list(self._subscribers)
# -- state snapshots ---------------------------------------------------
def status(self) -> Dict: if self.startup_error: state = "failed" elif self.runtime is None: state = "starting" elif self.paused: state = "paused" else: state = "running"
info: Dict = { "state": state, "startup_error": self.startup_error, "uptime_sec": int(time.time() - self.started_at), "poll_interval_sec": self.poll_interval, "muted": self.muted, "subscribers": len(self.subscribers()), } if self.runtime is not None: info.update( { "cycle": self.runtime.cycle, "regime": self.runtime.risk.regime, "universe": {venue: len(tickers) for venue, tickers in self.runtime.universe.items()}, "last_cycle_duration_sec": ( round(self.last_cycle_duration, 1) if self.last_cycle_duration else None ), } ) return info
def regime_info(self) -> Optional[Dict]: if self.runtime is None: return None regime = self.runtime.risk.regime envelope = self.runtime.envelope_store.get() policy = RISK_ENVELOPE_POLICY.get(regime, {}) return {"regime": regime, "envelope": envelope, "policy": policy}
def universe(self) -> Optional[Dict[str, List[str]]]: if self.runtime is None: return None return self.runtime.universe
def telemetry(self) -> Optional[Dict[str, int]]: if self.runtime is None: return None return self.runtime.telemetry.snapshot()
def events(self, limit: int = 10) -> List[Dict]: return list(self.recent_risk_events)[-limit:]
def regime_changes(self, limit: int = 5) -> List[Dict]: return list(self.recent_regime_changes)[-limit:]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114"""FastAPI app hosting the Telegram webhook on HuggingFace Spaces.
Startup sequence:1. The platform polling loop starts in a background thread (PlatformController).2. The async Telegram client connects (through the Google Apps Script proxy when GOOGLE_APPS_SCRIPT_URL is set — required on HF Spaces).3. Telegram pushes updates to POST /webhook/{WEBHOOK_SECRET}; register the URL once via POST /set_webhook after deploying."""
import asyncioimport loggingfrom contextlib import asynccontextmanager
import uvicornfrom fastapi import FastAPI, HTTPException, Request
from .bot_service import TelegramBotServicefrom .config import BotConfigfrom .controller import PlatformControllerfrom .telegram_client import TelegramClientfrom .tg_models import TelegramUpdate
logger = logging.getLogger(__name__)
controller = PlatformController()client = TelegramClient()bot_service = TelegramBotService(controller, client)
@asynccontextmanagerasync def lifespan(app: FastAPI): logging.basicConfig( level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s", ) BotConfig.validate() controller.start() await client.initialize() logger.info("telegram bot server started") yield controller.stop() await client.aclose() logger.info("telegram bot server stopped")
app = FastAPI( title="Market Analyzing Platform Bot", description="Telegram control interface for the market-wide risk radar", version="0.1.0", lifespan=lifespan,)
@app.get("/")async def root(): """Health endpoint HuggingFace Spaces pings to keep the Space alive.""" return { "status": "running", "platform": controller.status(), "bot_configured": bool(BotConfig.BOT_TOKEN), "proxy_configured": bool(BotConfig.PROXY_URL), }
@app.get("/health")async def health(): return {"status": "healthy", "platform_state": controller.status()["state"]}
@app.post(f"/webhook/{BotConfig.WEBHOOK_SECRET}")async def webhook(request: Request): try: json_data = await request.json() update = TelegramUpdate(**json_data) except Exception as exc: logger.error("invalid webhook payload: %s", exc) raise HTTPException(status_code=400, detail="Invalid update format")
# Ack Telegram immediately; process in the background so slow handlers # don't trigger webhook retries asyncio.create_task(bot_service.process_update(update)) return {"ok": True}
@app.post("/set_webhook")async def set_webhook(url: str = ""): """Register the webhook with Telegram (via the proxy when configured).
Uses https://{SPACE_HOST}/webhook/{WEBHOOK_SECRET} unless `url` is given. """ target = url or BotConfig.webhook_url() if not target: raise HTTPException( status_code=400, detail="No url given and SPACE_HOST is not set; pass ?url=https://.../webhook/<secret>", ) result = await client.call("setWebhook", url=target) return {"webhook_url": target, "telegram_response": result}
@app.get("/webhook_info")async def webhook_info(): result = await client.call("getWebhookInfo") return {"expected_url": BotConfig.webhook_url() or "<set SPACE_HOST>", "telegram_response": result}
def main() -> None: uvicorn.run(app, host="0.0.0.0", port=BotConfig.PORT, log_level="info")
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293"""Async Telegram API client.
Routes every call through the Google Apps Script proxy when configured(HuggingFace Spaces blocks direct api.telegram.org traffic), otherwise callsthe Telegram Bot API directly."""
import asyncioimport loggingfrom typing import Any
import httpx
from .config import BotConfig
logger = logging.getLogger(__name__)
# Telegram hard limit is 4096; leave headroom for HTML tagsMAX_MESSAGE_LENGTH = 4000
class TelegramClient: def __init__(self, config: type[BotConfig] = BotConfig) -> None: self._config = config self._http: httpx.AsyncClient | None = None
async def initialize(self) -> None: self._http = httpx.AsyncClient( timeout=httpx.Timeout(30.0), limits=httpx.Limits(max_keepalive_connections=5, max_connections=10), follow_redirects=True, )
async def aclose(self) -> None: if self._http: await self._http.aclose() self._http = None
async def call(self, method: str, **params: Any) -> dict[str, Any]: """Invoke any Bot API method (sendMessage, setWebhook, ...).""" if self._http is None: raise RuntimeError("TelegramClient not initialized") if not self._config.BOT_TOKEN: logger.warning("BOT_TOKEN missing, dropping %s call", method) return {"ok": False, "error": "BOT_TOKEN not configured"}
try: if self._config.PROXY_URL: payload = {"method": method, "bot_token": self._config.BOT_TOKEN, **params} resp = await self._http.post( self._config.PROXY_URL, json=payload, headers={"Content-Type": "application/json"}, ) else: url = f"https://api.telegram.org/bot{self._config.BOT_TOKEN}/{method}" resp = await self._http.post(url, json=params) result = resp.json() if not result.get("ok", False): logger.warning("telegram %s failed: %s", method, result) return result except Exception as exc: logger.error("telegram %s error: %s", method, exc) return {"ok": False, "error": str(exc)}
async def send_message( self, chat_id: int | str, text: str, parse_mode: str = "HTML" ) -> dict[str, Any]: if len(text) > MAX_MESSAGE_LENGTH: text = text[: MAX_MESSAGE_LENGTH - 3] + "..." return await self.call("sendMessage", chat_id=chat_id, text=text, parse_mode=parse_mode)
async def send_long_message(self, chat_id: int | str, text: str) -> None: """Split on paragraph boundaries and send sequentially.""" if len(text) <= MAX_MESSAGE_LENGTH: await self.send_message(chat_id, text) return
chunk = "" for part in text.split("\n\n"): if not part.strip(): continue part += "\n\n" if len(chunk) + len(part) > MAX_MESSAGE_LENGTH: if chunk: await self.send_message(chat_id, chunk) await asyncio.sleep(0.5) # keep ordering, avoid rate limits chunk = part else: chunk += part if chunk: await self.send_message(chat_id, chunk)12345678910from typing import Any
from pydantic import BaseModel
class TelegramUpdate(BaseModel): update_id: int message: dict[str, Any] | None = None edited_message: dict[str, Any] | None = None callback_query: dict[str, Any] | None = None10 unmodified lines111213141516112 unmodified lines12913013113213313440 unmodified lines17517617717817918093 unmodified lines2742752762772782792802812822832842852862874 unmodified lines292293294295296297298299300301302265 unmodified lines568569570571572573124 unmodified lines69869970070170270330 unmodified lines73473573673773873912 unmodified lines75275375475575675710 unmodified lines"python_full_version < '3.11'",][[package]]name = "beautifulsoup4"version = "4.15.0"112 unmodified lines{ url = "https://files.pythonhosted.org/packages/98/2b/f97f1c193fb855c345d678f5077d6926034db0722df74c8f057020e05a25/charset_normalizer-3.4.9-py3-none-any.whl", hash = "sha256:68e5f26a1ad57ded6d1cfb85331d1c1a195314756471d97758c48498bb4dcdf5", size = 64538, upload-time = "2026-07-07T14:34:56.993Z" },][[package]]name = "colorama"version = "0.4.6"40 unmodified lines{ url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" },][[package]]name = "idna"version = "3.18"93 unmodified linesversion = "0.1.0"source = { editable = "." }dependencies = [{ name = "lxml" },{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },{ name = "pandas", version = "2.3.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },{ name = "pandas", version = "3.0.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },{ name = "pyyaml" },{ name = "requests" },{ name = "yfinance" },]4 unmodified lines[package.metadata]requires-dist = [{ name = "lxml" },{ name = "numpy" },{ name = "pandas" },{ name = "pyyaml" },{ name = "requests" },{ name = "yfinance" },]265 unmodified lines{ url = "https://files.pythonhosted.org/packages/0c/c3/44f3fbbfa403ea2a7c779186dc20772604442dde72947e7d01069cbe98e3/pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992", size = 48172, upload-time = "2026-01-21T14:26:50.693Z" },][[package]]name = "pygments"version = "2.20.0"124 unmodified lines{ url = "https://files.pythonhosted.org/packages/5e/f5/0c41cb68dcae6b7de4fac4188a3a9589e21fb31df21ea3a2e888db95e6c9/soupsieve-2.8.4-py3-none-any.whl", hash = "sha256:e7e6b0769c8f51ed59acab6e994b00621096cfb1c640a7509295987388fbaf65", size = 37304, upload-time = "2026-05-24T13:55:55.406Z" },][[package]]name = "tomli"version = "2.4.1"30 unmodified lines{ url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },][[package]]name = "tzdata"version = "2026.3"12 unmodified lines{ url = "https://files.pythonhosted.org/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.151Z" },][[package]]name = "websockets"version = "16.1"10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434445464748112 unmodified lines16116216316416516616716816917017117217317417517617717840 unmodified lines21922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627793 unmodified lines3713723733743753763773783793803813823833843853863873884 unmodified lines393394395396397398399400401402403404405406407265 unmodified lines673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764124 unmodified lines88989089189289389489589689789889990090190290390490590690730 unmodified lines93893994094194294394494594694794894995095195295395495512 unmodified lines96896997097197297397497597697797897998098198298398498598698710 unmodified lines"python_full_version < '3.11'",][[package]]name = "annotated-doc"version = "0.0.4"source = { registry = "https://pypi.org/simple" }sdist = { url = "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz", hash = "sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size = 7288, upload-time = "2025-11-10T22:07:42.062Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl", hash = "sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size = 5303, upload-time = "2025-11-10T22:07:40.673Z" },][[package]]name = "annotated-types"version = "0.7.0"source = { registry = "https://pypi.org/simple" }sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" },][[package]]name = "anyio"version = "4.14.2"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },{ name = "idna" },{ name = "typing-extensions" },]sdist = { url = "https://files.pythonhosted.org/packages/61/cc/a381afa6efea9f496eff839d4a6a1aed3bfafc7b3ab4b0d1b243a12573dd/anyio-4.14.2.tar.gz", hash = "sha256:cfa139f3ed1a23ee8f88a145ddb5ac7605b8bbfd8592baacd7ce3d8bb4313c7f", size = 260176, upload-time = "2026-07-12T20:29:07.082Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/da/35/f2287558c17e29fafc8ef3daf819bb9834061cfa43bff8014f7df7f63bdc/anyio-4.14.2-py3-none-any.whl", hash = "sha256:9f505dda5ac9f0c8309b5e8bd445a8c2bf7246f3ce950121e45ea15bc41d1494", size = 125813, upload-time = "2026-07-12T20:29:05.763Z" },][[package]]name = "beautifulsoup4"version = "4.15.0"112 unmodified lines{ url = "https://files.pythonhosted.org/packages/98/2b/f97f1c193fb855c345d678f5077d6926034db0722df74c8f057020e05a25/charset_normalizer-3.4.9-py3-none-any.whl", hash = "sha256:68e5f26a1ad57ded6d1cfb85331d1c1a195314756471d97758c48498bb4dcdf5", size = 64538, upload-time = "2026-07-07T14:34:56.993Z" },][[package]]name = "click"version = "8.4.2"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "colorama", marker = "sys_platform == 'win32'" },]sdist = { url = "https://files.pythonhosted.org/packages/76/d4/81420972a676e8ffea40450d8c8c92943e7218a78fe9b64359836cc9876b/click-8.4.2.tar.gz", hash = "sha256:9a6cea6e60b17ebe0a44c5cc636d94f09bd66142c1cd7d8b4cd731c4917a15f6", size = 338000, upload-time = "2026-06-24T17:45:15.148Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/fb/e2/79c688af8b210d232694e31e59da9f6ec747bae31c3f5946e4e9b98860d5/click-8.4.2-py3-none-any.whl", hash = "sha256:e6f9f66136c816745b9d65817da91d61d957fb16e02e4dcd0552553c5a197b76", size = 119243, upload-time = "2026-06-24T17:45:13.73Z" },][[package]]name = "colorama"version = "0.4.6"40 unmodified lines{ url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" },][[package]]name = "fastapi"version = "0.139.2"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "annotated-doc" },{ name = "pydantic" },{ name = "starlette" },{ name = "typing-extensions" },{ name = "typing-inspection" },]sdist = { url = "https://files.pythonhosted.org/packages/cd/95/d3f0ae10836324a2eab98a52b61210ac609f08200bf4bb0dc8132d32f78a/fastapi-0.139.2.tar.gz", hash = "sha256:333145a6891e9b5b3cfceb69baf817e8240cde4d4588ae5a10bf56ffacb6255e", size = 423428, upload-time = "2026-07-16T15:06:17.912Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/5f/c7/cb03251d9dfb177246a9809a76f189d21df32dbd4a845951881d11323b7f/fastapi-0.139.2-py3-none-any.whl", hash = "sha256:b9ad015a835173d59865e2f5d8296fbc2b317bf56a2ba1a5bfbdd03de2fd4b1c", size = 130234, upload-time = "2026-07-16T15:06:19.557Z" },][[package]]name = "h11"version = "0.16.0"source = { registry = "https://pypi.org/simple" }sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },][[package]]name = "httpcore"version = "1.0.9"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "certifi" },{ name = "h11" },]sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" },][[package]]name = "httpx"version = "0.28.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "anyio" },{ name = "certifi" },{ name = "httpcore" },{ name = "idna" },]sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" },][[package]]name = "idna"version = "3.18"93 unmodified linesversion = "0.1.0"source = { editable = "." }dependencies = [{ name = "fastapi" },{ name = "httpx" },{ name = "lxml" },{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },{ name = "pandas", version = "2.3.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },{ name = "pandas", version = "3.0.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },{ name = "pydantic" },{ name = "pyyaml" },{ name = "requests" },{ name = "uvicorn" },{ name = "yfinance" },]4 unmodified lines[package.metadata]requires-dist = [{ name = "fastapi" },{ name = "httpx" },{ name = "lxml" },{ name = "numpy" },{ name = "pandas" },{ name = "pydantic" },{ name = "pyyaml" },{ name = "requests" },{ name = "uvicorn" },{ name = "yfinance" },]265 unmodified lines{ url = "https://files.pythonhosted.org/packages/0c/c3/44f3fbbfa403ea2a7c779186dc20772604442dde72947e7d01069cbe98e3/pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992", size = 48172, upload-time = "2026-01-21T14:26:50.693Z" },][[package]]name = "pydantic"version = "2.13.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "annotated-types" },{ name = "pydantic-core" },{ name = "typing-extensions" },{ name = "typing-inspection" },]sdist = { url = "https://files.pythonhosted.org/packages/18/a5/b60d21ac674192f8ab0ba4e9fd860690f9b4a6e51ca5df118733b487d8d6/pydantic-2.13.4.tar.gz", hash = "sha256:c40756b57adaa8b1efeeced5c196f3f3b7c435f90e84ea7f443901bec8099ef6", size = 844775, upload-time = "2026-05-06T13:43:05.343Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/fd/7b/122376b1fd3c62c1ed9dc80c931ace4844b3c55407b6fb2d199377c9736f/pydantic-2.13.4-py3-none-any.whl", hash = "sha256:45a282cde31d808236fd7ea9d919b128653c8b38b393d1c4ab335c62924d9aba", size = 472262, upload-time = "2026-05-06T13:43:02.641Z" },][[package]]name = "pydantic-core"version = "2.46.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "typing-extensions" },]sdist = { url = "https://files.pythonhosted.org/packages/9d/56/921726b776ace8d8f5db44c4ef961006580d91dc52b803c489fafd1aa249/pydantic_core-2.46.4.tar.gz", hash = "sha256:62f875393d7f270851f20523dd2e29f082bcc82292d66db2b64ea71f64b6e1c1", size = 471464, upload-time = "2026-05-06T13:37:06.98Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/e7/08/f1ba952f1c8ae5581c70fa9c6da89f247b83e3dd8c09c035d5d7931fc23d/pydantic_core-2.46.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:a396dcc17e5a0b164dbe026896245a4fa9ff402edca1dff0be3d53a517f74de4", size = 2113146, upload-time = "2026-05-06T13:37:36.537Z" },{ url = "https://files.pythonhosted.org/packages/56/c6/65f646c7ff09bd257f660434adb45c4dfcbbcebcc030562fecf6f5bf887d/pydantic_core-2.46.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:da4b951fe36dc7c3a1ccb4e3cd1747c3542b8c9ceede8fc86cae054e764485f5", size = 1949769, upload-time = "2026-05-06T13:37:46.365Z" },{ url = "https://files.pythonhosted.org/packages/64/ba/bfb1d928fd5b49e1258935ff104ae356e9fd89384a55bf9f847e9193ad40/pydantic_core-2.46.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb63e0198ca18aad131c089b9204c23079c3afa95487e561f4c522d519e55aba", size = 1974958, upload-time = "2026-05-06T13:37:28.611Z" },{ url = "https://files.pythonhosted.org/packages/4e/74/76223bfb117b64af743c9b6670d1364516f5c0604f96b48f3272f6af6cc6/pydantic_core-2.46.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f47286a97f0bc9b8859519809077b91b2cefe4ae47fcbf5e466a009c1c5d742b", size = 2042118, upload-time = "2026-05-06T13:36:55.216Z" },{ url = "https://files.pythonhosted.org/packages/cb/7b/848732968bc8f48f3187542f08358b9d842db564147b256669426ebb1652/pydantic_core-2.46.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:905a0ed8ea6f2d61c1738835f99b699348d7857379083e5fc497fa0c967a407c", size = 2222876, upload-time = "2026-05-06T13:38:25.455Z" },{ url = "https://files.pythonhosted.org/packages/b5/2f/e90b63ee2e14bd8d3db8f705a6d75d64e6ee1b7c2c8833747ce706e1e0ce/pydantic_core-2.46.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ea793e075b70290d89d8142074262885d3f7da19634845135751bd6344f73b50", size = 2286703, upload-time = "2026-05-06T13:37:53.304Z" },{ url = "https://files.pythonhosted.org/packages/ba/1e/acc4d70f88a0a277e4a1fa77ebb985ceabaf900430f875bf9338e11c9420/pydantic_core-2.46.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:395aebd9183f9d112f569aeb5b2214d1a10a33bec8456447f7fbdfa51d38d4cd", size = 2092042, upload-time = "2026-05-06T13:38:46.981Z" },{ url = "https://files.pythonhosted.org/packages/a9/da/0a422b57bf8504102bf3c4ccea9c41bab5a5cee6a54650acf8faf67f5a24/pydantic_core-2.46.4-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:b078afbc25f3a1436c7a1d2cd3e322497ee99615ba97c563566fdf46aff1ee01", size = 2117231, upload-time = "2026-05-06T13:39:23.146Z" },{ url = "https://files.pythonhosted.org/packages/bd/2a/2ac13c3af305843e23c5078c53d135656b3f05a2fd78cb7bbbb12e97b473/pydantic_core-2.46.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f747929cf940cddb5b3668a390056ddd5ba2e5010615ea2dcf4f9c4f3ab8791d", size = 2168388, upload-time = "2026-05-06T13:40:08.06Z" },{ url = "https://files.pythonhosted.org/packages/72/04/2beacf7e1607e93eefe4aed1b4709f079b905fb77530179d4f7c71745f22/pydantic_core-2.46.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:daa27d92c36f24388fe3ad306b174781c747627f134452e4f128ea00ce1fe8c4", size = 2184769, upload-time = "2026-05-06T13:38:13.901Z" },{ url = "https://files.pythonhosted.org/packages/9e/29/d2b9fd9f539133548eaf622c06a4ce176cb46ac59f32d0359c4abc0de047/pydantic_core-2.46.4-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:19e51f073cd3df251856a8a4189fbdf1de4012c3ebacfb1884f94f1eb406079f", size = 2319312, upload-time = "2026-05-06T13:39:08.24Z" },{ url = "https://files.pythonhosted.org/packages/7c/af/0f7a5b85fec6075bea96e3ef9187de38fccced0de92c1e7feda8d5cc7bb9/pydantic_core-2.46.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c1747f85cee84c26985853c6f3d9bd3e75da5212912443fa111c113b9c246f39", size = 2361817, upload-time = "2026-05-06T13:38:43.2Z" },{ url = "https://files.pythonhosted.org/packages/25/a4/73363fec545fd3ec025490bdda2743c56d0dd5b6266b1a53bbe9e4265375/pydantic_core-2.46.4-cp310-cp310-win32.whl", hash = "sha256:2f84c03c8607173d16b5a854ec68a2f9079ae03237a54fb506d13af47e1d018d", size = 1987085, upload-time = "2026-05-06T13:39:25.497Z" },{ url = "https://files.pythonhosted.org/packages/01/aa/62f082da2c91fac1c234bc9ee0066257ce83f0604abd72e4c9d5991f2d84/pydantic_core-2.46.4-cp310-cp310-win_amd64.whl", hash = "sha256:8358a950c8909158e3df31538a7e4edc2d7265a7c54b47f0864d9e5bae9dcebf", size = 2074311, upload-time = "2026-05-06T13:39:59.922Z" },{ url = "https://files.pythonhosted.org/packages/5c/fa/6d7708d2cfc1a832acb6aeb0cd16e801902df8a0f583bb3b4b527fde022e/pydantic_core-2.46.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:0e96592440881c74a213e5ad528e2b24d3d4f940de2766bed9010ab1d9e51594", size = 2111872, upload-time = "2026-05-06T13:40:27.596Z" },{ url = "https://files.pythonhosted.org/packages/ae/6f/aa064a3e74b5745afbdf250594f38e7ead05e2d651bcb35994b9417a0d4d/pydantic_core-2.46.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e0d65b8c354be7fb5f720c3caa8bc940bc2d20ce749c8e06135f07f8ed95dd7c", size = 1948255, upload-time = "2026-05-06T13:39:12.574Z" },{ url = "https://files.pythonhosted.org/packages/43/3a/41114a9f7569b84b4d84e7a018c57c56347dac30c0d4a872946ec4e36c46/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7bfb192b3f4b9e8a89b6277b6ce787564f62cfd272055f6e685726b111dc7826", size = 1972827, upload-time = "2026-05-06T13:38:19.841Z" },{ url = "https://files.pythonhosted.org/packages/ef/25/1ab42e8048fe551934d9884e8d64daa7e990ad386f310a15981aeb6a5b08/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9037063db01f09b09e237c282b6792bd4da634b5402c4e7f0c61effed7701a04", size = 2041051, upload-time = "2026-05-06T13:38:10.447Z" },{ url = "https://files.pythonhosted.org/packages/94/c2/1a934597ddf08da410385b3b7aae91956a5a76c635effef456074fad7e88/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc010ab034c8c7452522748bf937df58020d256ccae0874463d1f4d01758af8e", size = 2221314, upload-time = "2026-05-06T13:40:13.089Z" },{ url = "https://files.pythonhosted.org/packages/02/6d/9e8ad178c9c4df27ad3c8f25d1fe2a7ab0d2ba0559fad4aee5d3d1f16771/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8c5dac79fa1614d1e06ca695109c6105923bd9c7d1d6c918d4e637b7e6b32fd3", size = 2285146, upload-time = "2026-05-06T13:38:59.224Z" },{ url = "https://files.pythonhosted.org/packages/80/50/540cd3aeefc041beb111125c4bff779831a2111fc6b15a9138cda277d32c/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9fa868638bf362d3d138ea55829cefb3d5f4b0d7f142234382a15e2485dbec4", size = 2089685, upload-time = "2026-05-06T13:38:17.762Z" },{ url = "https://files.pythonhosted.org/packages/6b/a4/b440ad35f05f6a38f89fa0f149accb3f0e02be94ca5e15f3c449a61b4bc9/pydantic_core-2.46.4-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:17299feefe090f2caa5b8e37222bb5f663e4935a8bfa6931d4102e5df1a9f398", size = 2115420, upload-time = "2026-05-06T13:37:58.195Z" },{ url = "https://files.pythonhosted.org/packages/99/61/de4f55db8dfd57bfdfa9a12ec90fe1b57c4f41062f7ca86f08586b3e0ac0/pydantic_core-2.46.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4c63ebc82684aa89d9a3bcbd13d515b3be44250dc68dd3bd81526c1cb31286c3", size = 2165122, upload-time = "2026-05-06T13:37:01.167Z" },{ url = "https://files.pythonhosted.org/packages/f7/52/7c529d7bdb2d1068bd52f51fe32572c8301f9a4febf1948f10639f1436f5/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:aaa2a54443eff1950ba5ddc6b6ccda0d9c84a364276a62f969bdf2a390650848", size = 2182573, upload-time = "2026-05-06T13:38:45.04Z" },{ url = "https://files.pythonhosted.org/packages/37/b3/7c40325848ba78247f2812dcf9c7274e38cd801820ca6dd9fe63bcfb0eb4/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:18e5ceec2ab67e6d5f1a9085e5a24c9c4e2ac4545730bfe668680bca05e555f3", size = 2317139, upload-time = "2026-05-06T13:37:15.539Z" },{ url = "https://files.pythonhosted.org/packages/d9/37/f913f81a657c865b75da6c0dbed79876073c2a43b5bd9edbe8da785e4d49/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a0f62d0a58f4e7da165457e995725421e0064f2255d8eccebc49f41bbc23b109", size = 2360433, upload-time = "2026-05-06T13:37:30.099Z" },{ url = "https://files.pythonhosted.org/packages/c4/67/6acaa1be2567f9256b056d8477158cac7240813956ce86e49deae8e173b4/pydantic_core-2.46.4-cp311-cp311-win32.whl", hash = "sha256:041bde0a48fd37cf71cab1c9d56d3e8625a3793fef1f7dd232b3ff37e978ecda", size = 1985513, upload-time = "2026-05-06T13:38:15.669Z" },{ url = "https://files.pythonhosted.org/packages/aa/e6/c505f83dfeda9a2e5c995cfd872949e4d05e12f7feb3dca72f633daefa94/pydantic_core-2.46.4-cp311-cp311-win_amd64.whl", hash = "sha256:6f2eeda33a839975441c86a4119e1383c50b47faf0cbb5176985565c6bb02c33", size = 2071114, upload-time = "2026-05-06T13:40:35.416Z" },{ url = "https://files.pythonhosted.org/packages/0f/da/7a263a96d965d9d0df5e8de8a475f33495451117035b09acb110288c381f/pydantic_core-2.46.4-cp311-cp311-win_arm64.whl", hash = "sha256:14f4c5d6db102bd796a627bbb3a17b4cf4574b9ae861d8b7c9a9661c6dd3362d", size = 2044298, upload-time = "2026-05-06T13:38:29.754Z" },{ url = "https://files.pythonhosted.org/packages/ce/8c/af022f0af448d7747c5154288d46b5f2bc5f17366eaa0e23e9aa04d59f3b/pydantic_core-2.46.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:3245406455a5d98187ec35530fd772b1d799b26667980872c8d4614991e2c4a2", size = 2106158, upload-time = "2026-05-06T13:38:57.215Z" },{ url = "https://files.pythonhosted.org/packages/19/95/6195171e385007300f0f5574592e467c568becce2d937a0b6804f218bc49/pydantic_core-2.46.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:962ccbab7b642487b1d8b7df90ef677e03134cf1fd8880bf698649b22a69371f", size = 1951724, upload-time = "2026-05-06T13:37:02.697Z" },{ url = "https://files.pythonhosted.org/packages/8e/bc/f47d1ff9cbb1620e1b5b697eef06010035735f07820180e74178226b27b3/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8233f2947cf85404441fd7e0085f53b10c93e0ee78611099b5c7237e36aacbf7", size = 1975742, upload-time = "2026-05-06T13:37:09.448Z" },{ url = "https://files.pythonhosted.org/packages/5b/11/9b9a5b0306345664a2da6410877af6e8082481b5884b3ddd78d47c6013ce/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3a233125ac121aa3ffba9a2b59edfc4a985a76092dc8279586ab4b71390875e7", size = 2052418, upload-time = "2026-05-06T13:37:38.234Z" },{ url = "https://files.pythonhosted.org/packages/f1/b7/a65fec226f5d78fc39f4a13c4cc0c768c22b113438f60c14adc9d2865038/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5b712b53160b79a5850310b912a5ef8e57e56947c8ad690c227f5c9d7e561712", size = 2232274, upload-time = "2026-05-06T13:38:27.753Z" },{ url = "https://files.pythonhosted.org/packages/68/f0/92039db98b907ef49269a8271f67db9cb78ae2fc68062ef7e4e77adb5f61/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9401557acd873c3a7f3eb9383edef8ac4968f9510e340f4808d427e75667e7b4", size = 2309940, upload-time = "2026-05-06T13:38:05.353Z" },{ url = "https://files.pythonhosted.org/packages/5f/97/2aab507d3d00ca626e8e57c1eac6a79e4e5fbcc63eb99733ff55d1717f65/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:926c9541b14b12b1681dca8a0b75feb510b06c6341b70a8e500c2fdcff837cce", size = 2094516, upload-time = "2026-05-06T13:39:10.577Z" },{ url = "https://files.pythonhosted.org/packages/22/37/a8aca44d40d737dde2bc05b3c6c07dff0de07ce6f82e9f3167aeaf4d5dea/pydantic_core-2.46.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:56cb4851bcaf3d117eddcef4fe66afd750a50274b0da8e22be256d10e5611987", size = 2136854, upload-time = "2026-05-06T13:40:22.59Z" },{ url = "https://files.pythonhosted.org/packages/24/99/fcef1b79238c06a8cbec70819ac722ba76e02bc8ada9b0fd66eba40da01b/pydantic_core-2.46.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c68fcd102d71ea85c5b2dfac3f4f8476eff42a9e078fd5faefff6d145063536b", size = 2180306, upload-time = "2026-05-06T13:40:10.666Z" },{ url = "https://files.pythonhosted.org/packages/ae/6c/fc44000918855b42779d007ae63b0532794739027b2f417321cddbc44f6a/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b2f69dec1725e79a012d920df1707de5caf7ed5e08f3be4435e25803efc47458", size = 2190044, upload-time = "2026-05-06T13:40:43.231Z" },{ url = "https://files.pythonhosted.org/packages/6b/65/d9cadc9f1920d7a127ad2edba16c1db7916e59719285cd6c94600b0080ba/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:8d0820e8192167f80d88d64038e609c31452eeca865b4e1d9950a27a4609b00b", size = 2329133, upload-time = "2026-05-06T13:39:57.365Z" },{ url = "https://files.pythonhosted.org/packages/d0/cf/c873d91679f3a30bcf5e7ac280ce5573483e72295307685120d0d5ad3416/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fbdb89b3e1c94a30cc5edfce477c6e6a5dc4d8f84665b455c27582f211a1c72c", size = 2374464, upload-time = "2026-05-06T13:38:06.976Z" },{ url = "https://files.pythonhosted.org/packages/47/bd/6f2fc8188f31bf10590f1e98e7b306336161fac930a8c514cd7bd828c7dc/pydantic_core-2.46.4-cp312-cp312-win32.whl", hash = "sha256:9aa768456404a8bf48a4406685ac2bec8e72b62c69313734fa3b73cf33b3a894", size = 1974823, upload-time = "2026-05-06T13:40:47.985Z" },{ url = "https://files.pythonhosted.org/packages/40/8c/985c1d41ea1107c2534abd9870e4ed5c8e7669b5c308297835c001e7a1c4/pydantic_core-2.46.4-cp312-cp312-win_amd64.whl", hash = "sha256:e9c26f834c65f5752f3f06cb08cb86a913ceb7274d0db6e267808a708b46bc89", size = 2072919, upload-time = "2026-05-06T13:39:21.153Z" },{ url = "https://files.pythonhosted.org/packages/c4/ba/f463d006e0c47373ca7ec5e1a261c59dc01ef4d62b2657af925fb0deee3a/pydantic_core-2.46.4-cp312-cp312-win_arm64.whl", hash = "sha256:4fc73cb559bdb54b1134a706a2802a4cddd27a0633f5abb7e53056268751ac6a", size = 2027604, upload-time = "2026-05-06T13:39:03.753Z" },{ url = "https://files.pythonhosted.org/packages/ee/a4/73995fd4ebbb46ba0ee51e6fa049b8f02c40daebb762208feda8a6b7894d/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:14d4edf427bdcf950a8a02d7cb44a08614388dd6e1bdcbf4f67504fa7887da9c", size = 2111589, upload-time = "2026-05-06T13:37:10.817Z" },{ url = "https://files.pythonhosted.org/packages/fb/7f/f37d3a5e8bfcc2e403f5c57a730f2d815693fb42119e8ea48b3789335af1/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:0ce40cd7b21210e99342afafbd4d0f76d784eb5b1d60f3bdc566be4983c6c73b", size = 1944552, upload-time = "2026-05-06T13:36:56.717Z" },{ url = "https://files.pythonhosted.org/packages/15/3c/d7eb777b3ff43e8433a4efb39a17aa8fd98a4ee8561a24a67ef5db07b2d6/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:90884113d8b48f760e9587002789ddd741e76ab9f89518cd1e43b1f1a52ec44b", size = 1982984, upload-time = "2026-05-06T13:39:06.207Z" },{ url = "https://files.pythonhosted.org/packages/63/87/70b9f40170a81afd55ca26c9b2acb25c20d64bcfbf888fafecb3ba077d4c/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66ce7632c22d837c95301830e111ad0128a32b8207533b60896a96c4915192ea", size = 2138417, upload-time = "2026-05-06T13:39:45.476Z" },{ url = "https://files.pythonhosted.org/packages/9d/1d/8987ad40f65ae1432753072f214fb5c74fe47ffbd0698bb9cbbb585664f8/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:1d8ba486450b14f3b1d63bc521d410ec7565e52f887b9fb671791886436a42f7", size = 2095527, upload-time = "2026-05-06T13:39:52.283Z" },{ url = "https://files.pythonhosted.org/packages/64/d3/84c282a7eee1d3ac4c0377546ef5a1ea436ce26840d9ac3b7ed54a377507/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:3009f12e4e90b7f88b4f9adb1b0c4a3d58fe7820f3238c190047209d148026df", size = 1936024, upload-time = "2026-05-06T13:40:15.671Z" },{ url = "https://files.pythonhosted.org/packages/d7/ca/eac61596cdeb4d7e174d3dc0bd8a6238f14f75f97a24e7b7db4c7e7340a0/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ad785e92e6dc634c21555edc8bd6b64957ab844541bcb96a1366c202951ae526", size = 1990696, upload-time = "2026-05-06T13:38:34.717Z" },{ url = "https://files.pythonhosted.org/packages/fa/c3/7c8b240552251faf6b3a957db200fcfbbcec36763c050428b601e0c9b83b/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:00c603d540afdd6b80eb39f078f33ebd46211f02f33e34a32d9f053bba711de0", size = 2147590, upload-time = "2026-05-06T13:39:29.883Z" },{ url = "https://files.pythonhosted.org/packages/11/cb/428de0385b6c8d44b716feba566abfacfbd23ee3c4439faa789a1456242f/pydantic_core-2.46.4-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:0c563b08bca408dc7f65f700633d8442fffb2421fc47b8101377e9fd65051ff0", size = 2112782, upload-time = "2026-05-06T13:37:04.016Z" },{ url = "https://files.pythonhosted.org/packages/0b/b5/6a17bdadd0fc1f170adfd05a20d37c832f52b117b4d9131da1f41bb097ce/pydantic_core-2.46.4-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:db06ffe51636ffe9ca531fe9023dd64bdd794be8754cb5df57c5498ae5b518a7", size = 1952146, upload-time = "2026-05-06T13:39:43.092Z" },{ url = "https://files.pythonhosted.org/packages/2a/dc/03734d80e362cd43ef65428e9de77c730ce7f2f11c60d2b1e1b39f0fbf99/pydantic_core-2.46.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:133878133d271ade3d41d1bfb2a45ec38dbdbda40bc065921c6b04e4630127e2", size = 2134492, upload-time = "2026-05-06T13:36:58.124Z" },{ url = "https://files.pythonhosted.org/packages/de/df/5e5ffc085ed07cc22d298134d3d911c63e91f6a0eb91fe646750a3209910/pydantic_core-2.46.4-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9bc519fbf2b7578398853d815009ae5e4d4603d12f4e3f91da8c06852d3da3e9", size = 2156604, upload-time = "2026-05-06T13:37:49.88Z" },{ url = "https://files.pythonhosted.org/packages/81/44/6e112a4253e56f5705467cbab7ab5e91ee7398ba3d56d358635958893d3e/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c7a7bd4e39e8e4c12c39cd480356842b6a8a06e41b23a55a5e3e191718838ddf", size = 2183828, upload-time = "2026-05-06T13:37:43.053Z" },{ url = "https://files.pythonhosted.org/packages/ac/ad/5565071e937d8e752842ac241463944c9eb14c87e2d269f2658a5bd05e98/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:d396ec2b979760aaf3218e76c24e65bd0aca24983298653b3a9d7a45f9e47b30", size = 2310000, upload-time = "2026-05-06T13:37:56.694Z" },{ url = "https://files.pythonhosted.org/packages/4f/c3/66883a5cec183e7fba4d024b4cbbe61851a63750ef606b0afecc46d1f2bf/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:86e1a4418c6cd97d60c95c71164158eaf7324fae7b0923264016baa993eba6fc", size = 2361286, upload-time = "2026-05-06T13:40:05.667Z" },{ url = "https://files.pythonhosted.org/packages/4b/2d/69abac8f838090bbecd5df894befb2c2619e7996a98ddb949db9f3b93225/pydantic_core-2.46.4-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:d51026d73fcfd93610abc7b27789c26b313920fcfb20e27462d74a7f8b06e983", size = 2193071, upload-time = "2026-05-06T13:38:08.682Z" },][[package]]name = "pygments"version = "2.20.0"124 unmodified lines{ url = "https://files.pythonhosted.org/packages/5e/f5/0c41cb68dcae6b7de4fac4188a3a9589e21fb31df21ea3a2e888db95e6c9/soupsieve-2.8.4-py3-none-any.whl", hash = "sha256:e7e6b0769c8f51ed59acab6e994b00621096cfb1c640a7509295987388fbaf65", size = 37304, upload-time = "2026-05-24T13:55:55.406Z" },][[package]]name = "starlette"version = "1.3.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "anyio" },{ name = "typing-extensions" },]sdist = { url = "https://files.pythonhosted.org/packages/eb/e3/7c1dc7381d9f8ab7d854328ebfa884e62cb3f3d8549ddfd37c7814f42afa/starlette-1.3.1.tar.gz", hash = "sha256:05d0213193f2fbaae60e2ecb593b4add4262ad4e46536b54abe36f11a71724e0", size = 2703240, upload-time = "2026-06-12T09:23:11.602Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/ec/bb/2799cc2ede3ed41131f8975621e7213dfc7ef4acbbaadfa440f32500c370/starlette-1.3.1-py3-none-any.whl", hash = "sha256:c7372aae11c3c3f26a42df7bd626cec2f47d03483d261d369516a615a53714c6", size = 73632, upload-time = "2026-06-12T09:23:10.017Z" },][[package]]name = "tomli"version = "2.4.1"30 unmodified lines{ url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },][[package]]name = "typing-inspection"version = "0.4.2"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "typing-extensions" },]sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" },][[package]]name = "tzdata"version = "2026.3"12 unmodified lines{ url = "https://files.pythonhosted.org/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.151Z" },][[package]]name = "uvicorn"version = "0.51.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "click" },{ name = "h11" },{ name = "typing-extensions", marker = "python_full_version < '3.11'" },]sdist = { url = "https://files.pythonhosted.org/packages/a2/65/b7c6c443ccc58678c91e1e973bbe2a878591538655d6e1d47f24ba1c51f3/uvicorn-0.51.0.tar.gz", hash = "sha256:f6f4b69b657c312f516dd2d268ab9ae6f254b11e4bac504f37b2ab58b24dd0b0", size = 94412, upload-time = "2026-07-08T10:59:05.962Z" }wheels = [{ url = "https://files.pythonhosted.org/packages/45/ec/dbb7e5a6b91f86bfb9eb7d2988a2730907b6a729875b949c7f022e8b88fa/uvicorn-0.51.0-py3-none-any.whl", hash = "sha256:5d38af6cd620f2ae3849fb44fd4879e0890aa1febe8d47eb355fb45d93fe6a5b", size = 73219, upload-time = "2026-07-08T10:59:04.44Z" },][[package]]name = "websockets"version = "16.1"