Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Code question regarding Pipeline data and custom factors

I created a custom factor that calculates a value I use to then screen out stocks via the pipeline method. Maybe this is a silly question, but how can I reference this symbol-specific calculation in the handle data method? I've tried storing the custom factor's output (out[:] ) as a variable (context.Variable), but when I debug the output it gives me something much different than what I hoped for. Any advice is appreciated. Thx

2 responses

I store mine in context as a variable. Perhaps the factor is not doing what you think it's doing? Or, perhaps you are not storing it from the correct source? The approach I take is to define the factor in initialize() and add it to the Pipeline there. Then, in before_trading_start(), I pull it out of the Pipeline output and stuff it into a variable in context. Then, in handle data I can access the values.

Thanks for the reply. I'm realizing I just have no idea how Pandas DataFrames work and am slowly figuring out how to reference and index different things via .loc, .ix, and using "labels" to restrict data to a column etc. I've managed to get my values into a series (?) or list (maybe it's technically not a list since it has labels..) by saying
context.variable = pipeline_output['label I created']
Now I'm just trying to figure out how to make sure I can reference any symbol and find it's value without throwing an index error. I think it's the way I am updating the universe and when. Again, I appreciate your response and the help. I think reviewing Pandas would probably be a good idea for me to do. It's pretty new to me.