{"library":"pykrx","title":"pykrx: KRX Data Scraper","description":"pykrx is a Python library for scraping data from the Korea Exchange (KRX) and related financial data sources (e.g., Naver Finance). It provides functions to retrieve stock prices, market capitalization, OHLCV data, ETF, and bond information. The library is actively maintained with frequent updates to adapt to changes in upstream data sources and API policies. The current version is 1.2.7.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pykrx"],"cli":null},"imports":["from pykrx import stock"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from pykrx import stock\nfrom datetime import datetime, timedelta\n\n# Get today's date and 30 days ago\ntoday = datetime.now().strftime('%Y%m%d')\nstart_date = (datetime.now() - timedelta(days=30)).strftime('%Y%m%d')\n\n# Example: Get OHLCV data for Samsung Electronics (ticker: 005930) for the last 30 days\ndf = stock.get_market_ohlcv_by_date(start_date, today, \"005930\")\n\nprint(f\"OHLCV data for 005930 from {start_date} to {today}:\")\nprint(df.head())\n\n# Example: Get market cap data for KOSPI on a specific date\ndf_cap = stock.get_market_cap_by_date(\"20231026\", \"KOSPI\")\nprint(f\"\\nMarket cap data for KOSPI on 20231026:\")\nprint(df_cap.head())","lang":"python","description":"This quickstart demonstrates how to fetch historical OHLCV data for a specific stock and market capitalization data for KOSPI using `pykrx`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}