checking system…
Docs / back / src/maf/sources/adapters/alpaca.py · line 34
Python · 43 lines
 1"""Alpaca source adapter — stub kept for backwards compatibility.
 2
 3**Design decision:** MAF does NOT call Alpaca directly. trtools2 owns the
 4Alpaca integration end-to-end (live feed engine, news ingester, backfill,
 5QuestDB persistence). MAF consumes that data via the trtools2 Redis Streams
 6(``trtools2_bars`` / ``trtools2_news`` adapters) and the trtools2 HTTP API
 7(``trtools2_api`` adapter).
 8
 9This stub remains so legacy arena configs that still reference ``alpaca``
10fail loudly with an actionable message rather than silently producing
11empty payloads.
12"""
13
14from __future__ import annotations
15
16import logging
17from typing import Any
18
19from maf.sources.base import BaseSource
20
21logger = logging.getLogger(__name__)
22
23
24_GUIDANCE = (
25    "Direct Alpaca access is disabled. Use the trtools2 path instead: "
26    "bind `trtools2_bars` / `trtools2_news` (Redis Streams) or "
27    "`trtools2_api` (HTTP) — both ultimately source from Alpaca via trtools2."
28)
29
30
31class AlpacaSource(BaseSource):
32    """Hard stub — kept registered so old configs don't 500 on load."""
33
34    adapter_name = "alpaca"
35
36    async def fetch(self, params: dict[str, Any] | None = None) -> dict[str, Any]:
37        return {
38            "type": "alpaca",
39            "data": [],
40            "error": _GUIDANCE,
41            "guidance": _GUIDANCE,
42        }