Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
why all my SMA score is NaN

Hi Guys,
I am very new to quantopian and just started to explore basic concept of get_clean_factor_and_forward_returns.
I wrote a very simple sma algorithm (SMA crossing) and trying to find the tear sheet. however, I got some error at end of code. when I debug the code, i found all my SMA is nan, this is very weird. it should have some values and I cannot figure it out even exploring others code.

the code is very simple and naive, i really appreciate for any help or advise.
learning curve for algo trading is quite high and luckly i can find this forum to start with.

million thanks

2 responses

Try to use my_etfs as mask for your SMAs instead of QTradableStocksUS. SPY is not a Stock and thus not in qtu.

Hi Tentor,
thanks a lot for your help. after updating the mask, I got all SMA score!

but when I run the tear sheet, it still shows the exception. looks the exception is not related to SMA score .
any one has ideas?

```

TypeError Traceback (most recent call last)
in ()
----> 1 merged_data = get_clean_factor_and_forward_returns(factor_data, pricing_data)
2
3 create_information_tear_sheet(merged_data)

/venvs/py35/lib/python3.5/site-packages/alphalens/utils.py in get_clean_factor_and_forward_returns(factor, prices, groupby, binning_by_group, quantiles, bins, periods, filter_zscore, groupby_labels, max_loss, zero_aware, cumulative_returns) 837 quantiles=quantiles, bins=bins,
838 binning_by_group=binning_by_group,
--> 839 max_loss=max_loss, zero_aware=zero_aware)
840
841 return factor_data

/venvs/py35/lib/python3.5/site-packages/alphalens/utils.py in get_clean_factor(factor, forward_returns, groupby, binning_by_group, quantiles, bins, groupby_labels, max_loss, zero_aware) 593 factor_copy = factor.copy()
594 factor_copy.index = factor_copy.index.rename(['date', 'asset'])
--> 595 factor_copy = factor_copy[np.isfinite(factor_copy)]
596
597 merged_data = forward_returns.copy()

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''