Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
NaN's in batch transform output?

Hi,

I see NaNs in the output...shouldn't the batch transform "NaN cleaner" eliminate them?

1970-01-01initialize:13INFOuniverse is 98 to 98.1  
2013-05-06PRINT ----------------------------  
2013-05-06PRINT2013-05-06 14:31:00+00:00  
2013-05-06PRINT ----------------------------  
2013-05-06PRINT Securities  
2013-05-06PRINT[448, 25090, 42788, 23881, 19662, 4922, 1595, 39546]  
2013-05-06PRINT Current prices  
2013-05-06PRINT[ 75.16 75.41 62.62 121.34 55.5 107.82 20.93 61.81]  
2013-05-06PRINT Trailing price window  
2013-05-06PRINT[[ 74.47 74.93 60.79 ..., 107.27 19.84 nan] [ 74.49 74.9899 60.86 ..., 107.41 19.76 60.62 ] [ 74.52 74.98 60.98 ..., 107.53 19.7356 60.66 ] ..., [ 75.25 75.21 62.14 ..., 107.82 19.922 60.94 ] [ 75.24 75.23 62.15 ..., 107.8 19.91 60.95 ] [ 75.16 75.41 62.62 ..., 107.82 20.93 61.81 ]]  

Grant

2 responses

Hello Grant,

Are your NaNs always in the first row?

.....the batch_transform helper will fill in missing
values with the last prior value. As a result, it is still possible
for the first period to have a missing value (there is no prior)"

from https://www.quantopian.com/help#ide-batch-transforms

So only forward filling is used. There should be a flag to enable backfilling as well.

Regards,

Peter

Peter's got it right.

Imagine a stock that starts trading on December 15th. You've got a batch transform that uses a 30-day trailing window. On January 1st, the stock becomes a part of your universe. Batch transform will try to fill the panel back 30 days, but it cannot. It will fill it back to Dec 15 with data, and NaNs for the earlier dates.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.