26 lines
760 B
Python
26 lines
760 B
Python
"""Abstract base class for trading strategies."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from shared.schemas.trading import MarketSnapshot, SentimentContext, TradeSignal
|
|
|
|
|
|
class BaseStrategy(ABC):
|
|
"""Interface that every trading strategy must implement.
|
|
|
|
Each strategy evaluates market conditions (and optionally sentiment)
|
|
for a given ticker and returns a ``TradeSignal`` if the strategy has
|
|
an opinion, or ``None`` if it is neutral.
|
|
"""
|
|
|
|
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."""
|
|
...
|