26 lines
772 B
Python
26 lines
772 B
Python
"""Abstract base class for all trading strategies."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from shared.schemas.trading import MarketSnapshot, SentimentContext, TradeSignal
|
|
|
|
|
|
class BaseStrategy(ABC):
|
|
"""Base class that all trading strategies must inherit from.
|
|
|
|
Subclasses implement :meth:`evaluate` to inspect market data and
|
|
optionally sentiment, returning a :class:`TradeSignal` when the
|
|
strategy has a directional opinion and ``None`` otherwise.
|
|
"""
|
|
|
|
name: str
|
|
|
|
@abstractmethod
|
|
async def evaluate(
|
|
self,
|
|
ticker: str,
|
|
market: MarketSnapshot,
|
|
sentiment: SentimentContext | None = None,
|
|
) -> TradeSignal | None:
|
|
"""Return a signal if this strategy has an opinion, None otherwise."""
|
|
...
|