WRDS (Wharton Research Data Services)#

WRDS is the gold standard for academic financial research. It provides access to dozens of research databases used in peer-reviewed finance and accounting research.

What is WRDS?#

WRDS is a data platform maintained by the Wharton School at the University of Pennsylvania. It hosts:

  • CRSP - Stock prices, returns, and market data back to 1926

  • Compustat - Financial statements for public companies

  • IBES - Analyst earnings forecasts

  • TAQ - High-frequency trade and quote data

  • Thomson Reuters - Institutional holdings (13F filings)

  • And many more…

Access Requirements#

Warning

WRDS access typically requires institutional affiliation. Check if your university has a subscription.

If Elon University has WRDS access:

  1. Go to wrds-www.wharton.upenn.edu

  2. Click “Register” and use your Elon email

  3. Your account will be linked to Elon’s subscription

Set-up#

Install the WRDS Python library:

pip install wrds

Connecting to WRDS#

import wrds

# First time: will prompt for username/password
# Creates a .pgpass file for future connections
db = wrds.Connection()

After your first connection, credentials are stored locally and you won’t need to enter them again.

Exploring Available Data#

# List available libraries (databases)
db.list_libraries()

# List tables in a library
db.list_tables(library='crsp')

# Describe a table's columns
db.describe_table(library='crsp', table='dsf')

Example: CRSP Stock Data#

CRSP (Center for Research in Security Prices) contains the most comprehensive historical stock data available.

Daily Stock File (DSF)#

# Query daily stock data
query = """
SELECT permno, date, prc, ret, vol, shrout
FROM crsp.dsf
WHERE permno = 14593  -- Apple
AND date BETWEEN '2023-01-01' AND '2023-12-31'
"""

aapl = db.raw_sql(query)
aapl.head()

Key CRSP Variables#

Variable

Description

permno

Permanent security identifier

date

Trading date

prc

Closing price (negative = bid/ask average)

ret

Holding period return

vol

Trading volume (shares)

shrout

Shares outstanding (thousands)

Example: Compustat Financial Data#

Compustat contains accounting data from financial statements.

# Query annual financial data
query = """
SELECT gvkey, datadate, conm, at, sale, ni, ceq
FROM comp.funda
WHERE tic = 'AAPL'
AND datafmt = 'STD'
AND indfmt = 'INDL'
AND consol = 'C'
AND popsrc = 'D'
ORDER BY datadate
"""

aapl_financials = db.raw_sql(query)

Key Compustat Variables#

Variable

Description

gvkey

Global company key

at

Total assets

sale

Net sales/revenue

ni

Net income

ceq

Common equity

Merging CRSP and Compustat#

A common task is linking stock returns (CRSP) to financial data (Compustat). WRDS provides a linking table:

# CRSP-Compustat merged data
query = """
SELECT a.permno, a.date, a.ret, b.at, b.ni
FROM crsp.dsf a
INNER JOIN crsp.ccmxpf_linktable l
    ON a.permno = l.lpermno
INNER JOIN comp.funda b
    ON l.gvkey = b.gvkey
WHERE ...
"""

Resources#

Note

This section will be expanded with working examples once WRDS access is confirmed. Check back for updates!