8. Cross-Company Comparison — Sector, Insight, Ranking

Open In Colab

Use DartLab’s analysis engines to classify companies by sector, assign 10-area insight grades, and check market rankings.

  • Sector classification (WICS 11 sectors)
  • Sector-specific benchmark parameters
  • Insight grades (7 areas, A–F)
  • Anomaly detection
  • Market ranking
  • Comprehensive comparison table

Timeseries generation and financial ratio comparison were covered in 3. Timeseries Analysis and 4. Financial Ratios, so this tutorial focuses on the analysis engines.


Setup

import dartlab

Sector Classification

DartLab automatically classifies companies using the WICS (WiseFn Industry Classification Standard) 11-sector system. Comparing companies within the same sector produces meaningful analysis — comparing the debt ratio of a semiconductor company with a bank is pointless.

from dartlab.engines.sector import classify

for code in ["005930", "000660", "035420", "051910"]:
    info = classify(code)
    print(f"{info.corpName}: {info.sector} > {info.industryGroup} (confidence: {info.confidence})")

Classification follows three steps:

  1. Override mapping — Manually assigned companies (e.g., 삼성전자 → Information Technology)
  2. Keyword matching — Extracting keywords from company name and business description
  3. KSIC code mapping — Based on the Korean Standard Industrial Classification code

11 Sectors

SectorExample Companies
EnergySK이노베이션, S-Oil
MaterialsLG화학, POSCO
Industrials현대건설, 두산
Consumer Discretionary현대차, 삼성물산
Consumer Staples농심, CJ제일제당
Health Care삼성바이오, 셀트리온
FinancialsKB금융, 삼성생명
Information Technology삼성전자, SK하이닉스
Communication ServicesNAVER, 카카오
Utilities한국전력, 한국가스
Real Estate신한알파리츠

Sector Benchmarks

Each sector has its own benchmark parameters. These are used when applying sector-appropriate discount rates, growth rates, and PER multiples in valuation models.

from dartlab.engines.sector import getParams

params = getParams("005930")
print(f"Sector: {params.sector}")
print(f"Discount rate: {params.discountRate}%")
print(f"Growth rate: {params.growthRate}%")
print(f"PER multiple: {params.perMultiple}x")

Insight Grades

Seven areas are graded A through F to quickly identify a company’s strengths and weaknesses. Over 30 financial metrics are automatically analyzed.

from dartlab.engines.insight import analyze

for code in ["005930", "000660", "035420"]:
    result = analyze(code)
    if result is None:
        continue
    grades = result.grades()
    grade_str = " / ".join(f"{k}:{v}" for k, v in grades.items())
    print(f"{result.company.corpName} [{result.profile}]: {grade_str}")

7 Grading Areas

AreaEvaluation CriteriaA-Grade Standard (example)
performanceRevenue/operating profit growthRevenue 20%+ growth, profit 30%+ growth
profitabilityOperating margin, ROEOperating margin 15%+, ROE 15%+
healthDebt ratio, current ratioDebt ratio below 50%, current ratio 200%+
cashflowOperating CF, FCFStable operating CF, positive FCF
governanceLargest shareholder stake, audit opinionStable governance, unqualified audit opinion
riskAnomalies, contingent liabilities, related party transactionsNo anomalies, minor contingent liabilities
opportunityGrowth potentialStrong combination of growth and profitability

Grades range from A (excellent) to F (severe issues) in 6 levels.

Profile

Summarizes the company’s overall character in a single word.

result = analyze("005930")
print(result.profile)   # "안정형", "성장형", "위험형" etc.

Anomaly Detection

Automatically detects statistical anomalies (Z-score based) in financial metrics.

result = analyze("005930")
for anomaly in result.anomalies:
    print(f"  {anomaly.metric}: Z-score {anomaly.zscore:.1f} ({anomaly.direction})")

For example, a sudden drop in inventory turnover or an abnormally extended accounts receivable collection period would be detected as anomalies. These can be warning signs of accounting fraud, inventory buildup, or bad debts.


Market Ranking

Check where a company stands among all listed companies. Both overall market ranking and within-sector ranking are provided for revenue and assets.

from dartlab.engines.rank import getRankOrBuild

for code in ["005930", "000660", "035420"]:
    rank = getRankOrBuild(code)
    if rank is None:
        continue
    print(f"
{rank.corpName} ({rank.sector})")
    print(f"  Revenue rank: {rank.revenueRank}/{rank.revenueTotal} (in sector: {rank.revenueRankInSector}/{rank.revenueSectorTotal})")
    print(f"  Asset rank: {rank.assetRank}/{rank.assetTotal}")
    print(f"  Size class: {rank.sizeClass}")

sizeClass categorizes company size as large, mid, or small. Using this to compare companies of “same sector, similar size” produces the most meaningful results.


Comprehensive Comparison Example

A pattern for consolidating multiple metrics into a single table.

import polars as pl
import dartlab
from dartlab.engines.dart.finance import getTTM, getLatest
from dartlab.engines.sector import classify

codes = ["005930", "000660", "035420", "051910", "006400"]
rows = []

for code in codes:
    c = dartlab.Company(code)
    r = c.ratios
    sector = classify(code)
    if r is None:
        continue
    rows.append({
        "기업": c.corpName,
        "섹터": sector.sector if sector else "",
        "매출(억)": round(r.revenueTTM / 1e8) if r.revenueTTM else None,
        "영업이익률(%)": round(r.operatingMargin, 1) if r.operatingMargin else None,
        "ROE(%)": round(r.roe, 1) if r.roe else None,
        "부채비율(%)": round(r.debtRatio, 1) if r.debtRatio else None,
        "FCF(억)": round(r.fcf / 1e8) if r.fcf else None,
    })

df = pl.DataFrame(rows)
print(df)

Next Steps