Hi,
I am relatively new to writing a Quantopian algorithm, please bear with me if I ask something obvious.
I am trying to write a custom factor that takes the USEquityPricing.close
as its input. However, besides the close price, I'd also want to know if the equity being considered is currently held in my positions. Basically, I will use different strategies to calculate the factor value based on whether I hold the equity or not. To do this, I constructed a dictionary that contains all the equities I hold based on context.portfolio.positions
. However, when I try to pass this dict to the custom factor I build
def compute(self, today, assets, out, close, position_info):
it gave me a compile error below
NonPipelineInputs: Unexpected input types in str. Inputs to Pipeline expressions must be Filters, Factors, Classifiers, or BoundColumns.
Got the following type(s) instead: []
It seems the compute
method of a custom factor does not take input of type dict
. Then I tried to make the dict a global variable, again it failed, which I saw a few posts mentioning global variables do not work. My question is, is there a way for me to pass the information to a custom factor?