I've previously written an algorithm that calculates equal-risk weights for a multi-asset portfolio, using standard deviation as a proxy for risk. Now, I'm writing an algorithm that calculates these weights based solely on the downside deviations (lower partial moments). Here's what I've got so far:
def make_pipeline():
base_universe = StaticAssets(symbols('IHI','XLY','TLT'))
Close = USEquityPricing.close.latest.fillna(0)
returns = DailyReturns(inputs=[USEquityPricing.close], window_length=2)
diff = 0 - returns #simplied form for threshold=0
diff = np.clip(diff,a_min=0,a_max=None) Vola = np.sum(diff**2) / len(returns)
pipe = Pipeline(
columns={
'VolFactors' : Close / Vola,
'Closes' : Close,
},
screen=base_universe
)
return pipe
The code works fine all the way through diff.clip operation, but as soon as I add the Vola-defining equation, the pipeline chokes, providing the following error message:
TypeError: f() got an unexpected keyword argument 'out'
I would appreciate any assistance in sorting out the problem in this last, crucial step.