Back to Community
Trouble Building Custom Factors that Return Strings

Hey all,

I am trying to write a custom factor that uses MorningStar Fundamnetal data, and I am consistantly getting a TypeError. The financial health grade outputs a string, and I am trying to output that string and then add the factor to the universe. When I try explicitly setting the dtype to string, as shown below, I get the error: UnsupportedDataType: FinancialGrade instances with dtype |S0 are not supported. When I do not set it explictly, when I run_pipeline, I get this error:

TypeError: Don't know how to construct AdjustedArray on data of type
does someone know what is going on here?


class FinancialGrade(CustomFactor):  
     inputs = [morningstar.asset_classification.financial_health_grade]  
     window_length = 45  
     dtype ='|S0'  

     def compute(self,today,assets,out,volume,grade):  
          out[:] = grade[-1]  
5 responses

Hi Marcus,

The following paragraph from our help docs might help here:
"The Pipeline API only currently supports loading columns that can be coerced to floating-point values. This means that we currently support loading columns whose database representation is either an integer, a boolean, or a float. Notably, this means that we do not yet support datetime or str columns. We expect to remove this restriction in a future update."

I should add that there is a current issue with loading integer and boolean types in Pipeline as well, but we are currently working to fix it. As well, it's on our list to add support from loading string columns. For now, they can only be loaded using a get_fundamentals query.

I hope this helps.


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Ok Thanks Jamie !

You could of course just map the rating strings to a numeric scale in your factor.

Simon, could you explain how to "map the rating strings to a numeric scale in your factor." Thanks

One-and-a-half years later, CustomFactor output is still restricted to values that can be coerced to a floating point value.