I am trying to get an absolute value of the difference in 2 moving averages. You can kind of see what I am trying to do here below.
def make_pipeline():
mean_close_10 = SimpleMovingAverage(
inputs=[USEquityPricing.close],
window_length=10
)
mean_close_20 = SimpleMovingAverage(
inputs=[USEquityPricing.close],
window_length=20
)
latest_close = USEquityPricing.close.latest
vwap = VWAP(window_length=10)
mean_diff = abs(mean_close_20 - mean_close_10)
return Pipeline(
columns={
'10_day_mean_close': mean_close_10,
'VWAP 10': vwap,
'20_day_mean_close': mean_close_20,
'Mean Diff': mean_diff,
'latest_close_price': latest_close
}
)
This produces an error of:
<ipython-input-141-93b21dc74260> in make_pipeline()
---> 15 mean_diff = abs(mean_close_20 - mean_close_10)
TypeError: bad operand type for abs(): 'NumExprFactor'
I am guessing I am trying to get an absolute value for an array or something with a function meant for an individual number but that said I am not sure how I am supposed to get the result (the number displayed as an absolute value)