Every moving average, RSI line, MACD chart, and backtest begins with the same thing: market data.
Before Python can calculate anything, it needs prices to work with. So the first question in Phase 1 is not “Which indicator should we build?”
It is: How does real market data get into Python?
One simple answer is FinanceDataReader, usually shortened to FDR.
In this lesson, you do not need to download a large dataset or write a long program. First, we will understand what FDR does, what it does not do, and how it connects to the tools you prepared in Phase 0.
1. Start with the Big Picture
Imagine that you want to study Apple stock. Somewhere on the internet, there are historical prices for Apple. Your Python program needs a way to request those prices.
Financial market
↓
online data source
↓
FinanceDataReader
↓
pandas DataFrame
↓
your Python code
↓
chart / indicator / backtest
That is the basic data path we will use in the next several lessons.
Do not worry if some words are still unfamiliar. We will take them one at a time.
2. What Is FinanceDataReader?
FinanceDataReader is an open-source Python package for reading financial data.
Instead of manually visiting a finance website, copying prices, saving a spreadsheet, and then opening that file in Python, FDR lets Python request financial data for you.
Without a data reader
website
↓
copy or download
↓
file
↓
Python
With FinanceDataReader
Python
↓
ask for the data
↓
receive a table
This does not mean FinanceDataReader creates the market data. It acts as a reader that helps your Python program obtain financial data from supported online sources.
3. What Kind of Data Can FDR Work With?
FinanceDataReader supports several kinds of financial data. Depending on the market and data source, these include:
- individual stock prices,
- stock-market listings,
- major market indexes,
- exchange rates, and
- cryptocurrency price data.
For example, the same package can work with identifiers such as:
AAPL → Apple stock
005930 → Samsung Electronics
KS11 → KOSPI index
USD/KRW → U.S. dollar / Korean won
BTC/USD → Bitcoin / U.S. dollar
You do not need to memorize these symbols. The important idea is that different markets use different identifiers, and FDR gives Python a common way to request many of them.
4. Where Does pandas Fit?
FinanceDataReader and pandas do different jobs.
This distinction is important.
FinanceDataReader
= gets financial data
pandas
= organizes and works with the data
Python
= runs the instructions
Visual Studio Code
= where you write and run the code
When FDR brings historical price data into Python, the result is usually stored in a pandas object called a DataFrame.
A DataFrame is simply a table with rows and columns.
Open High Low Close Volume
Date
2025-01-02 ... ... ... ... ...
2025-01-03 ... ... ... ... ...
2025-01-06 ... ... ... ... ...
Later, pandas will help us select columns, calculate values, filter rows, and prepare data for charts and backtests.
For now, just remember:
FDR brings the table in. pandas helps us work with the table.
5. The Two FDR Tools You Will Meet First
FinanceDataReader has many features, but beginners do not need to learn them all at once. We will begin with two.
DataReader()
DataReader() is used when you want historical price data
for a particular symbol.
DataReader(
symbol,
start date,
end date
)
You can read this almost like a sentence:
“Give me the data for this symbol during this period.”
StockListing()
StockListing() is used when you want a list of securities
in a market or exchange.
StockListing("KRX")
You can read this as:
“Show me the stocks in this market.”
These two functions answer different questions:
DataReader()
→ What happened to ONE symbol over time?
StockListing()
→ What symbols are available in a market?
In the next lesson, we will start with DataReader().
StockListing() will come later.
6. Read This Code Before You Run It
Here is a preview of the kind of code you will run in the next lesson:
import FinanceDataReader as fdr
df = fdr.DataReader(
"AAPL",
"2025-01-02",
"2025-01-10"
)
print(df.head())
Do not copy it yet. First, try to read what each part means.
import FinanceDataReader as fdr
→ make FinanceDataReader available in this Python file
"AAPL"
→ the market symbol we want
"2025-01-02"
→ the start date
"2025-01-10"
→ the end date
fdr.DataReader(...)
→ ask FDR for the price data
df
→ store the returned table here
df.head()
→ look at the first five rows
If you can explain those seven lines in plain language, you are ready for the next lesson.
7. Why Not Start with Hundreds of Stocks?
FinanceDataReader can retrieve market listings and can be used in much larger workflows. That is useful, but it is not where we should begin.
If we immediately download thousands of symbols, filter them, calculate indicators, and search for trading opportunities, a beginner may see a lot of code without understanding the data underneath it.
Alphesta will build the workflow in smaller blocks:
one symbol
↓
one price table
↓
understand the columns
↓
draw the data
↓
calculate one indicator
↓
build one rule
↓
test the rule
The code will become larger later. Your understanding should grow first.
8. Why FDR Is a Good Starting Tool
For our first market-data lessons, FDR is useful because the basic workflow is short.
symbol
+
dates
+
DataReader()
↓
market-data table
That lets us focus on market-data concepts instead of spending the first lesson building a complicated data-download system.
Later, you may use other APIs, brokers, databases, or data vendors. That is fine. The important concepts you learn here will still transfer: symbols, dates, rows, columns, prices, missing dates, and data quality.
Check Your Understanding
Before moving on, see whether you can answer these questions without looking back:
- What job does FinanceDataReader do?
- What job does pandas do?
- What is a DataFrame?
- What question does
DataReader()answer? - What question does
StockListing()answer?
You do not need perfect definitions. If you can explain the ideas in your own words, that is enough.
What You Learned
FinanceDataReader
↓
gets financial data
pandas DataFrame
↓
holds the data as a table
DataReader()
↓
gets historical data for a symbol
StockListing()
↓
gets a market listing
You now have the map. In the next lesson, we will actually use it.
Where Do We Go Next?
Next, you will create a new Python file and download your first real market dataset.
We will use one familiar stock, one short date range, and one small table. Then you will change one input yourself and observe what changes.
Next lesson: How to Download Your First Market Data with Python.
← Previous: How to Add Codex to Visual Studio Code
Next lesson: How to Download Your First Market Data with Python