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.

Best for:

  • Live trading automation
  • Real-time price data
  • Order placement and management
  • Production trading systems

Detailed Comparison

FeaturepykrxKIS API
Account requiredNoYes
API approval requiredNoYes
Real-time quotesNoYes
Historical dataYes (good)Yes (limited)
Order placementNoYes
WebSocket streamingNoYes
Rate limitsUnofficial, scrapingOfficial limits
ReliabilityMediumHigh
CostFreeFree (with account)
Setup time5 minutes1-3 days

My Recommendation

Use pykrx when:

  • You’re learning and prototyping
  • You need historical data for backtesting
  • You want to screen stocks without a live account
  • You’re building research tools

Use KIS API when:

  • You’re ready to trade with real money
  • You need real-time data
  • You want to place automated orders
  • You’re building a production trading bot

Using Both Together

The best approach is to use both:

# Use pykrx for historical backtesting
from pykrx import stock
historical_data = stock.get_market_ohlcv_by_date("20240101", "20241231", "005930")

# Use KIS API for live trading signals
import requests
live_price = get_kis_price("005930", token)  # KIS API

# Compare and make trading decision
if live_price < historical_data["종가"].mean() * 0.95:
    place_buy_order("005930", quantity=10)  # KIS API