This repository is the baseline codebase for the coding boot camp. The first
student workflow is simple: open the project in PyCharm, select a Python
interpreter, install the requirements, and run the root main.py file.
Coding_BootCamp/
├── main.py # Demo script to run first
├── requirements.txt # Python package requirements
├── credentials.py # Loads optional environment variables
├── Data/
│ ├── data_definition.py # DataDefinition: one interface for data
│ └── sources/
│ ├── famafrench.py # Fama-French data via requests
│ ├── fred.py # FRED data via requests
│ └── yfin.py # Yahoo Finance data via yfinance
├── Classes/
│ └── MGTF_402/
│ └── Assignment_1.py # Intentionally blank; reserved for exercises
└── Utilities/
└── tools.py # Helper functions for returns and statistics
- Open PyCharm.
- Choose Open and select the
Coding_BootCampproject folder. - Select or create a virtual environment:
- macOS: PyCharm > Settings > Project > Python Interpreter
- Windows: File > Settings > Project > Python Interpreter
- Choose an existing interpreter or create a new virtual environment such as
.venv.
- Open the PyCharm terminal and install the project requirements:
python -m pip install -r requirements.txtThe main packages are:
| Package | Used for |
|---|---|
pandas |
DataFrames and time series |
numpy |
Numerical operations |
scipy |
Summary statistics |
matplotlib |
Plotting |
requests |
Downloading Fama-French and FRED data |
yfinance |
Yahoo Finance market data |
python-dotenv |
Loading optional values from .env |
You do not need a FRED_API_KEY just to open the repo, import most modules, or
work with non-FRED examples. A FRED API key is only needed when you make live
requests to the FRED API, such as pulling the NBER recession series.
If you need live FRED data, create a .env file in the project root:
FRED_API_KEY=your_key_here
Free keys are available from the FRED API documentation.
Run the main.py file at the project root.
In PyCharm, right-click main.py and choose Run 'main'.
From the terminal, run:
python main.pyYou should see progress messages and printed output in the PyCharm Run window
or terminal. The demo is designed to show how DataDefinition, the data source
modules, and the utility functions work together. When the live downloads
succeed, the chart is saved to outputs/ff5_growth_of_dollar.png.
Data/data_definition.py contains the DataDefinition class. This is the main
entry point for requesting data:
from Data.data_definition import DataDefinition
# Fama-French 5-Factor daily data
ff5 = DataDefinition(
source="famafrench",
item="F-F_Research_Data_5_Factors_2x3_daily",
start="2000-01-01",
end=None,
).extract()
# Yahoo Finance closing prices
spy = DataDefinition(
source="yfin",
item="SPY",
start="2000-01-01",
end=None,
).extract()
# FRED data; requires FRED_API_KEY for the live API request
recessions = DataDefinition(
source="fred",
item="USRECD",
start="2000-01-01",
end=None,
).extract()Supported data sources live in Data/sources/:
| Source | Module | Purpose |
|---|---|---|
famafrench |
Data/sources/famafrench.py |
Fama-French factor and portfolio data |
fred |
Data/sources/fred.py |
Federal Reserve Economic Data |
yfin |
Data/sources/yfin.py |
Yahoo Finance prices through yfinance |
Utilities/tools.py contains helper functions used by the demo, including:
compute_levels_from_returnscompute_returns_from_levelsreturn_descriptorconvert_daily_to_weeklygenerate_date_list
Import only what you need:
from Utilities.tools import compute_levels_from_returns, return_descriptorTo add another source later:
- Create a new module in
Data/sources/. - Add the import and routing logic in
Data/data_definition.py. - Use the new source through
DataDefinition(source="your_source", ...).
Keep source modules focused on downloading/parsing data, and keep calculations
in Utilities/tools.py or your exercise files.