Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Futures data.history problem for JY & JE

I am trying to calculate the volatility (standard deviation, ATR) for futures contracts. However I ran into a snag for JY & JE in 2012. The problem is: the results from data.history in a backtest show every day having the same value for a stretch of time, this occurs for over 100 days in the summer of 2012. The actual price did not look like this. It appears that the date is getting truncated to 3 significant digits. What is interesting is that this only happens for days earlier than t-1.

Here is an example where on 2012-09-24 I fetch the last 100 days data for the continuous future JY. (See the attached backtest)

2012-09-24 06:31  PRINT                               close      high       low     price  
2012-09-18 00:00:00+00:00  0.012000  0.012000  0.012000  0.012000  
2012-09-19 00:00:00+00:00  0.012000  0.012000  0.012000  0.012000  
2012-09-20 00:00:00+00:00  0.012000  0.012000  0.012000  0.012000  
2012-09-21 00:00:00+00:00  0.012000  0.012000  0.012000  0.012000  
2012-09-24 00:00:00+00:00  0.012827  0.012835  0.012803  0.012827  
2012-09-24 06:31  PRINT ATRs: {'JE': 0.0, 'JY': 0.0}  
2012-09-24 06:31  PRINT SDs: {'JE': 8.716877585302702e-18, 'JY': 8.716877585302702e-18}  

I take the data from the last 100 days and calculate the ATR and Standard deviation, for many weeks these values are effectively 0.
I remember reading on one post on futures that the values were only displayed to three significant digits, but this was only a display issue. That doesn't seem to be the case as any math on t-1 values shows that there are only three significant digits in there.

Does anyone know why these values are incorrect? If you plot the values of JY in Research you do not get this.

Thanks for the help.

1 response

As far as I can see the data precision for futures prices provided on 'd' level is too low for doing maths with futures. Prices for the continuous futures have the least precision, contracts seem to have 1 decimeter more, but still insufficient. E.g. for JY you will need 6 decimeters.

I have seen posts back on this without any solution. You'll get correct data if you retrieve by "data.history(future_contract, 'open', 60, '1m')" on minute level. However, doing maths for days will not be possible like this. Unless this is fixed any serious algo on some futures won't work (depending on their tick size).

Would be great to know if this issue is planned to be solved any time soon.