Giter VIP home page Giter VIP logo

wrds's Introduction

wrds: Python Interface for querying WRDS datasets (CRSP, COMPUSTAT)

Author: Eddy (Edwin) Hu

Institution: Rice University

Contact: eddyhu at the gmails

What is it

wrds is a Python package for interfacing with WRDS data (currently local dbs only). It simplifies a lot of the standard data munging activities (querying, merging, cleaning) for CRSP and COMPUSTAT data, and allows the user to quickly access key variables of interest to conduct empirical analyses.

Querying simplified

Suppose you want to pull stock returns and market caps in order to do annual portfolio sorts on size. This is conceptually easy, but involves quite a bit of upfront data munging. wrds does all the data munging and makes accessing the relevant data as easy as:

import sqlalchemy as sa
import wrds
	msf_query = wrds.MSFQuery().query.alias('msf_query')
	q = sa.select([msf_query.c.permno,
               msf_query.c.date,
               msf_query.c.ret_adj,
               msf_query.c.me,
               msf_query.c.vweight])

Which creates a SQL statement:

	SELECT
		msf_query.permno,
		msf_query.date,
		msf_query.ret_adj,
		msf_query.me,
		msf_query.vweight
	FROM ...

the ... is where the magic happens. wrds makes sure that CRSP permnos are correctly lined up with the company names, computes the market cap, adjust returns for delistings, and computes annual buy-and-hold portfolio weights.

Pulling book equity from COMPUSTAT is just as simple:

	funda_query = wrds.FUNDAQuery().query.alias('funda_query')
	q = sa.select([funda_query.c.lpermno,
               funda_query.c.gvkey,
               funda_query.c.datadate,
               funda_query.c.be
               ])

Which creates a SQL statement:

	SELECT
		funda_query.lpermno,
		funda_query.gvkey,
		funda_query.datadate,
		funda_query.be
	FROM ...

wrds merges in CRSP permnos so that the permno-gvkey link is unique, and computes book equity following Fama and French (1993), and Davis, Fama, and French (2000).

Features

  • CRSP Monthly, COMPUSTAT Annual and Quarterly data
    • Aligns accounting fundamentals with market prices
    • Computes delisting returns Shumway (1997)
    • Computes annual buy-and-hold market equity for use as portfolio value weights
    • Convenience functions for accessing Fama-French Factors
  • Computes several anomaly characteristics
    • net stock issuance
    • composie equity issuance
    • total accruals
    • gross profitability
    • net operating assets
    • asset growth
    • investment to assets
    • return on assets
    • Ohlson's O-Score
  • Uses PostgreSQL (via SQLAlchemy) to access/store data
    • Easily configurable for MySQL
  • Returns query results as pandas.DataFrames or record tuples

TO-DO:

  • Implement DSF support
    • basic support added 2014/03/04
    • MOM
    • IVOL
    • BAB
    • CHSDP
  • MSF
    • aggregate market equity by permco

wrds's People

Contributors

edwinhu avatar gaulinmp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.