Exemple #1
0
    def estimate(self, nparrays: List[np.recarray]):
        """Compute the book leverage

        Parameters
        ----------
        nparrays : List[np.recarray]
            Input datasets, same order as specified in `DATASETS_REQUIRED`

        Returns
        -------
        Tuple[pd.DataFrame, Dict[str, str]]
            Output dataset and the `VARIABLE_LABELS`
        """
        nparray = filter_funda(nparrays[0])
        # debts = long-term debt + debt in current liabilities
        debts = np.nansum([nparray.dltt, nparray.dlc], axis=0)
        # assets = debts + common equity
        assets = np.nansum([debts, nparray.ceq], axis=0)
        # book leverage = debts / assets
        bleverage = np.true_divide(debts, assets, where=(assets != 0))
        # set book leverage to missing if common equity is somehow missing
        bleverage[np.isnan(nparray.ceq)] = np.nan
        # add book leverage to the result
        nparray = rfn.rec_append_fields(nparray, NAME, bleverage)
        # keep only useful columns
        cols = set(rfn.get_names_flat(nparray.dtype))
        nparray.sort(order=(keys := ["gvkey", "datadate"]))
Exemple #2
0
 def estimate(self, nparrays: List[np.recarray]):
     nparray = filter_funda(nparrays[0])
     size = np.log(nparray.at, where=(nparray.at > 0))
     size[np.isnan(nparray.at)] = np.nan
     nparray = rfn.rec_append_fields(nparray, NAME, size)
     # keep only useful columns
     cols = set(rfn.get_names_flat(nparray.dtype))
     nparray.sort(order=(keys := ["gvkey", "datadate"]))
Exemple #3
0
 def estimate(self, nparrays: List[np.recarray]):
     nparray = filter_funda(nparrays[0])
     roa = np.true_divide(nparray.ib, nparray.at, where=(nparray.at != 0))
     roa[np.isnan(nparray.at)] = np.nan
     nparray = rfn.rec_append_fields(nparray, NAME, roa)
     # keep only useful columns
     cols = set(rfn.get_names_flat(nparray.dtype))
     nparray.sort(order=(keys := ["gvkey", "datadate"]))
def estimate(nparrays: List[np.recarray]):
    def filter_funda(x):
        return x[np.in1d(x.datafmt, ('STD')) & np.in1d(x.indfmt, ('INDL'))
                 & np.in1d(x.popsrc, ('D')) & np.in1d(x.consol, ('C'))]

    nparray = filter_funda(nparrays[0])
    capx = np.true_divide(nparray.capx, nparray.at, where=(nparray.at != 0))
    capx[np.isnan(nparray.at)] = np.nan
    nparray = rfn.rec_append_fields(nparray, name, capx)
    # keep only useful columns
    cols = set(rfn.get_names_flat(nparray.dtype))
    nparray.sort(order=(keys := ['gvkey', 'datadate']))
Exemple #5
0
 def estimate(self, nparrays: List[np.recarray]):
     nparray = filter_funda(nparrays[0])
     # market value at fiscal year
     mv = nparray.prcc_f * nparray.csho
     # market-to-book = market value of equity / common equity
     mtb = np.true_divide(mv, nparray.ceq, where=(nparray.ceq != 0))
     # set mtb to missing if common equity is somehow missing
     mtb[np.isnan(nparray.ceq)] = np.nan
     # add book leverage to the result
     nparray = rfn.rec_append_fields(nparray, NAME, mtb)
     # keep only useful columns
     cols = set(rfn.get_names_flat(nparray.dtype))
     nparray.sort(order=(keys := ["gvkey", "datadate"]))
Exemple #6
0
def estimate(nparrays: List[np.recarray]):
    def filter_funda(x):
        return x[np.in1d(x.datafmt, ('STD')) & np.in1d(x.indfmt, ('INDL'))
                 & np.in1d(x.popsrc, ('D')) & np.in1d(x.consol, ('C'))]

    nparray = filter_funda(nparrays[0])
    # debts = long-term debt + debt in current liabilities
    debts = np.nansum([nparray.dltt, nparray.dlc], axis=0)
    # assets = debts + common equity
    assets = np.nansum([debts, nparray.ceq], axis=0)
    # book leverage = debts / assets
    bleverage = np.true_divide(debts, assets, where=(assets != 0))
    # set book leverage to missing if common equity is somehow missing
    bleverage[np.isnan(nparray.ceq)] = np.nan
    # add book leverage to the result
    nparray = rfn.rec_append_fields(nparray, name, bleverage)
    # keep only useful columns
    cols = set(rfn.get_names_flat(nparray.dtype))
    nparray.sort(order=(keys := ['gvkey', 'datadate']))
Exemple #7
0
def estimate(nparrays: List[np.recarray]):

    def filter_funda(x): return x[
        np.in1d(x.datafmt, ('STD')) &
        np.in1d(x.indfmt, ('INDL')) &
        np.in1d(x.popsrc, ('D')) &
        np.in1d(x.consol, ('C'))
    ]

    nparray = filter_funda(nparrays[0])
    # market value at fiscal year
    mv = nparray.prcc_f * nparray.csho
    # market-to-book = market value of equity / common equity
    mtb = np.true_divide(mv, nparray.ceq, where=(nparray.ceq != 0))
    # set mtb to missing if common equity is somehow missing
    mtb[np.isnan(nparray.ceq)] = np.nan
    # add book leverage to the result
    nparray = rfn.rec_append_fields(nparray, name, mtb)
    # keep only useful columns
    cols = set(rfn.get_names_flat(nparray.dtype))
    nparray.sort(order=(keys := ['gvkey', 'datadate']))
Exemple #8
0
    def estimate(self, nparrays: List[np.recarray]):
        """Compute the capital expenditures scaled by total assets

        Parameters
        ----------
        nparrays : List[np.recarray]
            Input datasets, same order as specified in `DATASETS_REQUIRED`

        Returns
        -------
        Tuple[pd.DataFrame, Dict[str, str]]
            Output dataset and the `VARIABLE_LABELS`
        """
        nparray = filter_funda(nparrays[0])
        capx = np.true_divide(nparray.capx,
                              nparray.at,
                              where=(nparray.at != 0))
        capx[np.isnan(nparray.at)] = np.nan
        nparray = rfn.rec_append_fields(nparray, NAME, capx)
        # keep only useful columns
        cols = set(rfn.get_names_flat(nparray.dtype))
        nparray.sort(order=(keys := ["gvkey", "datadate"]))