The brief: a daily portfolio agent
Unlike Capstone #1 (one-off ticker analysis), this agent runs on a schedule. Every morning at 8 AM, it wakes up, reads your portfolio file, fetches overnight prices, curates the top 3 news stories, flags any unusual volume moves (using 2-sigma statistical tests), and emails you a markdown briefing.
This teaches you the core workflow of real-world agents: schedule → batch fetch → reason → notify. Financial advisors, content platforms, and security teams all use this exact pattern.
Arjun holds a diversified NSE portfolio: RELIANCE.NS (equity), HDFCBANK.NS (banking), TCS.NS (IT), IRFC.NS (bonds). Each morning, he wants a concise briefing: which tickers moved >2%, what's the top news driving each, and are there any red flags (e.g., IRFC.NS suddenly spiked on low volume = suspicious). He doesn't want to log into 5 broker apps; he just reads his email.
Architecture: four-agent pipeline
The portfolio briefing follows a modular multi-agent design:
DataFetcher: reads portfolio.yaml, fetches price snapshots from yfinance, computes overnight change %.
Analyst: runs LLM to pick top 3 news stories per ticker and flag anomalies (2-sigma volume test). Returns structured Pydantic models.
Writer: formats briefing as markdown with emoji, sections, and summary bullets.
Sender: emails markdown (SMTP), posts to Slack, or saves to file.
Portfolio file: YAML configuration
Store your portfolio in a simple YAML file. The DataFetcher reads it at runtime.
Pydantic models for structure
Define the briefing structure upfront. This ensures the LLM output is always valid and your email formatting works.
Step 1: DataFetcher — load and snapshot
The DataFetcher reads portfolio.yaml, fetches real price data for each ticker, and computes overnight changes. This is pure data plumbing — no LLM yet.
Step 2: Analyst — LLM-powered reasoning
Now pass the price data to an LLM. The Analyst agent has a system prompt that says: "Given these 5 tickers and their overnight changes, pick the 3 top news stories per ticker and flag any red flags."
Step 3: Writer — format markdown email
Take the structured briefing and format it as email-ready markdown. This is the step that transforms data into narrative.
Step 4: Sender — email, Slack, or file
Send the briefing via SMTP email, Slack webhook, or file. Then wrap it in a scheduler that runs daily at 8 AM.
Full pipeline: orchestration and scheduling
Tie all four agents together. Then use the `schedule` library to run it daily at 8 AM.
Production deployment: cron, GitHub Actions, or Modal
On your laptop, the `schedule` library works. In production, use one of three approaches:
Option 1: Cron (Linux/Mac): Add to your system crontab: `0 8 * * * cd /path && python portfolio_agent.py run-once`. Simple, always-on.
Option 2: GitHub Actions: Commit your code to GitHub. Create `.github/workflows/daily-briefing.yml` that runs your script on a schedule. Free tier allows ~2000 minutes/month.
Option 3: Modal (serverless): Deploy to Modal's serverless platform. Your function runs in the cloud, scheduled, with no VPS cost.
What to say on your resume
This project is production-grade work. Frame it correctly:
Weak: "Built a portfolio tracking bot"
Strong: "Engineered a scheduled batch-processing agent that orchestrates a 4-stage pipeline (data fetch → LLM analysis → markdown formatting → SMTP notification) to generate daily portfolio briefings for 5+ NSE tickers; detects anomalies using 2-sigma statistical tests; deployed on cron with monitoring"
How real-world agents scale
This portfolio briefing agent is a scaled-down version of what financial firms, SaaS platforms, and content services deploy daily. Every time Netflix sends you a "personalized recommendation email", every time SouthBank India flags a suspicious transaction for review, every time M-Pesa sends you a monthly statement—that's a multi-agent pipeline much like yours, running on a schedule, processing millions of records in batch. The core pattern is identical: fetch → reason → format → notify. You've built the real architecture.
Task: Modify the portfolio briefing to support a portfolio with 50+ tickers (typical for a fund). Add a "top 5 winners/losers" roll-up section. Ensure the email doesn't exceed 50 KB.
Think through:
1. How do you paginate the news section?
2. How do you compute portfolio-level metrics (Sharpe ratio, sector concentration)?
3. How do you optimize LLM calls if you have 50 tickers?
Hint: Use batch processing: fetch all prices in one call (DataFetcher), group tickers by sector, run Analyst once per sector (not per ticker), then Writer creates sections. For 50+ tickers, you'll want to batch the LLM calls and cache results so you're not calling the model 50 times.
Test your knowledge
You've built a production agent.
Now ship systems at scale.
Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Agentic Engineer →