major update
This commit is contained in:
@@ -6,6 +6,7 @@ using a time-decay weighted average over a configurable lookback window.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import math
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
@@ -34,6 +35,8 @@ async def store_sentiment(
|
||||
confidence: int,
|
||||
source: str,
|
||||
timestamp: datetime | None = None,
|
||||
reasoning: str = "",
|
||||
citations: list[dict] | None = None,
|
||||
) -> SentimentScore:
|
||||
"""Store a new sentiment record for a ticker."""
|
||||
ticker = await _get_ticker(db, symbol)
|
||||
@@ -41,12 +44,17 @@ async def store_sentiment(
|
||||
if timestamp is None:
|
||||
timestamp = datetime.now(timezone.utc)
|
||||
|
||||
if citations is None:
|
||||
citations = []
|
||||
|
||||
record = SentimentScore(
|
||||
ticker_id=ticker.id,
|
||||
classification=classification,
|
||||
confidence=confidence,
|
||||
source=source,
|
||||
timestamp=timestamp,
|
||||
reasoning=reasoning,
|
||||
citations_json=json.dumps(citations),
|
||||
)
|
||||
db.add(record)
|
||||
await db.commit()
|
||||
|
||||
Reference in New Issue
Block a user