Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Possible bug in data transform

Pardom my ignorance, but what is a row for the following day doing on my datapanel window with length 1

Code

@batch_transform(refresh_period=1, window_length=1)  
def get_day_prices(datapanel,sid):  
    closePriceSeries= datapanel['close_price'][sid];  
    log.debug('This is a tail of the time series');  
    log.debug(closePriceSeries.tail());  
    log.debug('The last entry close price is '+ str(closePriceSeries[-1]));  
    log.error("Observe the %f is on %s and not on %s" % (closePriceSeries[-1] , closePriceSeries.index[-1].date(), closePriceSeries.index[0].date()));  
    return closePriceSeries[-1];  

Results

2013-03-27get_day_prices:17DEBUGThis is a tail of the time series  
2013-03-27get_day_prices:18DEBUG2013-03-26 20:57:00+00:00    460.97  
2013-03-26 20:58:00+00:00    460.81  
2013-03-26 20:59:00+00:00    460.98  
2013-03-26 21:00:00+00:00    461.13  
2013-03-27 14:31:00+00:00    454.08  
Name: 24  
2013-03-27get_day_prices:19DEBUGThe last entry close price is 454.08  
2013-03-27get_day_prices:20ERRORObserve the 454.080000 is on 2013-03-27 and not on 2013-03-26  
2 responses

Hi Guillermo,

Thanks for sharing your findings, and thank you for probing into the batch transform's behavior.

The reason you are seeing two different dates is that the window_length is measured in days. Since you are testing with minutely data, the batch_transform holds a day of data, but does a rolling update. So, when the first trade of 3/27 arrives, the window stretches back to 3/26. We explain the behavior a bit more in our help docs: https://www.quantopian.com/help#ide-batch-transforms

We chose to have the minute data "roll" with partial days in order to keep the number of data points in a full window as consistent as possible. We cope with weekends and holidays so that the window is really measured in trading days.

I updated your algo a bit to log the head and tail of the window, as well as the full timestamp for the observations. Here's the output:

2013-03-27get_day_prices:17 DEBUG This is a tail of the time series  
2013-03-27get_day_prices:18 DEBUG  
2013-03-26 14:32:00+00:00    463.9425  <<------ first row at 9:32 EST (stamp is UTC)  
2013-03-26 14:33:00+00:00    463.4523  
2013-03-26 14:34:00+00:00    463.1300  
2013-03-26 14:35:00+00:00    463.5000  
2013-03-26 14:36:00+00:00    463.9801  
Name: 24  
2013-03-27get_day_prices:19 DEBUG  
2013-03-26 20:57:00+00:00    460.97  
2013-03-26 20:58:00+00:00    460.81  
2013-03-26 20:59:00+00:00    460.98  
2013-03-26 21:00:00+00:00    461.13  
2013-03-27 14:31:00+00:00    454.08 <<---- last row at 9:31 EST (stamp is UTC)  
Name: 24  
2013-03-27get_day_prices:20 DEBUG The last entry close price is 454.08  
2013-03-27get_day_prices:21 ERROR Observe the 454.080000 is on 2013-03-27 14:31:00+00:00 and not on 2013-03-26 14:32:00+00:00  
End of logs.  

thanks,
fawce

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.

Thank you very much for your quick reply. I am new to quantopian and I don't fully understand how it works, although I find it fascinating.
Love the work you guys are doing
G