31 lines
738 B
Python
31 lines
738 B
Python
"""Pydantic schemas for sentiment endpoints."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class SentimentScoreResult(BaseModel):
|
|
"""A single sentiment score record."""
|
|
|
|
id: int
|
|
classification: Literal["bullish", "bearish", "neutral"]
|
|
confidence: int = Field(ge=0, le=100)
|
|
source: str
|
|
timestamp: datetime
|
|
|
|
|
|
class SentimentResponse(BaseModel):
|
|
"""Envelope-ready sentiment response."""
|
|
|
|
symbol: str
|
|
scores: list[SentimentScoreResult]
|
|
count: int
|
|
dimension_score: float | None = Field(
|
|
None, ge=0, le=100, description="Time-decay weighted sentiment dimension score"
|
|
)
|
|
lookback_hours: float
|