Initial project structure: MarketScanner - Fear-to-Fortune Trading Intelligence
Features: - FastAPI backend with stocks, news, signals, watchlist, analytics endpoints - React frontend with TailwindCSS dark mode trading dashboard - Celery workers for news fetching, sentiment analysis, pattern detection - TimescaleDB schema for time-series stock data - Docker Compose setup for all services - OpenAI integration for sentiment analysis
This commit is contained in:
13
backend/app/schemas/__init__.py
Normal file
13
backend/app/schemas/__init__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""Pydantic schemas."""
|
||||
|
||||
from app.schemas.stock import StockCreate, StockResponse, StockWithPrice
|
||||
from app.schemas.news import NewsCreate, NewsResponse, NewsWithSentiment
|
||||
from app.schemas.signal import SignalResponse, SignalWithDetails
|
||||
from app.schemas.watchlist import WatchlistCreate, WatchlistResponse, WatchlistUpdate
|
||||
|
||||
__all__ = [
|
||||
"StockCreate", "StockResponse", "StockWithPrice",
|
||||
"NewsCreate", "NewsResponse", "NewsWithSentiment",
|
||||
"SignalResponse", "SignalWithDetails",
|
||||
"WatchlistCreate", "WatchlistResponse", "WatchlistUpdate",
|
||||
]
|
||||
43
backend/app/schemas/news.py
Normal file
43
backend/app/schemas/news.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""News schemas."""
|
||||
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class NewsBase(BaseModel):
|
||||
"""Base news schema."""
|
||||
title: str
|
||||
url: str
|
||||
source: str
|
||||
published_at: datetime
|
||||
|
||||
|
||||
class NewsCreate(NewsBase):
|
||||
"""Schema for creating a news article."""
|
||||
content: Optional[str] = None
|
||||
summary: Optional[str] = None
|
||||
author: Optional[str] = None
|
||||
image_url: Optional[str] = None
|
||||
|
||||
|
||||
class NewsResponse(NewsBase):
|
||||
"""Schema for news response."""
|
||||
id: UUID
|
||||
summary: Optional[str] = None
|
||||
author: Optional[str] = None
|
||||
fetched_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class NewsWithSentiment(NewsResponse):
|
||||
"""News response with sentiment analysis."""
|
||||
content: Optional[str] = None
|
||||
image_url: Optional[str] = None
|
||||
sentiment_score: Optional[float] = None
|
||||
sentiment_label: Optional[str] = None
|
||||
sentiment_confidence: Optional[float] = None
|
||||
is_processed: bool = False
|
||||
39
backend/app/schemas/signal.py
Normal file
39
backend/app/schemas/signal.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Signal schemas."""
|
||||
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class SignalBase(BaseModel):
|
||||
"""Base signal schema."""
|
||||
stock_id: UUID
|
||||
signal_price: float
|
||||
confidence_score: float
|
||||
|
||||
|
||||
class SignalResponse(SignalBase):
|
||||
"""Schema for signal response."""
|
||||
id: UUID
|
||||
signal_time: datetime
|
||||
status: str
|
||||
current_drawdown_percent: Optional[float] = None
|
||||
current_sentiment_score: Optional[float] = None
|
||||
expected_recovery_percent: Optional[float] = None
|
||||
expected_recovery_days: Optional[int] = None
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class SignalWithDetails(SignalResponse):
|
||||
"""Signal response with full details."""
|
||||
panic_event_id: Optional[UUID] = None
|
||||
pattern_id: Optional[UUID] = None
|
||||
triggered_at: Optional[datetime] = None
|
||||
outcome_price: Optional[float] = None
|
||||
outcome_percent: Optional[float] = None
|
||||
outcome_days: Optional[int] = None
|
||||
updated_at: datetime
|
||||
41
backend/app/schemas/stock.py
Normal file
41
backend/app/schemas/stock.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Stock schemas."""
|
||||
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class StockBase(BaseModel):
|
||||
"""Base stock schema."""
|
||||
symbol: str = Field(..., min_length=1, max_length=20)
|
||||
name: str = Field(..., min_length=1, max_length=255)
|
||||
sector: Optional[str] = None
|
||||
industry: Optional[str] = None
|
||||
exchange: Optional[str] = None
|
||||
country: str = "USA"
|
||||
|
||||
|
||||
class StockCreate(StockBase):
|
||||
"""Schema for creating a stock."""
|
||||
pass
|
||||
|
||||
|
||||
class StockResponse(StockBase):
|
||||
"""Schema for stock response."""
|
||||
id: UUID
|
||||
market_cap: Optional[int] = None
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class StockWithPrice(StockResponse):
|
||||
"""Stock response with latest price data."""
|
||||
latest_price: Optional[float] = None
|
||||
price_change_24h: Optional[float] = None
|
||||
price_change_percent_24h: Optional[float] = None
|
||||
volume_24h: Optional[int] = None
|
||||
42
backend/app/schemas/watchlist.py
Normal file
42
backend/app/schemas/watchlist.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Watchlist schemas."""
|
||||
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class WatchlistBase(BaseModel):
|
||||
"""Base watchlist schema."""
|
||||
panic_alert_threshold: float = -50.0
|
||||
price_alert_low: Optional[float] = None
|
||||
price_alert_high: Optional[float] = None
|
||||
priority: int = Field(1, ge=1, le=3)
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
class WatchlistCreate(WatchlistBase):
|
||||
"""Schema for creating a watchlist item."""
|
||||
symbol: str
|
||||
|
||||
|
||||
class WatchlistUpdate(BaseModel):
|
||||
"""Schema for updating a watchlist item."""
|
||||
panic_alert_threshold: Optional[float] = None
|
||||
price_alert_low: Optional[float] = None
|
||||
price_alert_high: Optional[float] = None
|
||||
priority: Optional[int] = Field(None, ge=1, le=3)
|
||||
notes: Optional[str] = None
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
|
||||
class WatchlistResponse(WatchlistBase):
|
||||
"""Schema for watchlist response."""
|
||||
id: UUID
|
||||
stock_id: UUID
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user