CoreSEQUENTIALinventory_2 swarm-ai v1.0.5-SNAPSHOTcode Example code swarm-ai-examples/stock-market-analysisopen_in_new

Stock Market Analysis

compare_arrows Grounded recommendation with live metrics vs. a hedge that can't fetch or compute anything.

Prompt (both sides)
Produce an institutional-quality investment analysis report for **AAPL** (Apple Inc).

Include: current price and 52-week range, key valuation ratios (P/E, P/S, EV/EBITDA, current ratio, gross margin), recent growth metrics, competitive position, and a clear **BUY / HOLD / SELL** recommendation with the price target and rationale.
Model
SwarmAI

Stock Market Analysis

SwarmAI workflow · SEQUENTIAL

0tokens
$0.00 · localcost
0tools
0.0s/ 50.2s
hub Swarm started
Raw LLM

Stock Market Analysis

Raw GPT-4o — no tools, no memory

0tokens
$0.00 · localcost
0.0s/ 8.3s
boltgpt-4o in 80 · out 0
Δ tokens (swarm − baseline)+146.724
Δ cost-$0.0000
Δ wall-time+41.8s
Asymmetry swarm succeeds · baseline cannot reach tools
insights What you're gaining

What you're looking at

Same prompt — institutional-quality AAPL investment analysis. Left: SwarmAI (7 agents, Finnhub + SEC XBRL tools, cited output). Right: raw LLM (one call, no tools, no memory).

On GPT-4o

Baseline

No call

Refuses to invent numbers

  • Output is a template: [Insert Current Price], [Insert P/E Ratio]
  • Honest — but unusable at an investment committee

Gain: an LLM that would otherwise stonewall becomes an analyst-grade tool with auditable output.

On GPT-5.4 mini

Baseline

BUY (fabricated)

Commits to a specific $235 12-month price target out of thin air

  • Zero tools called, zero filings consulted
  • Textbook confident hallucination

Gain: proof that citation discipline isn't optional — without it, the model fabricates plausible-looking specifics.

Why the two models disagree (HOLD vs BUY)

Identical numbers, different conclusion. Frontier models read facts differently — the framework's job is making both auditable, not picking the winner.

Metrics

Wall time
Swarm 4o46.6 s
Baseline 4o6.8 s
Swarm 5.4-mini45.5 s
Baseline 5.4-mini8.4 s
Tokens
Swarm 4o143,732
Baseline 4o762
Swarm 5.4-mini162,468
Baseline 5.4-mini1,055
Output
Swarm 4o3.3k chars, cited
Baseline 4oplaceholders
Swarm 5.4-mini7.8k chars, cited
Baseline 5.4-mini$235, no source

Switch the model chips above to replay either side.

codeWorkflow YAML
swarm:
  name: StockAnalysisWorkflow
  process: SEQUENTIAL

  agents:
    analyst:
      role: "Senior Financial Analyst"
      goal: "Analyze {{ticker}} using live financial data and market indicators"
      maxTurns: 3
      temperature: 0.2
      permissionMode: READ_ONLY
      compaction:
        preserveRecentTurns: 3
        thresholdTokens: 4000
      tools: [calculator, web-search]

    writer:
      role: "Investment Report Writer"
      goal: "Write an institutional-quality report with BUY/HOLD/SELL"
      temperature: 0.3
      permissionMode: WORKSPACE_WRITE

  tasks:
    analyze:
      description: "Analyze {{ticker}}: price, ratios, growth, competitive position"
      agent: analyst
      outputFormat: MARKDOWN
    report:
      description: "Write the investment report with BUY/HOLD/SELL and price target"
      agent: writer
      dependsOn: [analyze]
      outputFile: "output/stock_analysis_{{ticker}}.md"
      outputFormat: MARKDOWN

verified Reproducible — model version, temperature, seed, framework git SHA, and hashes of prompt + workflow are embedded in every trace. Re-run to diff against this recording.