Source code for trader.marketdata.base
"""The market-data interface the Core Service Layer depends on.
A Protocol keeps `yfinance` and `pandas` out of the Core, so additional
providers can be added later (requirements ยง7 wants extensible sources).
"""
from datetime import date
from typing import Protocol, runtime_checkable
from trader.domain import Bar, Quote
__all__ = ["MarketDataProvider"]
[docs]
@runtime_checkable
class MarketDataProvider(Protocol):
"""Live and historical price data."""
[docs]
def get_quote(self, symbol: str) -> Quote:
"""Return the most recent observed price for `symbol`."""
...
[docs]
def get_history(
self, symbol: str, start: date, end: date, interval: str = "1d"
) -> list[Bar]:
"""Return OHLCV bars for `symbol` between `start` and `end`."""
...