Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
problem w/ stddev?

It appears that there may be a problem with the stddev transform. For SPY, I compute mavg(15) and stddev(15) and the initial output is:

2013-04-01PRINT 2013-04-01 13:31:00+00:00  
2013-04-01PRINT mavg: 156.6  
2013-04-01PRINT stddev: None  
2013-04-01PRINT 2013-04-01 13:32:00+00:00  
2013-04-01PRINT mavg: 156.635  
2013-04-01PRINT stddev: 0.0494974746826  

Why is stddev returning 'None' for its first value?

Also, I've noticed that sometimes the second tic returns a stddev value of 0.

It bears a bit more testing, but it also appears that the value of stddev ramps up from an initial small value and then stabilizes over ~ 15 days.

--Grant

6 responses

It looks like stddev is returning values even when the number of bars is less than the lookback period. This could cause strange looking results like zero (if all the values are all the same) or an apparent ramp up looking behaviour.

I see the same issue. Especially the function stddev returns None until you have enough days in your backtest

The built-in transforms like mavg and stddev don't have a lookback period. They start "cold" and warm up over the algo. This is different than the batch transform, which is smart enough to know when it is warmed up or not.

  • In the future we'll change the built-in transforms to behave like the batch transform. Batch transform has a better behavior, and it benefits from being built later, with more experience.
  • Paper trading is cognizant of this limitation. Transforms are "warmed up" before an algo goes live in paper trading.
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.

Thanks Dan,

Was there a change at some point? I thought that the built-in transforms would start "warmed up" in the sense that they would look back prior to the start of the algorithm, so that their values would be correct from the start.

Grant

Hello Dan,

I suggest updating your help page, so that the start-up states for transforms (for both backtesting and paper trading) are documented.

Grant

It has always been like that. Built-in transforms were just about the first thing that was built. As we've gone along we've realized that doing automatic warmup is a superior product, but we haven't updated the built-in transforms to the new paradigm. It's on the list.

I'll update the help. It's going through the test server now.