Back to Community
How to get a random alpha factor

I am trying to access the available alpha factors. I have the listof some available factors but I want to combine some of them as random.
The list is a string list, but I want to access that attribute from the Fundamentals class. However, I can't access them with the use of getattr or the eval function because it the systems does not allow it. Is there any way I can access to an alpha factor with its name on a list?

Here is an example of the list I have:

alpha_factors = ['cannaics', 'financial_health_grade', 'growth_grade', 'growth_score', 'morningstar_economy_sphere_code',  
'morningstar_industry_code', 'morningstar_industry_group_code', 'morningstar_sector_code', 'nace', 'naics', 'profitability_grade',
'sic', 'size_score', 'stock_type', 'style_box']

cannaics = getattr(Fundamentals, alpha_factors[0])  

Thank you very much!

2 responses