feat: productionize local service — fix signal pipeline, lower thresholds, add company-name ticker extraction
- Point Ollama to local instance via host.docker.internal, use gemma3 model - Remove Docker Ollama service (using host's Ollama instead) - Add company-name-to-ticker mapping (Apple→AAPL, Tesla→TSLA, etc.) for RSS articles - Lower signal thresholds for faster feedback with paper trading: - FinBERT confidence: 0.6→0.4, signal strength: 0.3→0.15 - News strategy: article_count 2→1, confidence 0.5→0.3, score ±0.3→±0.15 - Fix market data BarSet access bug (BarSet.__contains__ returns False incorrectly) - Fix market data SIP feed error by switching to IEX feed for free Alpaca accounts - Fix nginx proxy routing for /api/auth/* to api-gateway /auth/* - Add seed_sample_data script - Update tests for new thresholds and alpaca mock modules
This commit is contained in:
parent
67e64fab18
commit
d36ae40df1
18 changed files with 749 additions and 185 deletions
|
|
@ -20,10 +20,13 @@ async def list_news(
|
|||
max_score: float | None = Query(default=None, ge=-1.0, le=1.0),
|
||||
page: int = Query(default=1, ge=1),
|
||||
per_page: int = Query(default=20, ge=1, le=100),
|
||||
page_size: int | None = Query(default=None, ge=1, le=100),
|
||||
) -> dict:
|
||||
"""Recent scored articles with optional filters."""
|
||||
from shared.models.news import Article, ArticleSentiment
|
||||
|
||||
effective_per_page = page_size if page_size is not None else per_page
|
||||
|
||||
db = request.app.state.db_session_factory
|
||||
async with db() as session:
|
||||
# Base query joining articles with sentiments
|
||||
|
|
@ -54,34 +57,35 @@ async def list_news(
|
|||
count_query = count_query.where(ArticleSentiment.score <= max_score)
|
||||
|
||||
total = (await session.execute(count_query)).scalar() or 0
|
||||
offset = (page - 1) * per_page
|
||||
query = query.offset(offset).limit(per_page)
|
||||
offset = (page - 1) * effective_per_page
|
||||
query = query.offset(offset).limit(effective_per_page)
|
||||
|
||||
result = await session.execute(query)
|
||||
rows = result.all()
|
||||
|
||||
return {
|
||||
"articles": [
|
||||
{
|
||||
"id": str(article.id),
|
||||
"source": article.source,
|
||||
"url": article.url,
|
||||
"title": article.title,
|
||||
"published_at": (
|
||||
article.published_at.isoformat()
|
||||
if article.published_at
|
||||
else None
|
||||
),
|
||||
"fetched_at": article.fetched_at.isoformat(),
|
||||
"ticker": sentiment.ticker,
|
||||
"sentiment_score": sentiment.score,
|
||||
"confidence": sentiment.confidence,
|
||||
"model_used": sentiment.model_used,
|
||||
}
|
||||
for article, sentiment in rows
|
||||
],
|
||||
"total": total,
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
"pages": (total + per_page - 1) // per_page if per_page else 0,
|
||||
}
|
||||
return {
|
||||
"articles": [
|
||||
{
|
||||
"id": str(article.id),
|
||||
"source": article.source,
|
||||
"url": article.url,
|
||||
"title": article.title,
|
||||
"published_at": (
|
||||
article.published_at.isoformat()
|
||||
if article.published_at
|
||||
else None
|
||||
),
|
||||
"fetched_at": article.fetched_at.isoformat(),
|
||||
"ticker": sentiment.ticker,
|
||||
"sentiment_score": sentiment.score,
|
||||
"confidence": sentiment.confidence,
|
||||
"model_used": sentiment.model_used,
|
||||
}
|
||||
for article, sentiment in rows
|
||||
],
|
||||
"total": total,
|
||||
"page": page,
|
||||
"page_size": effective_per_page,
|
||||
"per_page": effective_per_page,
|
||||
"pages": (total + effective_per_page - 1) // effective_per_page if effective_per_page else 0,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue