Agentic Trading Challenge

Technical Interview — Backend / AI Engineering

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), and produces a structured Buy / Sell / Hold recommendation as JSON.

Key constraint: No AI frameworks (LangChain, LlamaIndex, etc.). You must implement function calling manually — parse tool calls from raw LLM output, execute them, and inject results back into the conversation.

High-level flow:

CLI args (symbol) → LLM ⇔ Tools → Final AnalysisReport (JSON)

What’s Provided vs. What You Implement

ComponentStatusFile
Data typesProvidedinternal/models/types.go
Mock tools (GetStockPrice, GetNews, AnalyzeSentiment)Providedinternal/tools/tools.go
LLM client (HTTP call)Providedinternal/llm/client.go
CLI entry pointProvidedcmd/analyzer/main.go
Test suite (22 tests)Provided*_test.go
Tool-call parsing (ParseToolCall)You Implementinternal/llm/client.go
Agent loop verificationYou Implementinternal/agent/agent.go
System prompt designYou Implementinternal/agent/agent.go

Project Structure

stock-analyzer/
├── 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

  1. Download and extract the starter code:
    tar xzf agentic-trading-challenge.tar.gz
    cd stock-analyzer
  2. Verify it compiles:
    make build
  3. Run the tests to see your starting point (14 pass, 8 fail):
    make test
  4. Set your API key:
    export DEEPSEEK_API_KEY="your-key-here"

    Get a key at platform.deepseek.com.

  5. Implement ParseToolCall in internal/llm/client.go and refine the agent loop.
  6. 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.

Mock Data Reference

Stock Prices

SymbolPriceChangeChange%Volume
AAPL178.72+2.35+1.33%52.3M
GOOGL141.80−0.95−0.67%23.1M
TSLA248.50+8.20+3.41%98.8M
Other100.00+0.50+0.50%10.0M

News Headlines

AAPL (3 articles)
  • Apple Reports Record Q4 Revenue (Reuters)
  • Apple Announces New AI Features (Bloomberg)
  • Analysts Raise Apple Price Target (CNBC)
GOOGL (2 articles)
  • Google Cloud Revenue Surges 28% (Reuters)
  • DOJ Antitrust Case Update (WSJ)

TSLA (2 articles)
  • Tesla Deliveries Beat Expectations (Bloomberg)
  • Tesla Expands Charging Network (Electrek)

Sentiment Analysis

Keyword-based: positive words (record, beat, surge, growth, strong, ...) vs negative words (decline, drop, fall, antitrust, lawsuit, ...). Tie → neutral.

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)

  1. make build — compiles without errors
  2. make test — all 22 tests pass
  3. ./bin/analyzer AAPL — produces valid JSON to stdout

Manual Review

  1. Agent makes ≥ 2 tool calls before producing a final answer (not hardcoded)
  2. recommendation is one of Buy, Sell, or Hold
  3. confidence is in [0.0, 1.0]
  4. reasoning is a non-empty string

Scoring Rubric

CriterionWeightDescription
Agent Loop30%LLM drives tool selection, multi-turn conversation, clean termination
Function Calling25%Robust parsing (raw JSON, code fences, surrounding text), correct dispatch
Code Quality20%Idiomatic Go, proper error handling, clear naming
Output15%Valid JSON, reasonable recommendation with supporting data
Edge Cases10%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 IDDescription
deepseek-chatDeepSeek-V3 — use this for the challenge
deepseek-reasonerDeepSeek-V3 with chain-of-thought reasoning

Bonus (Optional)