Skip to main content

Various tools to create a connection to the WRDS service and download commonly used data.

Project description

Wrds Tools

Tools for accessing compustat variables through WRDS by name.

Setup

To build a connection to the wrds server via python, a .pgpass file is required in the user's home directory, with access limited to the user. To create this file, follow the instructions here: How to access WRDS through Python (WRDS login required).

After creating the file, don't forget to run "chmod 0600 ~/.pgpass" in the console to limit access, as also described here.

Using package directly from github

Install import_from_github_com from your terminal to use this package directly from github.

pip3 install import_from_github_com

Or use your package manager (e.g., Conda).

Now you can use Wrds Tools by importing it from github.

import wrds
from github_com.julianbarg import wrds_tools

Example

Build a connection to WRDS.

wrds = wrds_tools.WrdsConnection()
Loading library list...
Done

Download all S&P 500 constituents from between 2002-2007.

from datetime import date

wrds.set_observation_period(start_date=date(year=2002, month=1, day=1), 
                            end_date=date(year=2007, month=12, day=31))
wrds.build_sp500()
wrds.add_names()
sp500 = wrds.return_dataframe()

Save your sample to a .csv and excel file.

sp500.to_csv('sp500.csv')
sp500.to_excel('sp500.xlsx')

Run custom wrds queries.

db = wrds.db

KLD_ratings = db.get_table('kld', 'history')

# get some basic financials
funda = db.raw_sql('select GVKEY, FYEAR, FIC, REVT, SALE, EMP, GP, CURCD from compa.funda')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wrds_tools-0.0.8.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

wrds_tools-0.0.8-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file wrds_tools-0.0.8.tar.gz.

File metadata

  • Download URL: wrds_tools-0.0.8.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for wrds_tools-0.0.8.tar.gz
Algorithm Hash digest
SHA256 7b7398bef431024fa57a24e8bb411712b2c10459e07a659dfabdfbd84e81b1ca
MD5 02958e48ad315c4a072d0a274cb9b61f
BLAKE2b-256 1c28c2b80537e84028b7c8fe44ec847a98520048f2d1927f252152b179f4df11

See more details on using hashes here.

File details

Details for the file wrds_tools-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: wrds_tools-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for wrds_tools-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7c363da64d11872afca3cfba99dbc12f379a1a47909606a30d12594ddc2d7125
MD5 97e4251ddcb215d3d0015ae6ef5ef08e
BLAKE2b-256 9e5983e197c86bd3623319db8564f5d538c1d41730e4a8c89869b9479798e124

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page