I am new to coding and can't figure out why I am getting this build error. I am writing an algorithm that first filters out low liquidity and penny stocks to get my starting universe. Then I sort by market cap and take the first 3000 stocks. Next, I am trying to sort the remaining 3000 stocks by a custom factor: cash flow to total assets to get down to the 1000 with the highest cash flow to total assets. I will then sort by other factors. However, I cannot seem to make the cash flow to total assets sort work. I keep getting the error message:
UnboundLocalError: local variable 'CFTA' referenced before assignment. It is referring to this line of code:
CFTA = CFTA()
pipe.add(CFTA, 'CFTA')
I copy & pasted the code section to a notebook, because it doesn't format properly when I paste it as text.
I'm sure its a pretty simple fix, I just can't figure it out. Thanks in advance.