Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

audit: fix stock_portfolio_analyst - add env comment, rewrite em dashes, add docstring

Tiioluwani6a34a409d61a
diff --git a/ai_agents/stock_portfolio_analyst/.env.example b/ai_agents/stock_portfolio_analyst/.env.example
index 78b5611..44ae38f 100644
--- a/ai_agents/stock_portfolio_analyst/.env.example
+++ b/ai_agents/stock_portfolio_analyst/.env.example
@@ -1 +1,3 @@
+# NVIDIA API key (required)
+# Get your free key at https://build.nvidia.com
NVIDIA_API_KEY=your_nvidia_api_key_here
diff --git a/ai_agents/stock_portfolio_analyst/README.md b/ai_agents/stock_portfolio_analyst/README.md
index 5f0c542..83aeef6 100644
--- a/ai_agents/stock_portfolio_analyst/README.md
+++ b/ai_agents/stock_portfolio_analyst/README.md
@@ -1,12 +1,12 @@
# πŸ“ˆ Stock Portfolio Analyst
-> **Powered by [DeepSeek-V4-Flash](https://build.nvidia.com/deepseek-ai/deepseek-v4-flash) via NVIDIA API β€” fast, cost-efficient reasoning for real-time financial analysis**
+> **Powered by [DeepSeek-V4-Flash](https://build.nvidia.com/deepseek-ai/deepseek-v4-flash) via NVIDIA API for fast, cost-efficient reasoning and real-time financial analysis**
![Stock Portfolio Analyst Demo](assets/demo.png)
## Overview
-An AI-powered portfolio analysis agent that evaluates stock holdings using live market data. Enter your tickers, share counts, and average purchase prices, and the agent fetches real-time pricing and fundamentals via YFinance, searches for recent news via DuckDuckGo, and generates a comprehensive portfolio review β€” streamed live in the UI as it builds.
+An AI-powered portfolio analysis agent that evaluates stock holdings using live market data. Enter your tickers, share counts, and average purchase prices, and the agent fetches real-time pricing and fundamentals via YFinance, searches for recent news via DuckDuckGo, and generates a comprehensive portfolio review, streamed live in the UI as it builds.
The report covers P&L per position, portfolio-level metrics, concentration and valuation risk flags, sector breakdown, and specific rebalancing recommendations.
@@ -30,7 +30,7 @@ The report covers P&L per position, portfolio-level metrics, concentration and v
- [CalculatorTools](https://docs.agno.com/): Precise P&L and concentration calculations
**Model:**
-- **[DeepSeek-V4-Flash](https://build.nvidia.com/deepseek-ai/deepseek-v4-flash)** (`deepseek-ai/deepseek-v4-flash`) β€” fast and cost-efficient reasoning via the NVIDIA API
+- **[DeepSeek-V4-Flash](https://build.nvidia.com/deepseek-ai/deepseek-v4-flash)** (`deepseek-ai/deepseek-v4-flash`): fast and cost-efficient reasoning via the NVIDIA API
**UI:**
- [Gradio](https://www.gradio.app/): Interactive web interface with streaming markdown output
diff --git a/ai_agents/stock_portfolio_analyst/app.py b/ai_agents/stock_portfolio_analyst/app.py
index 7472a16..16b9238 100644
--- a/ai_agents/stock_portfolio_analyst/app.py
+++ b/ai_agents/stock_portfolio_analyst/app.py
@@ -66,6 +66,7 @@ def analyze(portfolio_df, question):
def reset():
+ """Restore the portfolio table to the default example and clear the question and output."""
return (
pd.DataFrame(DEFAULT_PORTFOLIO, columns=["Ticker (e.g. AAPL)", "Shares Owned", "Avg Purchase Price ($)"]),
"",