Hi,
I want to calculate number of updays in the past 1 year. I have coded as following using class. But i am not getting what I want. Can you please help me?
After this I also want to calculate the same for last 1 year (252 days) excluding latest month (22 days).
class Positivedays(CustomFactor):
inputs = [EquityPricing.close]
def compute(self, today, assets, out, close):
for i in range(self.window_length-1):
diff = close[i+1]-close[i]
if (diff>0):
updays =+1
out[:] = updays
def make_pipeline(context):
Initialize the pipeline
pipe = Pipeline()
Construct Factors
plusdays = Positivedays(window_length=10)
pipe.add(plusdays, 'plus')