Files
signal-platform/app/schemas/sentiment.py
Dennis Thiessen 181cfe6588
Some checks failed
Deploy / lint (push) Failing after 8s
Deploy / test (push) Has been skipped
Deploy / deploy (push) Has been skipped
major update
2026-02-27 16:08:09 +01:00

40 lines
920 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 CitationItem(BaseModel):
"""A single citation from the sentiment analysis."""
url: str
title: str
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
reasoning: str = ""
citations: list[CitationItem] = []
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