I'm trying to remove the Nan and Inf values in sentiment_score. However I get error values when I run it.
My code snippet:
sentiment_score = SimpleMovingAverage(
inputs=[stocktwits.bull_minus_bear],
window_length=20,
mask=QTradableStocksUS()
)
...
return Pipeline(
columns = {
'yesterday_close' : yesterday_close,
'yesterday_open' : yesterday_open,
'sentiment_score' : sentiment_score
},
screen = base_universe | sentiment_score.notnull() | sentiment_score.notnan() | sentiment_score.isfinite()
)
...
objective = opt.MaximizeAlpha(buy_these.sentiment_score )
ValueError: NaN or Inf values provided to MaximizeAlpha for
argument 'alphas'. Keys with NaNs: Equity(47578 [LTRP_A]),
Equity(48390 [UE]), Equity(49204 [CABO]), Equity(49883 [LSXM_K]) Keys
with Infs: None There was a runtime error on line 163.
Is there another way to remove the Nan ?