Skip to content
Back to skills

Pykrx Korean Market

ASecurity

Korean Capital Market (KOSPI, KOSDAQ, KONEX) data extraction skill using FinanceDataReader and pykrx. Supports Korean stock tickers, daily OHLCV historical charts, market cap ranking, investor net buying trends, and financial ratios.

  • 16 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added November 12, 2026
datapythongoreactapiperformance

Works with

  • api
  • mcp

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add hukim1112/frontier_agent_analysis --skill pykrx-korean-market --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pykrx Korean Market?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pykrx Korean Market
[![Security: A โ€” Skills Directory](https://www.skillsdirectory.com/api/skills/hukim1112-pykrx-korean-market/badge)](https://www.skillsdirectory.com/skills/hukim1112-pykrx-korean-market)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pykrx-korean-market
description: Korean Capital Market (KOSPI, KOSDAQ, KONEX) data extraction skill using FinanceDataReader and pykrx. Supports Korean stock tickers, daily OHLCV historical charts, market cap ranking, investor net buying trends, and financial ratios.
category: finance
tags: [korea, kospi, kosdaq, krx, fdr, pykrx, investor-trends, valuation]
dependencies: [finance-datareader, pykrx, pandas, numpy]
---

# pykrx-korean-market Skill

Specialized skill for the Korean domestic securities and capital markets (KRX, KOSPI, KOSDAQ). Combines `FinanceDataReader` (high reliability for listings & market cap) and `pykrx` (for investor breakdown and fundamental analytics).

## ๐ŸŽฏ Educational & Practical Use Cases (Practical Focus)
- **Market Indices & Sector Benchmarks**: Query daily performance of KOSPI, KOSDAQ, KRX 300.
- **Top Market Cap Rankings**: Fetch real-time market cap rankings across KOSPI / KOSDAQ without login restrictions.
- **Historical OHLCV Data**: Retrieve historical price candles for Samsung Electronics, SK Hynix, and all Korean listed assets.
- **Investor Flow Analysis (์ˆ˜๊ธ‰ ๋ถ„์„)**: Query Foreign, Institutional, and Retail net trade distributions.

---

## ๐Ÿ› ๏ธ LangChain & FastMCP Implementation

```python
"""
korean_market_tools.py - Korean stock market tools for LangChain & FastMCP Agents.
"""
from typing import Dict, Any, List, Optional
from datetime import datetime, timedelta
import pandas as pd
import FinanceDataReader as fdr
from langchain_core.tools import tool

@tool
def get_krx_stock_quote(ticker_or_name: str) -> Dict[str, Any]:
    """
    Get the latest quote, price changes, and 52-week data for a Korean stock by ticker code (e.g., '005930') or company name (e.g., '์‚ผ์„ฑ์ „์ž').
    """
    # Fetch KRX listing summary
    df_krx = fdr.StockListing('KRX')
    
    # Search by code or name
    ticker_clean = ticker_or_name.replace(".KS", "").replace(".KQ", "").strip()
    match = df_krx[(df_krx['Code'] == ticker_clean) | (df_krx['Name'] == ticker_or_name)]
    
    if match.empty:
        return {"error": f"Stock '{ticker_or_name}' not found in KRX listing."}
        
    row = match.iloc[0]
    code = row['Code']
    name = row['Name']
    
    # Fetch recent OHLCV
    start_date = (datetime.now() - timedelta(days=15)).strftime("%Y-%m-%d")
    df_ohlcv = fdr.DataReader(code, start_date)
    
    latest_candle = df_ohlcv.iloc[-1] if not df_ohlcv.empty else {}

    return {
        "ticker": code,
        "name": name,
        "market": row.get('Market', 'KRX'),
        "sector": row.get('Sector', 'Unknown'),
        "latest_close": int(row.get('Close', latest_candle.get('Close', 0))),
        "change_pct": float(row.get('ChagesRatio', 0.0)),
        "volume": int(row.get('Volume', latest_candle.get('Volume', 0))),
        "amount_krw": int(row.get('Amount', 0)),
        "market_cap_krw": int(row.get('Marcap', 0)),
        "shares_outstanding": int(row.get('Stocks', 0))
    }

@tool
def get_krx_top_market_cap(market: str = "KOSPI", top_n: int = 10) -> List[Dict[str, Any]]:
    """
    Get top N stocks ranked by market capitalization in KOSPI, KOSDAQ, or KRX.
    """
    market_filter = market.upper()
    df_krx = fdr.StockListing('KRX')
    
    if market_filter in ["KOSPI", "KOSDAQ", "KONEX"]:
        df_filtered = df_krx[df_krx['Market'] == market_filter]
    else:
        df_filtered = df_krx
        
    df_sorted = df_filtered.sort_values(by='Marcap', ascending=False).head(top_n)
    
    results = []
    for rank, (_, row) in enumerate(df_sorted.iterrows(), 1):
        results.append({
            "rank": rank,
            "ticker": row['Code'],
            "name": row['Name'],
            "market": row['Market'],
            "close": int(row['Close']),
            "change_pct": float(row.get('ChagesRatio', 0.0)),
            "market_cap_krw": int(row['Marcap']),
            "sector": row.get('Sector', '')
        })
    return results

@tool
def get_krx_historical_ohlcv(ticker: str, days: int = 30) -> List[Dict[str, Any]]:
    """
    Get historical daily OHLCV candles for a Korean stock code (e.g., '000660', '035420').
    """
    ticker_clean = ticker.replace(".KS", "").replace(".KQ", "").strip()
    start_date = (datetime.now() - timedelta(days=days*2)).strftime("%Y-%m-%d")
    df = fdr.DataReader(ticker_clean, start_date)
    
    if df.empty:
        return []
        
    records = []
    for date_idx, row in df.tail(days).iterrows():
        records.append({
            "date": str(date_idx)[:10],
            "open": int(row["Open"]),
            "high": int(row["High"]),
            "low": int(row["Low"]),
            "close": int(row["Close"]),
            "volume": int(row["Volume"]),
            "change": round(float(row.get("Change", 0.0)) * 100, 2)
        })
    return records
```

---

## ๐Ÿค– ReAct Agent Scenario

```yaml
agent_interaction:
  user_query: "์ฝ”์Šคํ”ผ ์‹œ๊ฐ€์ด์•ก ์ƒ์œ„ 5๊ฐœ ์ข…๋ชฉ๊ณผ ์‚ผ์„ฑ์ „์ž์˜ ์ตœ๊ทผ 10์ผ๊ฐ„ ์ฃผ๊ฐ€ ์ถ”์ด๋ฅผ ์•Œ๋ ค์ค˜."
  agent_steps:
    1. Call `get_krx_top_market_cap(market="KOSPI", top_n=5)`.
    2. Call `get_krx_historical_ohlcv(ticker="005930", days=10)`.
    3. Generate a structured capital market briefing.
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data โ†’

Comments

Loading commentsโ€ฆ

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.