Hello,
is there any documentation on how to use ARIMA models on securities forecasting? Im trying to build something basic, but im not sure if for instance the self.arima.current.value is a forecast or not, also it seems that the model is not warming up…. The goal would be an ARIMA that updates itself with every bar, and would make a prediction with the stock price.
Best
Álvaro
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
# <summary>
# Regression algorithm to test the behaviour of ARMA versus AR models at the same order of differencing.
# In particular, an ARIMA(1,1,1) and ARIMA(1,1,0) are instantiated while orders are placed if their difference
# is sufficiently large (which would be due to the inclusion of the MA(1) term).
# </summary>
class AutoRegressiveIntegratedMovingAverageRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2021, 10, 1)
self.SetEndDate(2021, 10, 20)
self.EnableAutomaticIndicatorWarmUp = True
self.SetCash(10000000)
self.ticker = self.AddCrypto("BTCUSD",Resolution.Minute)
#self.ticker = self.AddEquity("SPY", Resolution.Daily)
#self.setBenchmark("SPY")
self.arima = self.ARIMA(self.ticker.Symbol, 1, 1, 1, 50)
self.ar = self.ARIMA(self.ticker.Symbol, 1, 1, 0, 50)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
if self.arima.IsReady:
if self.arima.Current.Value > self.Securities[self.ticker.Symbol].Close and self.Portfolio.Invested == 0:
self.SetHoldings(self.ticker.Symbol,1)
elif self.Portfolio.Invested > 0 and self.arima.Current.Value < self.Securities[self.ticker.Symbol].Close:
self.Liquidate()
# if abs(self.arima.Current.Value - self.ar.Current.Value) > 1:
# if self.arima.Current.Value > self.last:
# self.MarketOrder("SPY", 1)
# else:
# self.MarketOrder("SPY", -1)
# self.last = self.arima.Current.Value
#self.Plot('SPY', self.Securities[self.ticker.Symbol].Close)
self.Plot('BTCUSD',self.Securities[self.ticker.Symbol].Close)
self.Plot('AR',self.ar.Current.Value)
self.Plot('ARIMA',self.arima.Current.Value)
Best
Alvaro
Louis Szeto
Hi Álvaro
Indeed the self.arima.Current.Value represents its next rolling forecast. Please check this thread for the details of the ARIMA indicator. It also requires warm-up:
Best
Louis
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.
Álvaro Anton Blanco
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.
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!