BaoKhuong's picture
Upload 5 files
5dd7bcd verified
from typing import List, Dict, Any
def _format_section(section: Dict[str, Any]) -> str:
source = section.get("source", "Unknown")
data = section.get("data")
return f"[Source: {source}]\n{str(data)[:4000]}"
def build_price_prediction_prompt(ticker: str, horizon_days: int, notes: str, context_sections: List[Dict[str, Any]]) -> str:
sections = "\n\n".join(_format_section(s) for s in context_sections)
instructions = f"You are a financial analyst AI. Predict the {ticker} stock price movement over the next {horizon_days} days (Up, Down, or Sideways), include a concise rationale using the provided data. Provide a single-sentence headline prediction followed by a short bullet list of reasons."
if notes:
instructions += f"\nAnalyst notes: {notes}"
return f"""
<TASK>
Price prediction for {ticker} over next {horizon_days} days.
</TASK>
<CONTEXT>
{sections}
</CONTEXT>
<INSTRUCTIONS>
{instructions}
</INSTRUCTIONS>
""".strip()
def build_equity_report_prompt(ticker: str, fiscal_year: str, extra_instructions: str, context_sections: List[Dict[str, Any]]) -> str:
sections = "\n\n".join(_format_section(s) for s in context_sections)
instructions = (
f"Write an equity research report for {ticker} covering FY {fiscal_year}. "
"Include: company overview, business segments, recent news impacts, key financial metrics, valuation view, and risks."
)
if extra_instructions:
instructions += f"\nAdditional guidance: {extra_instructions}"
return f"""
<TASK>
Equity research report for {ticker} FY {fiscal_year}.
</TASK>
<CONTEXT>
{sections}
</CONTEXT>
<INSTRUCTIONS>
{instructions}
</INSTRUCTIONS>
""".strip()