Skip to main content

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')

Metadata

Release files for wrds-tools 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wrds-tools 0.0.13
File Size Uploaded Provenance Actions
wrds_tools-0.0.13.tar.gz 9.3 kB Without provenance Details for wrds_tools-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wrds-tools 0.0.13
File Interpreter ABI Platform Actions
wrds_tools-0.0.13-py3-none-any.whl Python 3 none any Details for wrds_tools-0.0.13-py3-none-any.whl

Total release size: 30.9 kB

Release files / wrds_tools-0.0.13.tar.gz

Download URL wrds_tools-0.0.13.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bef7cc1b8b4fd6bde0b89c9848ec87a637a09be8cd5dafdb32724c82ae0418ea
BLAKE2b-256 checksum
How to use checksums
dd81e5340bc60f00e87f0120adb2a6465b7ea13cca2928c55482fba9a3dcd735
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / wrds_tools-0.0.13-py3-none-any.whl

Download URL wrds_tools-0.0.13-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
384fccf01ca94c8cf8534ba748467e6811622f09827e44232796c9baf4bfd836
BLAKE2b-256 checksum
How to use checksums
2c3a6650a8d6986250cc37ff841fdfdab405b9b53f3e3f96ebcb2740c40ba537
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for wrds-tools 0.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page