business_segment_tools.pyβ’36.8 kB
"""
Business segment analysis tools for comprehensive segment performance analysis
TDD Green Phase: Implement minimum code to pass tests
"""
import logging
import asyncio
import statistics
import math
from typing import Dict, Any, List, Optional, Union
from datetime import datetime, date, timedelta
from ..collectors.dart_collector import DARTCollector
from ..exceptions import MCPStockDetailsError, InsufficientDataError
from ..config import get_settings
from ..utils.financial_calculator import FinancialCalculator
class BusinessSegmentAnalyzer:
"""Advanced business segment analysis with comprehensive performance metrics"""
def __init__(self):
"""Initialize business segment analyzer"""
self.settings = get_settings()
self.logger = logging.getLogger("mcp_stock_details.business_segment_analyzer")
self.dart_collector = None
self.financial_calculator = FinancialCalculator()
async def _get_dart_collector(self) -> DARTCollector:
"""Get or create DART collector instance"""
if self.dart_collector is None:
api_key = self.settings.dart_api_key or "test_api_key"
self.dart_collector = DARTCollector(api_key=api_key)
return self.dart_collector
async def analyze_segment_performance(
self,
segment_data: Dict[str, Any],
analysis_years: int = 3
) -> Dict[str, Any]:
"""Analyze performance of business segments"""
if analysis_years <= 0:
raise MCPStockDetailsError("Analysis years must be positive")
if not segment_data.get("segments"):
raise InsufficientDataError("No segment data available for analysis")
segments = segment_data["segments"]
segment_performance = []
for segment in segments:
name = segment.get("name", "Unknown")
# Get revenue data for available years
revenues = []
profits = []
for year in range(2021, 2024): # 2021-2023
revenue_key = f"revenue_{year}"
profit_key = f"operating_profit_{year}"
if revenue_key in segment:
revenues.append(segment[revenue_key])
if profit_key in segment:
profits.append(segment[profit_key])
# Calculate growth rates
if len(revenues) >= 2:
# CAGR calculation
start_revenue = revenues[-1] # Oldest
end_revenue = revenues[0] # Most recent
years = len(revenues) - 1
if start_revenue > 0:
revenue_growth_rate = ((end_revenue / start_revenue) ** (1/years) - 1) * 100
else:
revenue_growth_rate = 0
else:
revenue_growth_rate = 0
# Calculate operating margin
latest_revenue = revenues[0] if revenues else 1
latest_profit = profits[0] if profits else 0
operating_margin = (latest_profit / latest_revenue) * 100 if latest_revenue > 0 else 0
# Calculate profit growth rate
if len(profits) >= 2:
start_profit = profits[-1]
end_profit = profits[0]
years = len(profits) - 1
if start_profit > 0:
profit_growth_rate = ((end_profit / start_profit) ** (1/years) - 1) * 100
else:
profit_growth_rate = 0 if end_profit > 0 else -100
else:
profit_growth_rate = 0
# Performance score (0-100)
margin_score = min(100, max(0, operating_margin * 2)) # Scale margin to 0-100
growth_score = min(100, max(0, revenue_growth_rate + 50)) # Normalize growth
performance_score = (margin_score * 0.6 + growth_score * 0.4)
segment_performance.append({
"name": name,
"revenue_growth_rate": round(revenue_growth_rate, 2),
"operating_margin": round(operating_margin, 2),
"profit_growth_rate": round(profit_growth_rate, 2),
"performance_score": round(performance_score, 1),
"latest_revenue": latest_revenue,
"latest_profit": latest_profit
})
# Performance ranking
performance_ranking = sorted(segment_performance, key=lambda x: x["performance_score"], reverse=True)
# Key insights
best_performer = performance_ranking[0] if performance_ranking else None
worst_performer = performance_ranking[-1] if performance_ranking else None
key_insights = []
if best_performer:
key_insights.append(f"Best performing segment: {best_performer['name']} (Score: {best_performer['performance_score']:.1f})")
if worst_performer and len(performance_ranking) > 1:
key_insights.append(f"Underperforming segment: {worst_performer['name']} (Score: {worst_performer['performance_score']:.1f})")
return {
"segment_performance": segment_performance,
"performance_ranking": performance_ranking,
"key_insights": key_insights,
"analysis_period": f"{analysis_years} years",
"total_segments": len(segments)
}
async def calculate_segment_growth_rates(
self,
segment_data: Dict[str, Any],
growth_period: str = "3Y"
) -> Dict[str, Any]:
"""Calculate growth rates for business segments"""
valid_periods = ["1Y", "3Y", "5Y"]
if growth_period not in valid_periods:
raise MCPStockDetailsError(f"Invalid growth period. Must be one of {valid_periods}")
segments = segment_data.get("segments", [])
segment_growth = []
growth_rates = []
for segment in segments:
name = segment.get("name", "Unknown")
# Get revenue data
revenues = []
for year in range(2021, 2024):
revenue_key = f"revenue_{year}"
if revenue_key in segment:
revenues.append(segment[revenue_key])
if len(revenues) >= 2:
# Calculate CAGR
start_revenue = revenues[-1]
end_revenue = revenues[0]
years = len(revenues) - 1
if start_revenue > 0:
cagr = ((end_revenue / start_revenue) ** (1/years) - 1) * 100
else:
cagr = 0
# Calculate revenue volatility
if len(revenues) > 1:
growth_year_over_year = []
for i in range(1, len(revenues)):
if revenues[i] > 0:
yoy_growth = (revenues[i-1] / revenues[i] - 1) * 100
growth_year_over_year.append(yoy_growth)
revenue_volatility = statistics.stdev(growth_year_over_year) if len(growth_year_over_year) > 1 else 0
else:
revenue_volatility = 0
growth_rates.append(cagr)
else:
cagr = 0
revenue_volatility = 0
segment_growth.append({
"name": name,
"cagr": round(cagr, 2),
"revenue_volatility": round(revenue_volatility, 2),
"growth_trend": "positive" if cagr > 0 else "negative" if cagr < 0 else "flat"
})
# Calculate overall metrics
average_growth_rate = statistics.mean(growth_rates) if growth_rates else 0
growth_stability = 100 - (statistics.stdev(growth_rates) if len(growth_rates) > 1 else 0)
# Find fastest growing segment
fastest_growing = max(segment_growth, key=lambda x: x["cagr"]) if segment_growth else None
return {
"segment_growth": segment_growth,
"average_growth_rate": round(average_growth_rate, 2),
"growth_stability": round(max(0, min(100, growth_stability)), 1),
"fastest_growing_segment": fastest_growing,
"period": growth_period,
"segments_analyzed": len(segment_growth)
}
async def analyze_segment_profitability(
self,
segment_data: Dict[str, Any],
benchmark_margins: Dict[str, float] = None
) -> Dict[str, Any]:
"""Analyze profitability of business segments"""
if benchmark_margins is None:
benchmark_margins = {}
segments = segment_data.get("segments", [])
segment_margins = []
margins = []
for segment in segments:
name = segment.get("name", "Unknown")
# Get latest financial data
latest_revenue = segment.get("revenue_2023", 0)
latest_profit = segment.get("operating_profit_2023", 0)
assets = segment.get("assets", 1)
# Calculate margins
operating_margin = (latest_profit / latest_revenue) * 100 if latest_revenue > 0 else 0
roa = (latest_profit / assets) * 100 if assets > 0 else 0
# Benchmark comparison
benchmark_margin = benchmark_margins.get(name, operating_margin)
margin_vs_benchmark = operating_margin - benchmark_margin
margins.append(operating_margin)
segment_margins.append({
"name": name,
"operating_margin": round(operating_margin, 2),
"roa": round(roa, 2),
"benchmark_margin": round(benchmark_margin, 2),
"margin_vs_benchmark": round(margin_vs_benchmark, 2),
"profitability_rank": 0 # Will be updated later
})
# Rank by profitability
segment_margins.sort(key=lambda x: x["operating_margin"], reverse=True)
for i, segment in enumerate(segment_margins):
segment["profitability_rank"] = i + 1
# Analyze margin trends (simplified - would need historical data)
margin_trends = {
"average_margin": round(statistics.mean(margins) if margins else 0, 2),
"margin_spread": round(max(margins) - min(margins) if margins else 0, 2),
"consistency": "high" if len(margins) > 1 and statistics.stdev(margins) < 5 else "moderate"
}
# Benchmark comparison summary
benchmark_comparison = {
"segments_above_benchmark": sum(1 for s in segment_margins if s["margin_vs_benchmark"] > 0),
"segments_below_benchmark": sum(1 for s in segment_margins if s["margin_vs_benchmark"] < 0),
"average_benchmark_gap": round(statistics.mean([s["margin_vs_benchmark"] for s in segment_margins]), 2)
}
return {
"segment_margins": segment_margins,
"profitability_ranking": segment_margins, # Already sorted
"margin_trends": margin_trends,
"benchmark_comparison": benchmark_comparison
}
async def calculate_segment_concentration(
self,
segment_data: Dict[str, Any],
concentration_metric: str = "revenue"
) -> Dict[str, Any]:
"""Calculate segment concentration using HHI and other metrics"""
segments = segment_data.get("segments", [])
if not segments:
raise InsufficientDataError("No segment data available for concentration analysis")
# Extract metric values
if concentration_metric == "revenue":
values = [segment.get("revenue_2023", 0) for segment in segments]
elif concentration_metric == "profit":
values = [segment.get("operating_profit_2023", 0) for segment in segments]
else:
values = [segment.get("revenue_2023", 0) for segment in segments] # Default to revenue
# Calculate total and percentages
total_value = sum(values)
if total_value == 0:
raise InsufficientDataError("No valid segment data for concentration calculation")
percentages = [(value / total_value) * 100 for value in values]
# Calculate HHI
hhi = sum(p ** 2 for p in percentages)
# Calculate concentration ratios
sorted_percentages = sorted(percentages, reverse=True)
top_segment_share = sorted_percentages[0] if sorted_percentages else 0
top_3_concentration = sum(sorted_percentages[:3])
# Determine concentration level
if hhi > 2500:
concentration_level = "very_high"
elif hhi > 1500:
concentration_level = "high"
elif hhi > 1000:
concentration_level = "moderate"
else:
concentration_level = "low"
# Calculate diversification score (inverse of concentration)
diversification_score = max(0, 100 - (hhi / 100))
return {
"hhi_index": round(hhi, 2),
"top_segment_share": round(top_segment_share, 2),
"top_3_concentration": round(top_3_concentration, 2),
"concentration_level": concentration_level,
"diversification_score": round(diversification_score, 1),
"metric_analyzed": concentration_metric
}
async def analyze_geographic_segments(
self,
geographic_data: Dict[str, Any],
risk_assessment: bool = True
) -> Dict[str, Any]:
"""Analyze geographic segment performance and risks"""
geographic_segments = geographic_data.get("geographic_segments", [])
if not geographic_segments:
return {"error": "No geographic segment data available"}
regional_performance = []
total_revenue = sum(region.get("revenue", 0) for region in geographic_segments)
# Risk scores by region (simplified)
region_risk_scores = {
"νκ΅": 25, "λ―Έκ΅": 30, "μ λ½": 35, "μ€κ΅": 65, "κΈ°ν": 50
}
for region_data in geographic_segments:
region = region_data.get("region", "Unknown")
revenue = region_data.get("revenue", 0)
operating_profit = region_data.get("operating_profit", 0)
revenue_share = (revenue / total_revenue) * 100 if total_revenue > 0 else 0
operating_margin = (operating_profit / revenue) * 100 if revenue > 0 else 0
market_risk_score = region_risk_scores.get(region, 50)
regional_performance.append({
"region": region,
"revenue": revenue,
"revenue_share": round(revenue_share, 2),
"operating_profit": operating_profit,
"operating_margin": round(operating_margin, 2),
"market_risk_score": market_risk_score
})
# Geographic concentration analysis
revenue_shares = [rp["revenue_share"] for rp in regional_performance]
geographic_hhi = sum(share ** 2 for share in revenue_shares)
geographic_concentration = {
"hhi_index": round(geographic_hhi, 2),
"concentration_level": "high" if geographic_hhi > 2500 else "moderate" if geographic_hhi > 1500 else "low"
}
# Market risk assessment
weighted_risk = sum(
rp["market_risk_score"] * rp["revenue_share"] / 100
for rp in regional_performance
)
market_risk_assessment = {
"overall_risk_score": round(weighted_risk, 1),
"risk_level": "high" if weighted_risk > 60 else "moderate" if weighted_risk > 40 else "low",
"key_risk_regions": [rp["region"] for rp in regional_performance if rp["market_risk_score"] > 60]
}
# Currency exposure (simplified)
non_domestic_exposure = sum(
rp["revenue_share"] for rp in regional_performance
if rp["region"] != "νκ΅"
)
currency_exposure = {
"foreign_revenue_exposure": round(non_domestic_exposure, 2),
"currency_risk_level": "high" if non_domestic_exposure > 70 else "moderate" if non_domestic_exposure > 40 else "low"
}
return {
"regional_performance": regional_performance,
"geographic_concentration": geographic_concentration,
"market_risk_assessment": market_risk_assessment,
"currency_exposure": currency_exposure
}
async def evaluate_competitive_positioning(
self,
segment_data: Dict[str, Any],
market_data: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Evaluate competitive positioning of business segments"""
if market_data is None:
market_data = {}
segments = segment_data.get("segments", [])
market_position = []
for segment in segments:
name = segment.get("name", "Unknown")
revenue = segment.get("revenue_2023", 0)
# Get market data for segment
segment_market = market_data.get(name, {})
market_size = segment_market.get("market_size", revenue * 10) # Estimate if not provided
market_growth = segment_market.get("growth_rate", 3.0) # Default growth
# Estimate market share
estimated_market_share = (revenue / market_size) * 100 if market_size > 0 else 0
# Assess competitive strength (simplified scoring)
competitive_strength = min(100, max(0,
estimated_market_share * 5 + # Market share component
min(50, market_growth * 5) + # Growth opportunity component
25 # Base competitiveness
))
market_position.append({
"segment": name,
"estimated_market_share": round(estimated_market_share, 2),
"market_size": market_size,
"market_growth_rate": market_growth,
"competitive_strength": round(competitive_strength, 1),
"position": "leader" if estimated_market_share > 20 else "challenger" if estimated_market_share > 10 else "follower"
})
# Identify competitive advantages
competitive_advantages = []
for position in market_position:
if position["competitive_strength"] > 80:
competitive_advantages.append(f"{position['segment']}: Market leadership position")
elif position["market_growth_rate"] > 5:
competitive_advantages.append(f"{position['segment']}: High growth market opportunity")
# Market share estimates summary
total_weighted_share = sum(
pos["estimated_market_share"] * (pos["market_size"] / sum(p["market_size"] for p in market_position))
for pos in market_position
) if market_position else 0
market_share_estimates = {
"weighted_average_share": round(total_weighted_share, 2),
"leadership_positions": sum(1 for pos in market_position if pos["position"] == "leader"),
"growth_opportunities": sum(1 for pos in market_position if pos["market_growth_rate"] > 5)
}
# Strategic recommendations
strategic_recommendations = [
"Focus investment on high-growth segments",
"Strengthen market position in leadership segments",
"Evaluate strategic options for underperforming segments"
]
return {
"market_position": market_position,
"competitive_advantages": competitive_advantages,
"market_share_estimates": market_share_estimates,
"strategic_recommendations": strategic_recommendations
}
async def assess_segment_risks(
self,
segment_data: Dict[str, Any],
external_factors: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Assess risks associated with business segments"""
if external_factors is None:
external_factors = {}
segments = segment_data.get("segments", [])
segment_risks = []
# Risk scoring factors
economic_indicators = external_factors.get("economic_indicators", {})
industry_trends = external_factors.get("industry_trends", {})
for segment in segments:
name = segment.get("name", "Unknown")
revenue_2023 = segment.get("revenue_2023", 0)
revenue_2022 = segment.get("revenue_2022", 0)
# Calculate revenue trend
revenue_change = ((revenue_2023 / revenue_2022) - 1) * 100 if revenue_2022 > 0 else 0
# Risk assessment by segment type
segment_risks_list = []
risk_score = 50 # Base risk score
# Segment-specific risks
if "λ°λ체" in name:
segment_risks_list.extend(["Cyclical market volatility", "Technology obsolescence", "Capital intensity"])
if industry_trends.get("semiconductor") == "cyclical_downturn":
risk_score += 20
elif "λμ€νλ μ΄" in name or "ν¨λ" in name:
segment_risks_list.extend(["Competition from Chinese manufacturers", "Technology transition", "Price pressure"])
risk_score += 10
elif "λͺ¨λ°μΌ" in name or "IM" in name:
segment_risks_list.extend(["Market saturation", "Fierce competition", "Short product cycles"])
if industry_trends.get("mobile") == "market_saturation":
risk_score += 15
# Revenue trend impact
if revenue_change < -10:
risk_score += 15
segment_risks_list.append("Declining revenue trend")
elif revenue_change < 0:
risk_score += 5
# Determine risk level
if risk_score > 75:
risk_level = "high"
elif risk_score > 60:
risk_level = "moderate"
else:
risk_level = "low"
segment_risks.append({
"segment": name,
"risk_level": risk_level,
"risk_score": min(100, max(0, risk_score)),
"key_risks": segment_risks_list,
"revenue_trend": "declining" if revenue_change < 0 else "growing"
})
# Calculate overall risk metrics
risk_scores = [sr["risk_score"] for sr in segment_risks]
overall_risk_score = statistics.mean(risk_scores) if risk_scores else 50
# Risk concentration analysis
revenues = [segment.get("revenue_2023", 0) for segment in segments]
total_revenue = sum(revenues)
revenue_shares = [(r / total_revenue) * 100 if total_revenue > 0 else 0 for r in revenues]
# Weight risks by revenue contribution
weighted_risk_score = sum(
sr["risk_score"] * (revenue_shares[i] / 100)
for i, sr in enumerate(segment_risks)
) if segment_risks else 50
risk_concentration = {
"revenue_weighted_risk": round(weighted_risk_score, 1),
"high_risk_segments": sum(1 for sr in segment_risks if sr["risk_level"] == "high"),
"risk_diversification": "good" if len(segment_risks) > 3 else "moderate"
}
# Risk mitigation recommendations
risk_mitigation = [
"Diversify across multiple segments to reduce concentration risk",
"Monitor cyclical trends and adjust capacity accordingly",
"Invest in R&D to maintain technological competitiveness"
]
return {
"segment_risks": segment_risks,
"risk_concentration": risk_concentration,
"overall_risk_score": round(overall_risk_score, 1),
"risk_mitigation": risk_mitigation
}
async def generate_segment_insights(
self,
segment_data: Dict[str, Any],
analysis_context: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Generate strategic insights about business segments"""
if analysis_context is None:
analysis_context = {}
segments = segment_data.get("segments", [])
# Key findings
key_findings = []
if len(segments) > 0:
# Revenue distribution
revenues = [segment.get("revenue_2023", 0) for segment in segments]
total_revenue = sum(revenues)
largest_segment = max(segments, key=lambda x: x.get("revenue_2023", 0)) if segments else None
if largest_segment:
largest_share = (largest_segment.get("revenue_2023", 0) / total_revenue) * 100 if total_revenue > 0 else 0
key_findings.append(f"Largest segment: {largest_segment.get('name')} ({largest_share:.1f}% of revenue)")
key_findings.append(f"Portfolio consists of {len(segments)} business segments")
# Growth opportunities
growth_opportunities = [
"Expand presence in high-growth segments",
"Leverage synergies between complementary segments",
"Consider strategic partnerships or acquisitions"
]
# Performance concerns
performance_concerns = []
for segment in segments:
revenue_2023 = segment.get("revenue_2023", 0)
revenue_2022 = segment.get("revenue_2022", 0)
if revenue_2022 > 0:
growth = ((revenue_2023 / revenue_2022) - 1) * 100
if growth < -5:
performance_concerns.append(f"{segment.get('name')}: Revenue declining ({growth:.1f}%)")
if not performance_concerns:
performance_concerns.append("No major performance concerns identified")
# Strategic recommendations
strategic_recommendations = [
"Focus resources on highest-margin segments",
"Develop integrated segment strategy",
"Monitor competitive dynamics across all segments"
]
# Outlook assessment
industry = analysis_context.get("industry", "technology")
market_cycle = analysis_context.get("market_cycle", "mature")
outlook_assessment = {
"overall_outlook": "stable" if market_cycle == "mature" else "growth",
"key_drivers": ["Market demand trends", "Competitive positioning", "Technology innovation"],
"strategic_focus": "Operational efficiency and market share defense" if market_cycle == "mature" else "Growth and expansion"
}
return {
"key_findings": key_findings,
"growth_opportunities": growth_opportunities,
"performance_concerns": performance_concerns,
"strategic_recommendations": strategic_recommendations,
"outlook_assessment": outlook_assessment
}
async def comprehensive_segment_analysis(
self,
company_code: str,
include_all_metrics: bool = True
) -> Dict[str, Any]:
"""Perform comprehensive business segment analysis"""
comprehensive_analysis = {}
try:
# Get segment data
segment_data = await self.get_segment_data(company_code)
# Segment overview
segments = segment_data.get("segments", [])
comprehensive_analysis["segment_overview"] = {
"total_segments": len(segments),
"segment_names": [segment.get("name") for segment in segments],
"total_revenue": segment_data.get("total_revenue_2023", 0)
}
# Performance analysis
performance_analysis = await self.analyze_segment_performance(segment_data)
comprehensive_analysis["performance_analysis"] = performance_analysis
# Growth analysis
growth_analysis = await self.calculate_segment_growth_rates(segment_data)
comprehensive_analysis["growth_analysis"] = growth_analysis
# Profitability analysis
profitability_analysis = await self.analyze_segment_profitability(segment_data)
comprehensive_analysis["profitability_analysis"] = profitability_analysis
# Risk assessment
risk_assessment = await self.assess_segment_risks(segment_data)
comprehensive_analysis["risk_assessment"] = risk_assessment
# Strategic insights
strategic_insights = await self.generate_segment_insights(segment_data)
comprehensive_analysis["strategic_insights"] = strategic_insights
except Exception as e:
self.logger.error(f"Error in comprehensive segment analysis: {e}")
comprehensive_analysis["error"] = str(e)
return comprehensive_analysis
async def calculate_segment_efficiency_metrics(
self,
segment_data: Dict[str, Any],
efficiency_benchmarks: Dict[str, float] = None
) -> Dict[str, Any]:
"""Calculate segment efficiency metrics"""
if efficiency_benchmarks is None:
efficiency_benchmarks = {}
segments = segment_data.get("segments", [])
segment_efficiency = []
for segment in segments:
name = segment.get("name", "Unknown")
revenue = segment.get("revenue_2023", 0)
assets = segment.get("assets", 1)
employees = segment.get("employees", 1)
# Calculate efficiency metrics
asset_turnover = revenue / assets if assets > 0 else 0
employee_productivity = revenue / employees if employees > 0 else 0
# Benchmark comparison
asset_benchmark = efficiency_benchmarks.get("asset_turnover", 1.0)
productivity_benchmark = efficiency_benchmarks.get("employee_productivity", 2.0)
# Efficiency score
asset_score = min(100, (asset_turnover / asset_benchmark) * 50) if asset_benchmark > 0 else 50
productivity_score = min(100, (employee_productivity / productivity_benchmark) * 50) if productivity_benchmark > 0 else 50
efficiency_score = (asset_score + productivity_score) / 2
segment_efficiency.append({
"name": name,
"asset_turnover": round(asset_turnover, 2),
"employee_productivity": round(employee_productivity / 1000000, 2), # In millions
"efficiency_score": round(efficiency_score, 1),
"efficiency_rank": 0 # Will be updated
})
# Rank by efficiency
segment_efficiency.sort(key=lambda x: x["efficiency_score"], reverse=True)
for i, segment in enumerate(segment_efficiency):
segment["efficiency_rank"] = i + 1
# Identify improvement opportunities
improvement_opportunities = []
for segment in segment_efficiency:
if segment["efficiency_score"] < 60:
improvement_opportunities.append(f"{segment['name']}: Focus on asset utilization and productivity")
return {
"segment_efficiency": segment_efficiency,
"efficiency_ranking": segment_efficiency,
"improvement_opportunities": improvement_opportunities
}
async def get_segment_data(self, company_code: str) -> Dict[str, Any]:
"""Get business segment data for a company (mock implementation)"""
# Mock segment data for testing
if company_code == "005930": # Samsung Electronics
return {
"company_code": company_code,
"segments": [
{
"name": "λ°λ체",
"revenue_2023": 63747000000000, "revenue_2022": 76956000000000, "revenue_2021": 83018000000000,
"operating_profit_2023": 3369000000000, "operating_profit_2022": 18325000000000, "operating_profit_2021": 26009000000000,
"assets": 145632000000000, "employees": 85000, "capex": 24500000000000,
"percentage_of_total": 25.8
},
{
"name": "λμ€νλ μ΄ν¨λ",
"revenue_2023": 50148000000000, "revenue_2022": 47543000000000, "revenue_2021": 45897000000000,
"operating_profit_2023": 1561000000000, "operating_profit_2022": 1204000000000, "operating_profit_2021": 895000000000,
"assets": 82451000000000, "employees": 45000, "capex": 8900000000000,
"percentage_of_total": 20.3
},
{
"name": "IM(λͺ¨λ°μΌ)",
"revenue_2023": 124871000000000, "revenue_2022": 118345000000000, "revenue_2021": 109385000000000,
"operating_profit_2023": 8952000000000, "operating_profit_2022": 7825000000000, "operating_profit_2021": 6851000000000,
"assets": 67234000000000, "employees": 92000, "capex": 12300000000000,
"percentage_of_total": 50.5
},
{
"name": "κΈ°ν",
"revenue_2023": 8908000000000, "revenue_2022": 9128000000000, "revenue_2021": 8745000000000,
"operating_profit_2023": 421000000000, "operating_profit_2022": 392000000000, "operating_profit_2021": 315000000000,
"assets": 12851000000000, "employees": 25000, "capex": 1200000000000,
"percentage_of_total": 3.4
}
],
"geographic_segments": [
{"region": "νκ΅", "revenue": 75234000000000, "operating_profit": 4521000000000, "percentage": 30.4},
{"region": "μ€κ΅", "revenue": 58967000000000, "operating_profit": 3214000000000, "percentage": 23.9},
{"region": "λ―Έκ΅", "revenue": 68453000000000, "operating_profit": 4123000000000, "percentage": 27.7},
{"region": "μ λ½", "revenue": 25129000000000, "operating_profit": 1524000000000, "percentage": 10.2},
{"region": "κΈ°ν", "revenue": 19091000000000, "operating_profit": 921000000000, "percentage": 7.8}
],
"total_revenue_2023": 247674000000000,
"total_revenue_2022": 251972000000000,
"total_revenue_2021": 256387000000000,
"total_operating_profit_2023": 14303000000000
}
else:
# Default mock data for other companies
return {
"company_code": company_code,
"segments": [
{
"name": "μ¬μ
λΆλ¬Έ1",
"revenue_2023": 100000000000, "revenue_2022": 95000000000, "revenue_2021": 90000000000,
"operating_profit_2023": 8000000000, "operating_profit_2022": 7500000000,
"assets": 50000000000, "employees": 5000
},
{
"name": "μ¬μ
λΆλ¬Έ2",
"revenue_2023": 80000000000, "revenue_2022": 85000000000, "revenue_2021": 82000000000,
"operating_profit_2023": 5000000000, "operating_profit_2022": 5500000000,
"assets": 40000000000, "employees": 4000
}
],
"total_revenue_2023": 180000000000,
"total_operating_profit_2023": 13000000000
}