Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to pass global info solution

I've been having trouble passing info around in my algorithm between methods, but I finally figured something out. I wanted some more info out of my custom factor than just the array value. Here is what worked. Hope it helps. I'm interested to here if there are other ways, or if it helped you.

global info example

ctx = {}

class cust(CustomFactor):

def compute(self, today, asset_ids, out, values):

    for ind in xrange(0, 300)  
          out[ind] = 1  
    ctx['other'] = 14  
3 responses

Be careful with globals and Pipeline. For example, see:

https://www.quantopian.com/posts/feed-current-portfolio-weights-into-pipeline-custom-factor

Pipeline does this batching thing and odd behavior can result if you use globals in a dynamic fashion.

Upvoting like stackoverflow would be productive toward success. I would upvote these.
Imagine if you will, submitted for your approval (this is my Rod Serling impression), Q posts the entire todo list and we vote our priorities.