Install FinanceDataReader via pip
masterInstall the latest version of finance-datareader using pip:
pip install -U finance-datareaderrepository·master·Indexed 23 days ago
https://github.com/financedata/financedatareaderAn open-source financial data reader (crawler) for fetching stock listings, historical prices, indexes, exchange rates, and cryptocurrency data. It provides a Python API featuring DataReader, StockListing, and SnapDataReader, as well as a CLI tool ('fdr') for querying data in CSV, JSON, and Markdown formats. Supported sources include KRX, NASDAQ, NYSE, Yahoo Finance, and FRED.
Install the latest version of finance-datareader using pip:
pip install -U finance-datareaderIf you are in an environment with restricted network access (e.g., firewall or air-gapped system), download the .whl files from the GitHub dist directory and install them locally:
pip install finance_datareader-x.x.x-py3-none-any.whlWhen retrieving price data, the format of the identifier depends on the market:
Use the 6-digit short code.
'005930' (Samsung Electronics), '215600' (ShinlaGen).fdr.StockListing('KRX').Use the Ticker symbol.
'AAPL' (Apple), 'AMZN' (Amazon), 'GOOG' (Google).fdr.StockListing('NASDAQ').You can install FinanceDataReader using pip or uv.
Using pip:
pip install finance-datareaderUsing uv: To add it as a project dependency:
uv add finance-datareaderTo install it as a global CLI tool:
uv tool install finance-datareaderThe fdr command allows you to query financial data directly from your terminal.
Run without installation (using uvx):
uvx --from finance-datareader fdr price AAPL --start 2024Run after installing via uv tool:
uv tool install finance-datareader
# Then use the 'fdr' command directlyIf you want to avoid direct requests to KRX and instead use pre-cached CSV data from the fdr_krx_data_cache repository, use the following classes:
KrxMarcapListingCache(market): Cached market capitalization and listing data.KrxStockListingCache(market): Cached descriptive information.KrxDelistingCache(market, start, end): Cached delisting data.The NaverSnapReader class allows querying specific Naver-based data using a specialized ticker string format.
Ticker Formats:
Financial Statements: NAVER/FINSTATE[/options]/CODE
- separator.fin_type options: 0, 1, 2, 3, 4.freq options: Y (Year), Q (Quarter), A (All).NAVER/FINSTATE/005930, NAVER/FINSTATE-Q/005930, NAVER/FINSTATE-Q1/005930.Investor Trends: NAVER/INVESTORS/CODE
NAVER/INVESTORS/005930.Use fdr.StockListing(symbol) to retrieve a list of all stocks currently listed on a specific exchange. The function returns a pandas DataFrame containing the stock information.
Available exchange symbols include:
| Symbol | Exchange | Notes |
|---|---|---|
KRX | KRX Total | Includes KOSPI, KOSDAQ, and KONEX |
KOSPI | KOSPI | |
KOSDAQ | KOSDAQ | |
KONEX | KONEX | |
NASDAQ | NASDAQ | |
NYSE | NYSE | |
AMEX | AMEX | |
S&P500 | S&P 500 | Components of the S&P 500 index |
SSE | Shanghai Stock Exchange | |
SZSE | Shenzhen Stock Exchange | |
HKEX | Hong Kong Stock Exchange | |
TSE | Tokyo Stock Exchange | |
HOSE | Ho Chi Minh City Stock Exchange | |
ETF/KR | Korean ETFs |
Use fdr.DataReader(symbol, start_date, end_date) to retrieve historical price data for stocks, indices, commodities, currencies, and cryptocurrencies.
Supported data types include:
KS11), KOSDAQ (KQ11), Dow Jones (DJI), S&P500 (S&P500), etc.'005930'), US stocks (e.g., 'AAPL').CL=F), Gold (GC=F), etc.'USD/KRW') and Cryptocurrencies (e.g., 'BTC/USD').'FRED:M2').You can fetch multiple symbols at once by providing a comma-separated string.
Use fdr.SnapDataReader(path) to fetch non-time-series data such as index constituents or financial statements.
Index Constituents:
KRX/INDEX/LIST: List of all KRX indices.KRX/INDEX/STOCK/{index_code}: List of stocks within a specific index (e.g., 'KRX/INDEX/STOCK/1001' for KOSPI).Financial Statements (via NAVER):
NAVER/FINSTATE/{symbol}: Annual financial statements.NAVER/FINSTATE-Q/{symbol}: Quarterly financial statements.-1Y, -2Y, -3Y, -4Y for specific years or K-IFRS/K-GAAP variations (e.g., NAVER/FINSTATE-1Y/005930).Use fdr.StockListing(market) to retrieve lists of available stocks and indices for various markets. This is useful for discovering symbols.
Supported markets:
'KRX', 'KOSPI', 'KOSDAQ', 'KONEX'. Use -DESC suffix (e.g., 'KRX-DESC') for descriptive lists including funds.'KRX-DELISTING' (delisted stocks), 'KRX-ADMIN' (managed stocks).'S&P500', 'NASDAQ', 'NYSE'.'SSE' (Shanghai), 'SZSE' (Shenzhen), 'HKEX' (Hong Kong), 'TSE' (Tokyo), 'HOSE' (Ho Chi Minh).'ETF/KR' for Korean ETFs.Use fdr.DataReader(symbol, start, end) to fetch historical price data. The symbol can be a stock ticker (e.g., 'AAPL', '068270'), an index (e.g., 'KS11', 'DJI'), a currency pair (e.g., 'USD/KRW'), or a cryptocurrency (e.g., 'BTC/KRW').
If end is not provided, it defaults to the current date.
import FinanceDataReader as fdr
# 애플(AAPL), 2017-01-01 ~ 현재
df = fdr.DataReader('AAPL', '2017')
# 셀트리온(068270), 2017-01-01 ~ 2018-05-30
df = fdr.DataReader('068270', '2017-01-01', '2018-05-30')
# KS11 (KOSPI 지수), 2015-01-01~현재
df = fdr.DataReader('KS11', '2015')
# 다우지수, 2015년~현재
df = fdr.DataReader('DJI', '2015-01-01')
# 원달러 환율, 1995-01-01 ~ 현재
df = fdr.DataReader('USD/KRW', '1995')
# 비트코인 원화 가격 (빗썸), 2016년~현재
df = fdr.DataReader('BTC/KRW', '2016')