FinanceDataReader

0.9.110 · active · verified Fri Apr 17

FinanceDataReader is a Python library for retrieving various financial data, including stock prices, stock lists for multiple markets (Korea, US, etc.), and macroeconomic data. It currently supports version 0.9.110 and is actively maintained with frequent updates to adapt to changing data sources and improve functionality.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to fetch stock listings for KOSPI and historical daily prices for specific tickers like Samsung Electronics (005930) and Apple (AAPL) using `FinanceDataReader`.

import FinanceDataReader as fdr
import pandas as pd

# Get a list of KOSPI stocks
kospistock_list = fdr.StockListing('KOSPI')
print(f"First 5 KOSPI stocks:\n{kospistock_list.head()}")

# Get Samsung Electronics (005930) historical prices from 2017 to 2018
df = fdr.DataReader('005930', '2017-01-01', '2018-12-31')
print(f"\nSamsung Electronics prices (2017-2018):\n{df.head()}")

# Get Apple (AAPL) historical prices for the last year
# Using pd.Timestamp.now() for dynamic date calculation
today = pd.Timestamp.now()
oneyear_ago = today - pd.DateOffset(years=1)
apple_df = fdr.DataReader('AAPL', oneyear_ago.strftime('%Y-%m-%d'), today.strftime('%Y-%m-%d'))
print(f"\nApple prices (last year):\n{apple_df.head()}")

view raw JSON →