Market Peer Comparison - Story Telling by Claude Code
In the world of financial analysis, averages can be misleading. A simple “industry average” often hides the true story of winners, losers, and the hidden gems in between. This is where the Market - Peer Comparison Dashboard from AI Thinking steps in, transforming dry spreadsheets into a dynamic visual landscape of market health.
Browsing the dashboard reveals a sophisticated approach to industry analysis that goes far beyond standard metrics. Here are the key insights and facts that make this tool a game-changer for understanding market structure:
1. The Power of Distribution Over Averages
The most striking feature of the dashboard is its move away from single data points. By utilizing Ratio Distributions and Quartile Heatmaps, the tool provides a “Investor’s eye view” of an entire industry.
- Fact: The dashboard visualizes performance using Box Plots and Histograms.
- Insight: This allows you to see the shape of the market. Is the industry highly competitive with clustered ratios, or is it fragmented with massive disparities between the leaders and laggards?
2. Granular Peer Comparison
Context is everything. A Price-to-Earnings (P/E) ratio of 20 might be expensive for a bank but a bargain for a tech startup.
- Fact: The dashboard filters data by Industry, ensuring that every comparison is relevant and grounded in sector-specific realities.
- Fact: It allows for individual Company Selection within these quartiles.
- Insight: You can instantly spot where a specific company sits relative to its peers—whether it’s an outlier punching above its weight or a laggard stuck in the specific quartile.
3. Visualizing Financial Health
The dashboard transforms complex financial ratios into intuitive visual patterns. instead of scanning rows of numbers, you can scan a Heatmap.
- Insight: Heatmaps allow for rapid identification of strengths and weaknesses across multiple metrics simultaneously. First quartile vs. Fourth quartile tells a company’s financial story in seconds.
The data used in this dashboard is quarterly data from Apr-Jun, 2025.
Using Claude Code Agent Framework
We used Claude Code, which is a command line tool allowing to delegate complex coding tasks to Claude. Claude Code acted as an intelligent coding partner that understood the requirements and created this project end to end.
Let’s dive deeper into how these three agents are created.
1. Explorer Agent
Transform messy, real-world CSV files into pristine, analysis-ready datasets.
Think of this agent as your data detective. It receives a CSV file that might have missing values, weird outliers (one company showed 92,000% growth—clearly a data error), and inconsistent formatting. Its job is to make sense of the chaos.
Explorer Agent instructions in markdown:
---
name: data-explorer
description: Loads and explores datasets. Assesses data quality, creates clean subsets, calculates derived metrics, and prepares analysis plans.
---
## Role
Transform raw CSV data into analysis-ready datasets with comprehensive documentation.
## Input
- CSV files from `./data/` (columns: Name, Market Capitalization, Sales, Profit, etc.)
- Analysis question or insight goal
## Output Location
./out/insights/[insight-name]/plan/
Create the following set of files.
- ./out/insights/[insight-name]/plan/data/ - Clean CSV files
- ./out/insights/[insight-name]/plan/analysis-plan.md - Details of the data files create along with their metadata.
## Workflow
1. Load & Inspect - Parse CSV, examine structure, identify issues
2. Clean & Transform - Handle missing values, calculate derived metrics, if required
3. Create Subsets - Generate focused datasets for the required visualizations
4. Document - Write analysis-plan.md, data-dictionary.md, exploration-notes.md
5. Verify - Check data sufficiency and completeness
2. The Visualization Agent
Transform clean data into interactive, publication-ready visualizations.
This agent is your graphics department. It receives the cleaned datasets and analysis plan from the Data Explorer and thinks: “How do I show market dominance? A treemap where bigger rectangles = bigger companies. How do I show profitability patterns? Color code by profit margin—green for profitable, red for losses.”
The genius of separation: Each chart lives in its own folder with chart.js (the D3 code), styles.css (all the visual styling), and example.html (a working demo). Why separate? So you can embed these charts in reports, websites, or presentations without modification. Just copy the folder.
Visualzation Agent instructions in markdown:
---
name: chart-builder
description: You are the Create Charts agent, a D3.js visualization specialist. You transform prepared datasets into beautiful, interactive charts with proper code organization and comprehensive documentation..
---
## Role
Transform prepared datasets into production-ready, interactive D3.js visualizations.
## Input
- ./out/insights/[insight-name]/plan/data/ - Clean CSV files
- ./out/insights/[insight-name]/plan/analysis-plan.md - Medata and guidance of the data files.
## Output Location
./out/insights/[insight-name]/charts/
## Workflow
- Read `analysis-plan.md` to understand the insight question
- Review recommended visualizations
- Check the data dictionary for field details
- Choose appropriate chart types (bar, line, scatter, heatmap, etc.)
- Design for clarity and insight delivery
- Plan interactions (hover, click, zoom, filter)
- Consider responsive design
- For multiple related views, plan navigation (dropdown, tabs, menu)
## File Structure for charts creation
[chart-name]/
├── chart.js # D3 visualization logic
├── styles.css # Chart-specific styling
├── example.html # Standalone demo
├── embedding-guide.md # Integration docs
└── data/ # Copy of required CSV
## Dashboard Requirements
- dashboard.html - Multi-chart container with tabs
- dashboard.js - View switching, industry selector, stats calculation
- dashboard.css - Layout and theme
- industries-config.json - Multi-industry configuration
- README.md - Overview and quick start
Claude Code Command: Bringing Agents Together
Here’s where it all comes together. Both the agents—Data Explorer, Chart Builder - orchestrate through a single claude command agent called market-ratios command.
---
description: Analyze and compare performance of companies in specific industry using financial ratios.
---
## Context
Build an interactive dashboard to analyze company performance within selected industries.
Industry metadata, data file paths, and the list of financial ratios are provided in industry-config.json. The dashboard must dynamically load industries, companies, and ratio definitions from this config file rather than hard-coding them.
Ensure the dashboard is fully configurable so updates to industry-config.json automatically reflect in the industry list, associated data files, company names, and ratio selections.
Consider only companies with market cap higher than 10000.
## Your task
Build an interactive dashboard with the following functionalities:
1. **Industry Selector**
Users choose an industry from a dropdown.
2. **Two-Tab Interfaces**
**Tab 1 - Ratio Distribution**
* Select a ratio from a dropdown
* Display its distribution across companies in the chosen industry (boxplot or histogram)
* the choice between box plot and histogram should be selected from a radio button
* Clearly highlight outliers
**Tab 2 - Quartile Heatmap**
* Show all ratios as rows and quartile ranges as four columns
* Values in each cell represent the range for that quartile
* If a company is selected from a dropdown in the tab, highlight the quartile position of that company for each ratio.
3. Additionally, implement
* Ratio Definitions & Examples
Provide links or popovers for each financial ratio that show a short explanation, formula (in markdown), and one simple numerical example.
These elements should appear context-appropriately on relevant tabs and update dynamically as the user selects industries, ratios, or companies.
Now the command agent can be run as below:
/market-ratios
Disclaimer: This blog and dashboard are intended solely for educational purposes. They do not provide investment advice or recommend any stocks for purchase or sale. While every effort is made to source data from reliable and publicly available platforms, certain datasets, charts, or insights may contain inaccuracies, or discrepancies. If you find any issues or need any clarification, please write to the Author