Skip to main content

Financial Research Data Services

Project description

frds

FRDS - Financial Research Data Services

LICENSE PyPIDownloads Code style: black

frds is a Python framework that aims to provide the simplest way to compute a collection of major academic measures used in the finance literature, one-click with a Graphical User Interface (GUI).

GUI

Supported Measures

The built-in measures currently supported by frds are as below. New measures will be added to frds gradually and can be easily developed following a template shown in Developing New Measures.

Firm Characteristics

  • Accounting Restatements
    • Number of various accounting restatements during the past (n) fiscal year.
    • Source: wrds.comp.funda, wrds.audit.auditnonreli.
  • Asset Tangibility
    • Property, Plant and Equipment (Net) scaled by total assets.
    • Source: wrds.comp.funda.
  • Board Independence
    • Board size and independence measured as the ratio of independent board members to board size.
    • Source: wrds.funda, wrds.boardex.na_wrds_company_profile, wrds.boardex.na_wrds_org_composition.
  • Book Leverage
    • Amount of debts scaled by the firm's total debts plus common equity.
    • Source: wrds.comp.funda.
  • Capital Expenditure
    • Capital expenditures scaled by total assets.
    • Source: wrds.comp.funda.
  • Credit Rating
    • S&P credit rating.
    • Source: wrds.ciq.erating, wrds.ciq.gvkey.
  • Executive Ownership
    • Various measures of executive stock ownership.
    • Source: wrds.comp.funda, wrds.execcomp.anncomp.
  • Firm Size
    • Natural logarithm of total assets.
    • Source: wrds.comp.funda.
  • Market-to-Book Ratio
    • Market value of common equity to book value of common equity.
    • Source: wrds.comp.funda.
  • ROA
    • Income before extraordinary items scaled by total assets.
    • Source: wrds.comp.funda.
  • ROE
    • Income before extraordinary items scaled by common equity.
    • Source: wrds.comp.funda.
  • Stock Delisting
    • Stocks delisted due to financial troubles or as a result of being merged.
    • Source: wrds.crsp.dse.

Bank Holding Company (BHC) Characteristics

Installation & Configuration

frds requires Python3.8 or higher. To install using pip:

$ pip install frds

After installation, a folder frds will be created under your user's home directory, which contains a data folder, a result folder and a default configuration file config.ini:

[Paths]
base_dir: ~/frds
data_dir: ${base_dir}/data
result_dir: ${base_dir}/result

[Login]
wrds_username: 
wrds_password: 

You need to enter your WRDS username and password under the login section.

Usage

To start estimating various measures, run frds as a module:

$ python -m frds.gui.run

Alternatively, run without GUI to estimate all measures with default parameters:

$ python -m frds.run

You can also use the following example to use frds programmatically.

from frds import Professor
from frds.measures import AccountingRestatement, ROA, FirmSize

measures = [
    AccountingRestatement(years=1),
    AccountingRestatement(years=2),
    ROA(),
    FirmSize(),
]

config = dict(
        wrds_username="your_wrds_username",
        wrds_password="you_wrds_password",
        result_dir="path/to/where/you/want/to/store/the/result/",
        data_dir="path/to/where/you/want/to/store/the/data/",
    )

if __name__ == "__main__":
    with Professor(config=config) as prof:
        prof.calculate(measures)

The output data will be saved as STATA .dta file in the result folder.

For example, below is a screenshot of the output for frds.measures.AccountingRestatement.

result

Developing New Measures

New measures can be easily added by subclassing frds.measures.Measure and implement the estimate function, as shown in the template below. The best working example would be frds.measures.ROA.

from typing import List
import numpy as np
import pandas as pd
from frds.measures import Measure
from frds.data import Dataset

DATASETS_REQUIRED = [
    Dataset(source='wrds',
            library="comp",
            table="funda",
            vars=[
                "datadate",
                "gvkey",
                "at",
                "ib",
            ],
            date_vars=["datadate"],
    )
]
VARIABLE_LABELS = {}

class NewMeasure(Measure):
    
    def __init__(self):
        # Note: `name` will be used to name the result dataset. 
        # So this will lead to a `New Measure.dta` in the `result` folder.
        # If the new measure contains custom parameters, please also implement
        # the `__str__()` function to differentiate
        super().__init__(name="New Measure", datasets_required=DATASETS_REQUIRED)

    def estimate(self, nparrays: List[np.recarray]):
        # do something with nparrays and produce a `result` pandas DataFrame
        # ...
        assert isinstance(result, pd.DataFrame)
        return result, VARIABLE_LABELS

Then to estimate NewMeasure:

from frds import Professor

measures = [
    NewMeasure(),
]

config = dict(
        wrds_username="your_wrds_username",
        wrds_password="you_wrds_password",
        result_dir="path/to/where/you/want/to/store/the/result/",
        data_dir="path/to/where/you/want/to/store/the/data/",
    )

if __name__ == "__main__":
    with Professor(config=config) as prof:
        prof.calculate(measures)

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.4.0rc4.tar.gz (32.9 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