Downloads
Download the starter code and challenge specification.
Overview
Build an agentic stock analysis workflow in Go. Your program accepts a stock ticker symbol, uses the DeepSeek Chat LLM to autonomously call tools (get price, fetch news, analyze sentiment, retrieve historical prices, financial metrics, insider trades, and analyst ratings), and produces a structured Buy / Sell / Hold recommendation as JSON.
High-level flow:
CLI args (symbol) → LLM ⇔ Tools → Final AnalysisReport (JSON)
What’s Provided vs. What You Implement
| Component | Status | File |
|---|---|---|
| Data types | Provided | internal/models/types.go |
| Mock tools (7 functions) | You Implement | internal/tools/tools.go |
| LLM client (HTTP call) | Provided | internal/llm/client.go |
| CLI entry point | Provided | cmd/analyzer/main.go |
| Test suite (40 tests) | Provided | *_test.go |
Tool dispatch (executeTool) | You Implement | internal/agent/agent.go |
Tool-call parsing (ParseToolCall) | You Implement | internal/llm/client.go |
| Agent loop verification | You Implement | internal/agent/agent.go |
| System prompt design | You Implement | internal/agent/agent.go |
Project Structure
├── Makefile
├── go.mod
├── cmd/analyzer/main.go
├── internal/
│ ├── agent/agent.go, agent_test.go
│ ├── llm/client.go, client_test.go
│ ├── models/types.go
│ └── tools/tools.go, tools_test.go
├── configs/config.example.yaml
├── testdata/sample_response.json
└── docs/challenge.tex, challenge.pdf
Getting Started
-
Download and extract the starter code:
tar xzf agentic-trading-challenge.tar.gz cd stock-analyzer -
Verify it compiles:
make build -
Run the tests to see your starting point (7 pass, 33 fail):
make test -
Set your API key:
export DEEPSEEK_API_KEY="your-key-here"Get a key at platform.deepseek.com.
-
Implement the 7 mock tool functions in
tools.go,executeToolinagent.go, andParseToolCallinclient.go. -
Run:
./bin/analyzer AAPL
Available Tools
The mock tools return deterministic data so you can focus on the agent logic.
GetStockPrice(symbol)
{
"name": "GetStockPrice",
"arguments": { "symbol": "AAPL" }
}
Returns: symbol, price, change, change_pct, volume, high, low.
GetNews(symbol)
{
"name": "GetNews",
"arguments": { "symbol": "AAPL" }
}
Returns: array of news items with title, source, summary.
AnalyzeSentiment(text)
{
"name": "AnalyzeSentiment",
"arguments": { "text": "Apple Reports Record Q4 Revenue..." }
}
Returns: sentiment (positive/negative/neutral), confidence.
GetHistoricalPrices(symbol)
{
"name": "GetHistoricalPrices",
"arguments": { "symbol": "AAPL" }
}
Returns: array of 5 entries with date, open, high, low, close, volume (oldest first).
GetFinancials(symbol)
{
"name": "GetFinancials",
"arguments": { "symbol": "AAPL" }
}
Returns: symbol, revenue, net_income, eps, pe_ratio, market_cap, dividend_yield.
GetInsiderTrading(symbol)
{
"name": "GetInsiderTrading",
"arguments": { "symbol": "AAPL" }
}
Returns: array of insider trades with name, title, trade_type, shares, price, date.
GetAnalystRatings(symbol)
{
"name": "GetAnalystRatings",
"arguments": { "symbol": "AAPL" }
}
Returns: array of analyst ratings with firm, rating, price_target, date.
Mock Data Reference
Stock Prices
| Symbol | Price | Change | Change% | Volume |
|---|---|---|---|---|
| AAPL | 178.72 | +2.35 | +1.33% | 52.3M |
| GOOGL | 141.80 | −0.95 | −0.67% | 23.1M |
| TSLA | 248.50 | +8.20 | +3.41% | 98.8M |
| NVDA | 875.30 | −12.40 | −1.40% | 45.2M |
| META | 505.75 | +15.30 | +3.12% | 32.8M |
| AMZN | 178.25 | +0.75 | +0.42% | 28.5M |
| Other | 100.00 | +0.50 | +0.50% | 10.0M |
News Headlines
- Apple Reports Record Q4 Revenue (Reuters)
- Apple Announces New AI Features (Bloomberg)
- Analysts Raise Apple Price Target (CNBC)
- Google Cloud Revenue Surges 28% (Reuters)
- DOJ Antitrust Case Update (WSJ)
TSLA (2 articles)
- Tesla Deliveries Beat Expectations (Bloomberg)
- Tesla Expands Charging Network (Electrek)
NVDA (3 articles)
- NVIDIA AI Chip Demand Plateaus (Reuters)
- NVIDIA CEO Sells $50M in Stock (Bloomberg)
- NVIDIA Valuation Concerns Rise (WSJ)
META (2 articles)
- Meta Reality Labs Shows Turnaround (Bloomberg)
- Meta Ad Revenue Grows 25% (Reuters)
AMZN (2 articles)
- AWS Growth Slows to 12% (CNBC)
- Amazon Expands Same-Day Delivery (Reuters)
Sentiment Analysis
Keyword-based: positive words (record, beat, surge, growth, strong, ...) vs negative words (decline, drop, fall, antitrust, lawsuit, ...). Tie → neutral.
Historical Prices
Returns 5 most recent trading days (oldest first). Last entry's close matches current price. AAPL shows upward trend; NVDA shows downward trend.
Financials
| Symbol | Revenue (B) | EPS | P/E | Market Cap (B) |
|---|---|---|---|---|
| AAPL | 383.28 | 6.42 | 27.8 | 2,800 |
| GOOGL | 307.39 | 5.80 | 24.4 | 1,780 |
| TSLA | 96.77 | 4.73 | 52.5 | 790 |
| NVDA | 60.92 | 12.06 | 72.6 | 2,150 |
| META | 134.90 | 15.02 | 33.7 | 1,300 |
| AMZN | 574.78 | 2.90 | 61.5 | 1,870 |
Insider Trading
AAPL: 2 Buy trades (bullish). NVDA: 2 Sell trades (bearish). Unknown symbols: empty.
Analyst Ratings
AAPL: 3 ratings (2 Buy, 1 Hold). NVDA: 3 ratings (1 Sell, 1 Hold, 1 Buy). META: 2 Buy. Unknown: empty.
Expected Output
{
"symbol": "AAPL",
"recommendation": "Buy",
"confidence": 0.85,
"reasoning": "Strong Q4 earnings, positive analyst sentiment, and upward price momentum.",
"price": { "symbol": "AAPL", "price": 178.72, ... },
"news": [ ... ],
"sentiment": { "sentiment": "positive", "confidence": 0.85 }
}
Acceptance Criteria
Automated (must all pass)
make build— compiles without errorsmake test— all 40 tests pass./bin/analyzer AAPL— produces valid JSON to stdout
Manual Review
- Agent makes ≥ 2 tool calls before producing a final answer (not hardcoded)
recommendationis one ofBuy,Sell, orHoldconfidenceis in [0.0, 1.0]reasoningis a non-empty string
Scoring Rubric
| Criterion | Weight | Description |
|---|---|---|
| Agent Loop | 30% | LLM drives tool selection, multi-turn conversation, clean termination |
| Function Calling | 25% | Robust parsing (raw JSON, code fences, surrounding text), correct dispatch |
| Code Quality | 20% | Idiomatic Go, proper error handling, clear naming |
| Output | 15% | Valid JSON, reasonable recommendation with supporting data |
| Edge Cases | 10% | Unknown symbols, malformed responses, API errors |
DeepSeek API Reference
Full docs: api-docs.deepseek.com · Chat completions: create-chat-completion
POST https://api.deepseek.com/chat/completions
Content-Type: application/json
Authorization: Bearer <DEEPSEEK_API_KEY>
| Model ID | Description |
|---|---|
deepseek-chat | DeepSeek-V3 — use this for the challenge |
deepseek-reasoner | DeepSeek-V3 with chain-of-thought reasoning |
Bonus (Optional)
- Streaming — SSE streaming with real-time partial output
- Retries with backoff — exponential backoff for 429/500/503
- Multi-turn memory — remember previous analyses across runs
- Concurrent tool calls — use goroutines to execute independent tools in parallel
- Additional tests — extend the suite with your own edge-case tests