SKILL.md
Financial Data Analysis
A practical skill for sourcing, processing, and analyzing financial data in academic research contexts. Covers data acquisition from public APIs, cleaning workflows, and standard analytical techniques used in empirical finance research.
Data Acquisition
Public Financial Data Sources
| Source | Data Type | Access | Python Package |
|---|---|---|---|
| Yahoo Finance | Prices, fundamentals | Free | yfinance |
| FRED (St. Louis Fed) | Macroeconomic indicators | Free (API key) | fredapi |
| SEC EDGAR | Company filings (10-K, 10-Q) | Free | sec-edgar-downloader |
| WRDS (Wharton) | CRSP, Compustat, IBES | University subscription | wrds |
| Alpha Vantage | Real-time and historical prices | Free tier | alpha_vantage |
Fetching Price Data
import yfinance as yf
import pandas as pd
def fetch_stock_data(tickers: list[str], start: str, end: str) -> pd.DataFrame:
"""
Fetch adjusted close prices for a list of tickers.
Args:
tickers: List of ticker symbols (e.g., ['AAPL', 'MSFT'])
start: Start date (YYYY-MM-DD)
end: End date (YYYY-MM-DD)
Returns:
DataFrame with adjusted close prices
"""
data = yf.download(tickers, start=start, end=end, auto_adjust=True)
prices = data['Close'] if len(tickers) > 1 else data[['Close']]
prices.columns = tickers if len(tickers) > 1 else tickers
return prices
# Fetch 5 years of data
prices = fetch_stock_data(['AAPL', 'MSFT', 'GOOGL'], '2020-01-01', '2025-01-01')
print(prices.head())
