Overview
When building a Korean stock data pipeline in Python, you’ll encounter two popular libraries: pykrx and FinanceDataReader. Both are free and open-source, but they have different strengths.
What is pykrx?
pykrx is a Python library that pulls data directly from the KRX (Korea Exchange) website. It is focused exclusively on Korean markets.
Install:
pip install pykrx
What is FinanceDataReader?
FinanceDataReader (FDR) is a broader financial data library that supports Korean stocks, US stocks, ETFs, crypto, and more — all through a unified API.
Install:
pip install finance-datareader
Feature Comparison
| Feature | pykrx | FinanceDataReader |
|---|---|---|
| Korean stocks (KOSPI/KOSDAQ) | ✅ Excellent | ✅ Good |
| US stocks | ❌ No | ✅ Yes |
| Korean ETFs | ✅ Yes | ✅ Yes |
| Crypto | ❌ No | ✅ Yes |
| Market cap data | ✅ Yes | ❌ Limited |
| Fundamental data (PER, PBR) | ✅ Yes | ❌ No |
| Foreign investor data | ✅ Yes | ❌ No |
| Index data | ✅ Yes | ✅ Yes |
| Unified API for multiple markets | ❌ No | ✅ Yes |
| Setup required | None | None |
| Cost | Free | Free |
Code Comparison
Getting Samsung Electronics Data
pykrx:
from pykrx import stock
df = stock.get_market_ohlcv_by_date("20240101", "20241231", "005930")
print(df.head())
FinanceDataReader:
import FinanceDataReader as fdr
df = fdr.DataReader("005930", "2024-01-01", "2024-12-31")
print(df.head())
FDR wins on syntax simplicity — date format is more intuitive.
Getting Fundamental Data
pykrx (supported):
from pykrx import stock
df = stock.get_market_fundamental_by_ticker("20241231", market="KOSPI")
print(df[["PER", "PBR", "DIV"]].head())
FinanceDataReader (not supported):
# FDR does not provide PER, PBR, dividend data for Korean stocks
# You need a separate data source for fundamentals
pykrx wins for fundamental data.
Getting US Stock Data
pykrx (not supported):
# pykrx only covers Korean markets
FinanceDataReader (supported):
import FinanceDataReader as fdr
# Apple
aapl = fdr.DataReader("AAPL", "2024-01-01")
# S&P 500
sp500 = fdr.DataReader("SPY", "2024-01-01")
FDR wins for multi-market coverage.
When to Use pykrx
Choose pykrx when you need:
- Korean stock fundamental data (PER, PBR, dividend yield)
- Foreign investor trading volume
- Detailed market cap data
- Korean market-specific data (short selling, program trading)
- Sector/theme index data
# pykrx shines here — FDR can't do this
from pykrx import stock
# Get all KOSPI stocks with low PER and high dividend
fundamentals = stock.get_market_fundamental_by_ticker("20241231", market="KOSPI")
value_stocks = fundamentals[
(fundamentals["PER"] > 0) & (fundamentals["PER"] < 10) &
(fundamentals["DIV"] > 3.0)
]
print(value_stocks.head())
When to Use FinanceDataReader
Choose FDR when you need:
- Cross-market comparison (Korean vs US stocks)
- Simple, clean API for price data
- Crypto or commodity data
- Quick prototyping
# FDR shines here — compare Korean and US markets
import FinanceDataReader as fdr
samsung = fdr.DataReader("005930", "2024-01-01")
nvidia = fdr.DataReader("NVDA", "2024-01-01")
samsung_return = (samsung["Close"].iloc[-1] / samsung["Close"].iloc[0] - 1) * 100
nvidia_return = (nvidia["Close"].iloc[-1] / nvidia["Close"].iloc[0] - 1) * 100
print(f"Samsung 2024 return: {samsung_return:.1f}%")
print(f"NVIDIA 2024 return: {nvidia_return:.1f}%")
Use Both Together
The best approach is to use both libraries together:
from pykrx import stock
import FinanceDataReader as fdr
# Use FDR for price history (cleaner syntax)
df_price = fdr.DataReader("005930", "2024-01-01", "2024-12-31")
# Use pykrx for fundamentals (not available in FDR)
df_fundamentals = stock.get_market_fundamental_by_ticker("20241231", market="KOSPI")
samsung_fundamentals = df_fundamentals.loc["005930"]
print(f"Samsung PER: {samsung_fundamentals['PER']}")
print(f"Samsung PBR: {samsung_fundamentals['PBR']}")
print(f"Samsung Dividend Yield: {samsung_fundamentals['DIV']}%")
Summary
| Use Case | Winner |
|---|---|
| Korean fundamental data | pykrx |
| Multi-market data | FinanceDataReader |
| Simple price data | FinanceDataReader |
| Foreign investor data | pykrx |
| US + Korean comparison | FinanceDataReader |
| Stock screener | pykrx |
Bottom line: For Korean-only projects, pykrx is the better choice. For projects that need both Korean and international data, use FinanceDataReader — or combine both.