Exemple #1
0
    def get_factor_data(
        self,
        start_date: dt.date = None,
        end_date: dt.date = None,
        identifiers: List[str] = None,
        include_performance_curve: bool = False,
        category_filter: List[str] = None,
        factor_type: FactorType = None,
        format: ReturnFormat = ReturnFormat.DATA_FRAME
    ) -> Union[List[Dict], pd.DataFrame]:
        """ Get factor data for existing risk model

        :param start_date: start date for data request
        :param end_date: end date for data request
        :param identifiers: list of factor ids associated with risk model
        :param include_performance_curve: request to include the performance curve of the factors
        :param category_filter: filter the results to those having one of the specified categories. \
            Default is to return all results
        :param factor_type:
        :param format: which format to return the results in

        :return: risk model factor data
        """
        factor_data = GsFactorRiskModelApi.get_risk_model_factor_data(
            self.id, start_date, end_date, identifiers,
            include_performance_curve)
        if factor_type:
            factor_data = [
                factor for factor in factor_data
                if factor['type'] == factor_type.value
            ]
        if category_filter:
            if factor_type == FactorType.Category:
                print(
                    'Category Filter is not applicable for the Category FactorType'
                )
            else:
                factor_data = [
                    factor for factor in factor_data
                    if factor['factorCategory'] in category_filter
                ]
        if format == ReturnFormat.DATA_FRAME:
            factor_data = pd.DataFrame(factor_data)
        return factor_data
Exemple #2
0
 def get_factor_data(
     self,
     start_date: dt.date = None,
     end_date: dt.date = None,
     identifiers: List[str] = None,
     include_performance_curve: bool = False,
     format: ReturnFormat = ReturnFormat.DATA_FRAME
 ) -> Union[List[Dict], pd.DataFrame]:
     """ Retrieve factor data for existing risk model
         :param start_date: start date for data request
         :param end_date: end date for data request
         :param identifiers: list of factor ids associated with risk model
         :param include_performance_curve: request to include the performance curve of the factors
         :param format: which format to return the results in
         :return: risk model factor data """
     factor_data = GsFactorRiskModelApi.get_risk_model_factor_data(
         self.id, start_date, end_date, identifiers,
         include_performance_curve)
     if format == ReturnFormat.DATA_FRAME:
         factor_data = pd.DataFrame(factor_data)
     return factor_data