pykrx Tutorial: Pull Korean Stock Data with Python (2026)

What is pykrx? pykrx is an open-source Python library that pulls data from the KRX website. It is the easiest way to get Korean stock market data without needing a paid API. Installation pip install pykrx Basic Usage Get Stock Price History from pykrx import stock # Get Samsung Electronics (005930) price history df = stock.get_market_ohlcv_by_date("20240101", "20241231", "005930") print(df.head()) Get All KOSPI Tickers from pykrx import stock # Get all KOSPI tickers tickers = stock.get_market_ticker_list(market="KOSPI") print(f"Total KOSPI stocks: {len(tickers)}") # Get company name from ticker name = stock.get_market_ticker_name("005930") print(f"005930 = {name}") # Samsung Electronics Get Market Cap Data # Get market cap for all KOSPI stocks df = stock.get_market_cap_by_ticker("20241231", market="KOSPI") print(df.sort_values("시가총액", ascending=False).head(10)) Get Fundamental Data # Get PER, PBR, dividend yield df = stock.get_market_fundamental_by_ticker("20241231", market="KOSPI") print(df[["PER", "PBR", "DIV"]].head()) Building a Simple Screener from pykrx import stock def screen_low_per_stocks(market="KOSPI", max_per=10): today = "20241231" fundamentals = stock.get_market_fundamental_by_ticker(today, market=market) low_per = fundamentals[ (fundamentals["PER"] > 0) & (fundamentals["PER"] < max_per) ] low_per["name"] = [stock.get_market_ticker_name(t) for t in low_per.index] return low_per[["name", "PER", "PBR", "DIV"]].sort_values("PER") results = screen_low_per_stocks() print(results.head(20)) pykrx vs KIS API Comparison Feature pykrx KIS API Real-time data No Yes Historical data Yes Yes Order placement No Yes Cost Free Free (with account) Best for Research, backtesting Live trading

June 19, 2026 · 1 min · Phillip

Build a Korean Stock Screener with pykrx (Python Tutorial)

What We’re Building A Python-based Korean stock screener that: Pulls data from KRX via pykrx Filters stocks by multiple criteria (PER, PBR, volume) Exports results to CSV Can be automated with GitHub Actions Setup pip install pykrx pandas Complete Screener Code from pykrx import stock import pandas as pd from datetime import datetime, timedelta class KoreanStockScreener: def __init__(self, market="KOSPI"): self.market = market self.today = datetime.now().strftime("%Y%m%d") def get_all_data(self): fundamentals = stock.get_market_fundamental_by_ticker( self.today, market=self.market ) market_cap = stock.get_market_cap_by_ticker( self.today, market=self.market ) df = pd.concat([fundamentals, market_cap[["시가총액", "거래량"]]], axis=1) df["name"] = [stock.get_market_ticker_name(t) for t in df.index] return df def screen(self, max_per=15, max_pbr=1.5, min_div=2.0, min_volume=100000): df = self.get_all_data() filtered = df[ (df["PER"] > 0) & (df["PER"] < max_per) & (df["PBR"] > 0) & (df["PBR"] < max_pbr) & (df["DIV"] > min_div) & (df["거래량"] > min_volume) ] return filtered[["name", "PER", "PBR", "DIV", "시가총액", "거래량"]] def export(self, df, filename="screener_results.csv"): df.to_csv(filename, encoding="utf-8-sig") print(f"Saved {len(df)} stocks to {filename}") # Run screener screener = KoreanStockScreener(market="KOSPI") results = screener.screen(max_per=12, max_pbr=1.2, min_div=3.0) print(results.head(20)) screener.export(results) Automating with GitHub Actions Create .github/workflows/screener.yml: ...

June 18, 2026 · 2 min · Phillip

KIS API vs pykrx: Which Should You Use for Korean Stock Trading?

Overview If you’re building a Korean stock trading system in Python, you’ll encounter two main tools: KIS API and pykrx. Here’s a detailed breakdown of when to use each. What is pykrx? pykrx is an open-source library that scrapes publicly available data from the KRX website. It requires no account or API key. Best for: Historical data research Backtesting trading strategies Stock screening and analysis Learning and prototyping What is KIS API? KIS API is the official API from Korea Investment & Securities. It requires a brokerage account and API approval. ...

June 16, 2026 · 2 min · Phillip