New Feature - Time Series Indicators

Back

Hello everyone,

I am proud to present some of my work in bringing Time Series Analysis into Lean! The TimeSeriesIndicator is a new indicator sub-class allowing for the statistical treatment of data in the framework described by Brockwell and Davis. As a particular implementation of this new class, the AutoRegressiveIntegratedMovingAverage is an indicator which allows you to fit AR, ARMA, and ARIMA models to your data. Most importantly, given that these indicators are fully integrated with the Lean engine, performance is demonstrably fast when compared to pure-Python implementations. Such and more is described in the attached QuantBook (the .ipynb file in the backtest after clicking `</>Code` ).

 

Moreover, the attached QuantBook should provide some useful snippets for anyone wishing to employ these methods in their own work!

 

Happy coding,

Aaron

Update Backtest








 
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Some additional notes:

  1. The rolling forecasts will differ between statsmodels and the Lean implementation due to the fact that Lean uses a two-step fitting procedure whereas statsmodels will fit using maximum likelihood estimation.
  2. The two-step procedure employed by Lean requires that AR is included in the model (that is, such that ARIMA(p,d,q) is such that p > 0)
  3. The tests for TimeSeriesIndicator provides examples on how to use TimeSeriesIndicator methods beyond the scope of ARIMA
1

thank you!

1

Thumbs up!

 

1

Fantastic! Can't wait to give it a spin.

1

This is good work, Aaron. Thanks for sharing. 

1

Aaron this is great stuff.  Do you have any recommendations on how to handle the "Runtime Error: Matrix must be positive definite. (Open Stacktrace)" when the resolution is switched from daily to minute on the algo that you shared? 

0

Jonathan Rogers,

I'd first try increasing the period and see if the additional data results in the required linear dependence to decompose the matrix. If the above does not work, this might suggest that you should try out some different parameters.

https://stackoverflow.com/questions/47115466/matrix-must-be-positive-definite-math-net-c-sharp-library

 

0

Typo: last post should have said "independence".

0

thank you

 

0

This is great! 

0

Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!