Skip to main content

Financial Research Data Services

Project description

frds

FRDS - Financial Research Data Services

LICENSE Code style: black

frds aims to provide the simplest way to compute a collection of major academic measures used in the finance literature.

Getting started by checking out this notebook.

Example usage

Import

We start by importing relevant modules.

Specifically, we import the Funda class from the frds.data.wrds.comp library since the demo uses only the Fundamentals Annual dataset from Compustat via WRDS. We next import the setup and load functions from frds.io.wrds, which are used to configure WRDS credentials and data management for WRDS datasets.

from frds.data.wrds.comp import Funda
from frds.io.wrds import setup, load

(Optional) Setup

Then, set WRDS credentials in case later we need to download from WRDS.

setup(username='username', password='password', save_credentials=True)

Load data

We now download the Funda (Fundamentals Annual) dataset and assign it to the variable FUNDA.

FUNDA = load(Funda, use_cache=True, obs=100)

Compute

Let's now compute a few metrics to showcase how easy it is.

import numpy as np
import pandas as pd
from frds.measures.corporate import roa

pd.DataFrame(
    {
        # We can calculate metrics on the go
        "Fyear": FUNDA.FYEAR,
        "Tangibility": FUNDA.PPENT / FUNDA.AT,
        "Firm_Size": np.log(FUNDA.AT),
        "MTB": FUNDA.PRCC_F * FUNDA.CSHO / FUNDA.CEQ,
        # Or we can use the built-in measures available in FRDS:
        "ROA_v1": roa(FUNDA),
        "ROA_v2": roa(FUNDA, use_lagged_total_assets=True)
    }
).dropna().head(10)

The result would be a nice pd.DataFrame:

Fyear Tangibility Firm_Size MTB ROA_v1 ROA_v2
GVKEY DATADATE
001000 1970-12-31 1970 0.265351 3.510052 2.319803 0.056143 0.065408
1971-12-31 1971 0.260450 3.378611 2.054797 0.004705 0.004126
1976-12-31 1976 0.426061 3.652890 0.899635 0.088996 0.947310
001001 1984-12-31 1984 0.781644 2.789139 1.492970 0.069958 0.080441
1985-12-31 1985 0.567439 3.676174 3.102697 0.065223 0.158357
001002 1970-12-31 1970 0.181825 2.619000 0.499715 0.035490 0.032331
1971-12-31 1971 0.207127 2.495104 0.827517 0.065660 0.058009
1972-12-31 1972 0.166369 2.752131 0.561460 0.057285 0.074074
001003 1983-12-31 1983 0.030015 2.143472 2.311034 0.123109 0.186435
1984-12-31 1984 0.051450 2.109122 1.138268 0.046960 0.138214

Built-in Measures

Check the built-in measures and documentation.

Note

This library is still under development and breaking changes may be expected.

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

frds-0.7.2.tar.gz (65.8 kB view hashes)

Uploaded Source

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