macrosynergy.panel.make_blacklist#

Module with functions for processing “blacklist” data for cross-sections in a quantamental DataFrame.

startend(dti, start, length)[source]#

Return start and end dates of a sequence as tuple

Parameters:
  • dti – datetime series of working days

  • start – index of start

  • length – number of sequential days

Return <Tuple[pd.Timestamp, pd.Timestamp]>:

tuple of start and end date

make_blacklist(df, xcat, cids=None, start=None, end=None, nan_black=False)[source]#

Converts binary category of standardized dataframe into a standardized dictionary that can serve as a blacklist for cross-sections in further analyses

Parameters:
  • df (DataFrame) – standardized DataFrame with following columns: ‘cid’, ‘xcat’, ‘real_date’ and ‘value’.

  • xcat (str) – category with binary values, where 1 means blacklisting and 0 means not blacklisting.

  • cids (Lis) – list of cross-sections that are considered in the formation of the blacklist. Per default, all available cross sections are considered.

  • start (str) – earliest date in ISO format. Default is None and earliest date for which the respective category is available is used.

  • end (str) – latest date in ISO format. Default is None and latest date for which the respective category is available is used.

  • nan_black (bool) – if True NaNs are blacklisted (coverted to ones). Defaults is False, i.e. NaNs are converted to zeroes.

Return <dict>:

standardized dictionary with cross-sections as keys and tuples of start and end dates of the blacklist periods in ISO formats as values. If one cross section has multiple blacklist periods, numbers are added to the keys (i.e. TRY_1, TRY_2, etc.)