Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Calculating Macro Factors

Sorry if this is a repeat or it should be obvious but has anyone on Quantopian created custom factors based on macro inputs? USD, yield curve shape, inflation, GDP, etc.?

If anyone can point me in the right direction, it would be most helpful.

Thanks!

3 responses

Should I be searching elsewhere for this?

Thanks in advance!

The problem with the macro economic data is that it's a single value. Factors were originally designed to provide a separate value for a list of assets. With the advent of multiple pipelines, it may be convenient to use a separate pipeline for all the macro data and supply a screen like 'SPY' therefore returning only a single asset with all the associated data values. Anyway, to use the macro data one needs to create a simple custom factor.

# To use the single value datasets (ie ones that don't have a value for each asset)  
# one needs to ceate a simple custom factor

class LatestMacroEconomic(CustomFactor):  
    window_length = 1  
    def compute(self, today, asset_ids, out, values):  
        out[:] = values[-1]

See attached notebook. Good luck.

Thanks very much for the start Dan. Your point is noted about single points in macro, but I was envisioning the factor being "high R^2 to rising inflation" for example. That way each asset would have a separate value for the factor. I will review your notebook and have a crack.

Thanks again for the response.