Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing calendar_date handling #1

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 1 addition & 135 deletions src/data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,143 +7,9 @@ class Price(BaseModel):
high: float
low: float
volume: int
time: str
time: str = \"N/A\" # Fallback value for missing calendar_date


class PriceResponse(BaseModel):
ticker: str
prices: list[Price]


class FinancialMetrics(BaseModel):
ticker: str
report_period: str
period: str
currency: str
market_cap: float | None
enterprise_value: float | None
price_to_earnings_ratio: float | None
price_to_book_ratio: float | None
price_to_sales_ratio: float | None
enterprise_value_to_ebitda_ratio: float | None
enterprise_value_to_revenue_ratio: float | None
free_cash_flow_yield: float | None
peg_ratio: float | None
gross_margin: float | None
operating_margin: float | None
net_margin: float | None
return_on_equity: float | None
return_on_assets: float | None
return_on_invested_capital: float | None
asset_turnover: float | None
inventory_turnover: float | None
receivables_turnover: float | None
days_sales_outstanding: float | None
operating_cycle: float | None
working_capital_turnover: float | None
current_ratio: float | None
quick_ratio: float | None
cash_ratio: float | None
operating_cash_flow_ratio: float | None
debt_to_equity: float | None
debt_to_assets: float | None
interest_coverage: float | None
revenue_growth: float | None
earnings_growth: float | None
book_value_growth: float | None
earnings_per_share_growth: float | None
free_cash_flow_growth: float | None
operating_income_growth: float | None
ebitda_growth: float | None
payout_ratio: float | None
earnings_per_share: float | None
book_value_per_share: float | None
free_cash_flow_per_share: float | None


class FinancialMetricsResponse(BaseModel):
financial_metrics: list[FinancialMetrics]


class LineItem(BaseModel):
ticker: str
report_period: str
period: str
currency: str

# Allow additional fields dynamically
model_config = {"extra": "allow"}


class LineItemResponse(BaseModel):
search_results: list[LineItem]


class InsiderTrade(BaseModel):
ticker: str
issuer: str | None
name: str | None
title: str | None
is_board_director: bool | None
transaction_date: str | None
transaction_shares: float | None
transaction_price_per_share: float | None
transaction_value: float | None
shares_owned_before_transaction: float | None
shares_owned_after_transaction: float | None
security_title: str | None
filing_date: str


class InsiderTradeResponse(BaseModel):
insider_trades: list[InsiderTrade]


class CompanyNews(BaseModel):
ticker: str
title: str
author: str
source: str
date: str
url: str
sentiment: str | None = None


class CompanyNewsResponse(BaseModel):
news: list[CompanyNews]


class Position(BaseModel):
cash: float = 0.0
shares: int = 0
ticker: str


class Portfolio(BaseModel):
positions: dict[str, Position] # ticker -> Position mapping
total_cash: float = 0.0


class AnalystSignal(BaseModel):
signal: str | None = None
confidence: float | None = None
reasoning: dict | str | None = None
max_position_size: float | None = None # For risk management signals


class TickerAnalysis(BaseModel):
ticker: str
analyst_signals: dict[str, AnalystSignal] # agent_name -> signal mapping


class AgentStateData(BaseModel):
tickers: list[str]
portfolio: Portfolio
start_date: str
end_date: str
ticker_analyses: dict[str, TickerAnalysis] # ticker -> analysis mapping


class AgentStateMetadata(BaseModel):
show_reasoning: bool = False
model_config = {"extra": "allow"}