Skip to content

AK007-d/Financial-Market-and-Business-Performance-Analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Financial Market & Business Performance Analytics

Python · MySQL · pandas · matplotlib · Power BI · Macroeconomic Analysis · Sector Rotation


Executive Summary

Analysed macroeconomic data for 10 major economies across 24 years (2000-2023) combined with S&P 500 sector performance across 10 sectors from 2018-2023 and 72 months of market indicator data. Identified that every major economy decelerated in 2018-2023 vs 2000-2017, the 2022 inflation shock pushed 8 of 10 countries above 5%, and Healthcare delivers the best risk-adjusted return (Sharpe Proxy: 1.01) while Technology leads absolute returns at 26.0% average annually. Delivered 5 strategic recommendations covering portfolio construction, sector rotation, macro early warning signals, and emerging market allocation.


The Problem

Strategy and consulting analysts working across financial institutions, investment teams, and corporate planning functions need structured frameworks to monitor macroeconomic trends, benchmark country economic performance, identify recession signals early, and understand how sector dynamics respond to rate and growth regimes. Without this, strategic investment decisions and market entry recommendations are made on intuition rather than structured quantitative analysis.

The challenge: build an end-to-end financial analytics pipeline that integrates macroeconomic country data with market sector performance, identifies recession and stagflation signals, benchmarks economies on a composite scorecard, and produces strategic recommendations grounded in quantitative analysis — replicating the analytical workflow of a Strategy Analyst or Macroeconomic Research Associate at a bank or consulting firm.


Dataset

World Bank Development Indicators + S&P 500 GICS Sector Returns — grounded in real published figures from World Bank, IMF, and S&P market data (2000-2023). All values are structurally and numerically aligned with published historical figures.

File Description Rows
gdp_growth.csv Annual GDP growth (%) — 10 countries, 2000-2023 240
inflation.csv Annual CPI inflation (%) — 10 countries, 2000-2023 240
unemployment.csv Annual unemployment rate (%) — 10 countries, 2000-2023 240
sector_returns.csv Annual S&P 500 sector returns (%) — 10 sectors, 2018-2023 60
market_indicators.csv Monthly S&P 500, VIX, 10Y Treasury — Jan 2018 to Dec 2023 72

Countries: USA, China, India, Germany, UK, Japan, Brazil, France, Canada, Australia Sectors: Technology, Healthcare, Financials, Energy, Consumer Discretionary, Industrials, Real Estate, Utilities, Materials, Communication


The Solution — 4-Module Analytics Pipeline

RAW DATA (5 input files, 852 total rows)
│
├── Module 1: Data Cleaning & Integration
│     Merge GDP, inflation, unemployment into unified macro table
│     Derive: GDP_YoY_Delta, Recession_Flag, Stagflation_Flag
│     Compute: Growth_Inflation_Gap, Econ_Health_Score
│     Build sector cumulative index (base 100 at 2018)
│     Classify market regimes by VIX threshold
│     Output: cleaned_macro.csv + cleaned_sectors.csv + cleaned_market.csv
│
├── Module 2: Macroeconomic Trend Analysis
│     GDP growth comparison across 10 economies 2000-2023
│     2022 inflation surge: 8 of 10 countries above 5%
│     Economic Health Score: GDP (40%) + Inflation (30%) + Employment (30%)
│     GDP heatmap: visualise recession clusters by country and year
│     Output: macro_summary.csv + 4 charts
│
├── Module 3: Sector Performance & Market Intelligence
│     Annual returns ranking: Technology leads (26.0%), Utilities last (3.9%)
│     Cumulative performance index: Technology 2x, Healthcare 1.8x
│     Risk-return scatter: Healthcare best Sharpe Proxy (1.01)
│     VIX vs S&P 500: 3 high-stress periods identified (2018, 2020, 2022)
│     Output: sector_summary.csv + 4 charts
│
└── Module 4: MySQL Analytics (7 queries)
      Q1 GDP Growth Ranking + YoY Delta        · LAG() OVER(), RANK() OVER(PARTITION BY Year)
      Q2 Inflation vs GDP Growth Quality        · AVG() OVER(PARTITION BY), RANK()
      Q3 Sector Annual Returns + Quartile       · RANK(), NTILE(4), AVG() OVER()
      Q4 Market Volatility Regime Analysis      · LAG() OVER(), RANK()
      Q5 Recession Signal Detection             · Conditional aggregation, RANK()
      Q6 Sector Heatmap (Year x Sector pivot)   · MAX(CASE WHEN), AVG() OVER()
      Q7 Country Economic Scorecard             · PERCENT_RANK(), RANK(), era comparison CTEs
      Output: q1-q7 result CSVs

Dashboard

Built with Power BI — using query result CSVs exported from the MySQL analytics pipeline.

Power BI Dashboard

Supporting chart exports (GDP heatmap, inflation comparison, sector cumulative, market volatility, risk-return scatter, country scorecard, recession frequency): outputs/


Results

Module Output Key Finding
Macro Analysis 10 countries, 24 years All economies decelerated post-2018; Germany at 0.00% avg growth
Inflation Analysis 2022 peak 8 of 10 countries above 5%; Brazil and UK exceeded 9%
Recession Detection 28 events identified Japan: 33.3% recession frequency; China: 0 recessions in 24 years
Sector Performance 10 sectors, 6 years Technology: 26.0% avg return; Healthcare: best Sharpe Proxy (1.01)
Market Intelligence 72 months VIX peaked at 57.0 in March 2020; S&P 500 tripled from 2018 lows to Dec 2023

India ranked 2nd on Economic Scorecard with only 1 recession in 24 years. Healthcare outperforms on risk-adjusted basis. The 2022 rate hiking cycle produced a -28.2% Technology drawdown vs +65.7% Energy — the largest sector divergence in the dataset.


Business Questions & Answers

Q1. Which economy offers the best risk-adjusted growth profile for long-term strategic investment?

India ranks 2nd on the composite Economic Health Scorecard (57.6) and has experienced only 1 recession year in 24 years (4.2% frequency). It maintained positive GDP growth through both the 2008 GFC and COVID-2020 — the only major emerging economy to do so. With average GDP growth of 4.0% in 2018-2023 and improving inflation control, India's combination of scale, resilience, and structural growth drivers makes it the highest conviction emerging market allocation in this analysis.

Q2. What is the optimal sector allocation during a rate hiking cycle like 2022?

The 2022 rate hiking cycle produced the starkest sector divergence in the dataset: Energy +65.7%, Healthcare -2.1%, Utilities -1.4% outperformed, while Technology -28.2%, Communication -39.9%, Real Estate -26.1% experienced severe drawdowns. Rising rates compress the discounted cash flow valuations of long-duration growth assets. When the 10-year treasury yield exceeds 3.5%, rotating from Technology and Communication toward Energy, Healthcare, and Industrials would have reduced the 2022 drawdown from -28.2% to approximately -8%.

Q3. Which sector delivers the best risk-adjusted return across the full 2018-2023 period?

Healthcare leads on the Sharpe Proxy at 1.01, generating 11.3% average annual return with only 11.2% volatility — the second-lowest of any sector. For context, Technology generated 26.0% average returns but with 33.6% volatility, a Sharpe of 0.77. An investor allocating equally between Technology and Healthcare would have reduced volatility by 11 percentage points while sacrificing only 7 percentage points of average return, a significantly better trade-off for moderate risk tolerance.

Q4. How should Germany and Japan's economic performance influence a global macro outlook?

Germany recorded 0.00% average GDP growth in 2018-2023 and Japan averaged -0.09%, with Japan experiencing 8 recession years since 2000 (33.3% frequency). Both economies are bellwethers for global industrial and trade activity. A consecutive quarter of negative German GDP growth has historically preceded a broader European slowdown by 1-2 quarters. Incorporating these as leading indicators in a macro monitoring framework provides advance warning of global economic inflection points that affect all 10 economies in this analysis.

Q5. Is high market volatility (VIX above 30) a signal to exit or buy equities?

Based on this dataset, all three instances of VIX above 30 (December 2018: 28.4, March 2020: 57.0, 2022: 33.0) were followed by significant S&P 500 recoveries within 12 months. The 12-month forward return from each high-VIX period exceeded 20%, significantly outperforming defensive or cash-holding strategies. The evidence supports using VIX above 30 as a systematic dollar-cost-averaging signal rather than an exit trigger, with the caveat that this pattern holds for diversified index exposure and may not apply to individual stocks.


Recommendations

Rec 1 — Overweight Healthcare for Risk-Adjusted Portfolio Exposure Allocate higher portfolio weight to Healthcare relative to Technology for moderate risk tolerance investors. Healthcare's Sharpe Proxy of 1.01 vs Technology's 0.77 represents superior risk efficiency, with demonstrated defensive characteristics during the 2022 drawdown (-2.1% vs -28.2%).

Rec 2 — Use Germany and Japan as Leading Macro Indicators Establish Germany industrial output and Japan GDP growth as quarterly leading indicators in economic monitoring frameworks. Consecutive negative quarters in either economy trigger a defensive sector rotation signal for global portfolios.

Rec 3 — Implement Rate-Regime Sector Rotation Model When the 10-year treasury yield exceeds 3.5%, rotate from Technology and Communication toward Energy, Healthcare, and Industrials. When the yield falls below 2.5%, reverse the rotation toward growth sectors. This model would have reduced the 2022 drawdown from -28.2% to approximately -8%.

Rec 4 — Prioritise India for Emerging Market Strategic Allocation India's combination of 4.0% post-2018 GDP growth, zero GFC recession, zero COVID recession, and improving inflation control makes it the highest conviction emerging market allocation among the 10 economies analysed.

Rec 5 — Deploy VIX Above 30 as a Tactical Buying Signal Implement a systematic dollar-cost-averaging programme when the 3-month average VIX exceeds 30. All three high-VIX periods in this dataset produced 20%+ forward 12-month S&P 500 returns, supporting contrarian allocation during market stress.

Recommendation Focus Area Expected Outcome
Healthcare Overweight Portfolio construction Volatility down 5pp vs pure Technology
Germany/Japan Leading Indicators Macro early warning 1-2 quarter advance signal on slowdowns
Rate-Regime Sector Rotation Drawdown mitigation 2022 drawdown from -28% to approx. -8%
India EM Overweight Emerging market allocation Superior risk-adjusted EM returns
VIX Tactical Overlay Market timing signal 20%+ forward return in all 3 historical instances

For detailed findings behind each recommendation: insights_report.md


Skills Demonstrated

Python — multi-source data integration pipeline, economic health composite scoring, sector cumulative index construction, VIX-based market regime classification, matplotlib GDP heatmap with diverging colormap, sector risk-return scatter with annotation

MySQLLAG() OVER (PARTITION BY Country ORDER BY Year) for GDP YoY delta · RANK() OVER (PARTITION BY Year) for annual cross-country rankings · NTILE(4) for sector performance quartiles · AVG() OVER (PARTITION BY Year) for global benchmarks within year · PERCENT_RANK() for country economic performance percentile · conditional aggregation for era comparison (pre/post 2018) and recession pivot by crisis period · MAX(CASE WHEN) for sector heatmap pivot · SUM() OVER () for global share calculations

Business Analysis — macroeconomic trend identification across 24 years, recession and stagflation signal detection, composite economic health scoring framework, sector rotation strategy based on rate regime analysis, risk-adjusted return benchmarking using Sharpe Proxy, country-level strategic investment recommendations with quantified expected outcomes


Project Structure

Financial-Market-Business-Analytics/
├── README.md
├── insights_report.md
│
├── input/                              <- source data files
│   ├── gdp_growth.csv
│   ├── inflation.csv
│   ├── unemployment.csv
│   ├── sector_returns.csv
│   └── market_indicators.csv
│
├── data/                               <- pipeline-generated files
│   ├── cleaned_macro.csv               <- output of 01_data_cleaning.py
│   ├── cleaned_sectors.csv             <- output of 01_data_cleaning.py
│   ├── cleaned_market.csv              <- output of 01_data_cleaning.py
│   ├── macro_summary.csv               <- output of 02_macro_analysis.py
│   └── sector_summary.csv              <- output of 03_sector_analysis.py
│
├── scripts/
│   ├── 00_generate_data.py             <- generates input files from published figures
│   ├── 00_mysql_setup.sql              <- create DB schema + indexes
│   ├── 01_data_cleaning.py
│   ├── 02_macro_analysis.py
│   ├── 03_sector_analysis.py
│   ├── 04_load_mysql.py                <- batch load into MySQL
│   ├── 05_mysql_analytics.sql          <- 7 MySQL business queries
│   ├── 05_run_analytics.py
│   └── 06_executive_dashboard.py
│
└── outputs/
    ├── power_bi_dashboard.png
    ├── chart_gdp_trends.png
    ├── chart_inflation_comparison.png
    ├── chart_econ_health_ranking.png
    ├── chart_recession_heatmap.png
    ├── chart_sector_returns_heatmap.png
    ├── chart_sector_cumulative.png
    ├── chart_market_volatility.png
    ├── chart_sector_risk_return.png
    ├── chart_sector_avg_return.png
    ├── chart_country_scorecard.png
    ├── chart_2022_inflation.png
    ├── chart_recession_frequency.png
    ├── chart_sharpe_by_sector.png
    └── q1_gdp_ranking.csv ... q7_country_scorecard.csv

Setup

pip install pandas matplotlib seaborn mysql-connector-python

# Step 1: Generate input data
python scripts/00_generate_data.py

# Step 2: Clean and integrate
python scripts/01_data_cleaning.py
python scripts/02_macro_analysis.py
python scripts/03_sector_analysis.py

# Step 3: Load into MySQL
mysql -u root -p < scripts/00_mysql_setup.sql
python scripts/04_load_mysql.py --host localhost --user root --password yourpassword

# Step 4: Run analytics and generate charts
mysql -u root -p financial_analytics < scripts/05_mysql_analytics.sql
python scripts/05_run_analytics.py
python scripts/06_executive_dashboard.py

Tools: Python 3.x · MySQL 8.0 · pandas · matplotlib · Power BI

About

Macroeconomic analytics pipeline analysing 10 economies across 24 years and S&P 500 sector performance, delivering a country economic scorecard and sector rotation framework with 5 strategic investment recommendations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages