Skip to main content

Download and process datasets commonly used in finance research

Project description

finsets

Documentation site.

GitHub page.

Install

pip install finsets

How to use

import finsets as fds

or

from finsets import fred, wrds, papers

WRDS

Before you use any of the wrds_ modules, you need to create a pgpass with your WRDS credentials. To do that, run

from finsets.wrds import wrds_api
db = wrds_api.Connection()
WRDS recommends setting up a .pgpass file.
You can create this file yourself at any time with the create_pgpass_file() function.
Loading library list...
Done

This will prompt you for your WRDS username and password. After you enter your credentials, if you don’t have a pgpass file already set up, it will ask you if you want to do that. Hit y and it will be automatically created for you. After this, you will never have to input your WRDS password.

You will still have to supply your WRDS username to functions that retrieve data from WRDS (all of them have a wrds_username parameter). If you don’t want to be prompted for the username for every download, save it under a WRDS_USERNAME environment variable:

  • On Windows, in a Command Prompt:
    • setx WRDS_USERNAME "your_wrds_username_here"
  • On Linux, in a terminal:
    • echo 'export WRDS_USERNAME="your_wrds_username_here"' >> ~/.bashrc && source ~/.bashrc
  • On macOS, since macOS Catalina:
    • echo 'export WRDS_USERNAME="your_wrds_username_here"' >> ~/.zshrc && source ~/.szhrc
  • On macOS, prior to macOS Catalina:
    • echo 'export WRDS_USERNAME="your_wrds_username_here"' >> ~/.bash_profile && source ~/.bash_profile

The functions in the wrds_ modules will close database connections to WRDS automatically. However, if you open a connection manually, as above (with wrds.Connection()) make sure you remember to close that connection. In our example above:

db.close()

Check the wrds_utils module for an introduction to some of the main utilities that come with the wrds package.

FRED

To use the functions in the fred module, you’ll need an API key from the St. Louis FRED.

Get one here and store it in your environment variables under the name FRED_API_KEY

Alternatively, you can supply the API key directly as the api_key parameter in each function in the fred module.

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

finsets-0.0.1.tar.gz (31.0 kB view hashes)

Uploaded Source

Built Distribution

finsets-0.0.1-py3-none-any.whl (29.4 kB view hashes)

Uploaded Python 3

Supported by

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