Tutorial: WRDS Data Access Via Python API

- 1 min

Prerequisites

Setup

To create .pgpass file

For Mac user, you can create the .pgpass under /Users/username.

wrds-pgdata.wharton.upenn.edu:9737:wrds:your_username:your_password

where your_username is your WRDS username and your_password is your WRDS password.

To restrict file permissions:

chmod 600 ~/.pgpass

Getting Started

Now, you have set up your WRDS profile and can access your WRDS account through the Python API.

import wrds
## provide your username 
db = wrds.Connection(wrds_username='username')

## Here is an example to get DOW daily index value.
db.raw_sql('SELECT date,dji FROM djones.djdaily limit 10')

## Get data from CRSP
crsp = db.raw_sql('select cusip,permno,date,bidlo,askhi from crsp.dsf LIMIT 100')
Johnew Zhang

Johnew Zhang

Researcher

comments powered by Disqus
rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora