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: (WRDS login required).
After creating the file, don't forget to run "chmod 0600 ~/.pgpass" in the console to limit access, .
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size wrds_tools-0.0.11-py3-none-any.whl (21.6 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size wrds_tools-0.0.11.tar.gz (9.3 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for wrds_tools-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54f9755c4463718ef8202a5e1d726f94f03c089be2fd08abbb68509a7b61aa6c |
|
MD5 | 055ad3ea9dc9da31466ced5bef74b448 |
|
BLAKE2-256 | 0704cc182a224e328193217c557201e28b1abc89f394e534aff714c6c257daa3 |