106
8 Time Series
and the 95% confidence level bands around the forecast value ˆ
y i+n are given by
ˆ
y i+n ± 2
σ ( ˆ
y i+n ) 2 .
Inspired by reading about algorithmic trading methods in [7] let us explore the
use of forecasting with a rather contrived example, where we use the day-to-day
returns r d = S d+1 − S d from stock S d on day d, to predict the sign of the return on
the following day d + 1. If the sign is positive, we keep the stock; if it is negative,
we short-sell it. The hope is to turn a loss caused by a falling stock value into a gain.
On the other hand, if the prediction is wrong, we turn the gain from stocks going up
into a loss, because we short sell. We calculate the running tally of our portfolio by
accumulating the “real” return r d+1 with the sign, predicted by the algorithm. To test
it, we used data from Apple Inc. (AAPL) from March 27, 2018 until March 27, 2019,
retrieved from [8], and show the result in Fig. 8.8. The solid black line shows the
evolution of the stock value as it happened during the period. The dot-dashed blue
curve is based on using only data from the last day (m = 1) to forcast the next, which
basically means “if it went up, it will continue to go up.” We observe that it mostly
tracks the black line with little worse results. Especially after day 200 it misses the
rise; likely the algorithm is fooled by small wiggles in the real data. The dashed red
line is based on using the last four days (m = 4) to predict the following day. This
prediction performs rather poor up to day 150, but works reasonably well during
the subsequent 50 days, where the stock value falls. We attribute this to the fact that
the black line with the real data shows moderately systematic oscillations that this
algorithm correctly identified. Varying the horizon m, over which the prediction is
based showed varying results, most om them lying in the range given by the two
examples from Fig. 8.8. Also, testing with other stocks showed great variations. For
stocks with fairly stable changes in their value, m = 1 worked best, but we observe
that the algorithm is badly fooled by random stock motion. This is understandable,
because using a forecasting method implicitly assumes that the underlying dynamics
shows systematic behavior. Thus, if we believe in the efficient market hypothesis
and that the stock evolution is based on a martingale process, we should be unable to
predict tomorrows stock value, based on historic values. We therefore recommend
not to use this algorithm with real money.
Most of the models we encountered so far were autoregressive. But there are more.
8.8 Zoo of Models
In Sect. 8.2 we already addressed MA, AR, and ARMA models, which were defined
through (8.3), (8.6), and (8.7). In this section we will discuss a number of generalizations.
ARIMA
ARMA models with coefficients θ and φ only work satisfactorily if the underlying
process is stationary, rather than having a trend or seasonal variations superimposed.
We already observed and remedied this in Sect. 8.1, where we discussed the CO 2
8 Time Series
and the 95% confidence level bands around the forecast value ˆ
y i+n are given by
ˆ
y i+n ± 2
σ ( ˆ
y i+n ) 2 .
Inspired by reading about algorithmic trading methods in [7] let us explore the
use of forecasting with a rather contrived example, where we use the day-to-day
returns r d = S d+1 − S d from stock S d on day d, to predict the sign of the return on
the following day d + 1. If the sign is positive, we keep the stock; if it is negative,
we short-sell it. The hope is to turn a loss caused by a falling stock value into a gain.
On the other hand, if the prediction is wrong, we turn the gain from stocks going up
into a loss, because we short sell. We calculate the running tally of our portfolio by
accumulating the “real” return r d+1 with the sign, predicted by the algorithm. To test
it, we used data from Apple Inc. (AAPL) from March 27, 2018 until March 27, 2019,
retrieved from [8], and show the result in Fig. 8.8. The solid black line shows the
evolution of the stock value as it happened during the period. The dot-dashed blue
curve is based on using only data from the last day (m = 1) to forcast the next, which
basically means “if it went up, it will continue to go up.” We observe that it mostly
tracks the black line with little worse results. Especially after day 200 it misses the
rise; likely the algorithm is fooled by small wiggles in the real data. The dashed red
line is based on using the last four days (m = 4) to predict the following day. This
prediction performs rather poor up to day 150, but works reasonably well during
the subsequent 50 days, where the stock value falls. We attribute this to the fact that
the black line with the real data shows moderately systematic oscillations that this
algorithm correctly identified. Varying the horizon m, over which the prediction is
based showed varying results, most om them lying in the range given by the two
examples from Fig. 8.8. Also, testing with other stocks showed great variations. For
stocks with fairly stable changes in their value, m = 1 worked best, but we observe
that the algorithm is badly fooled by random stock motion. This is understandable,
because using a forecasting method implicitly assumes that the underlying dynamics
shows systematic behavior. Thus, if we believe in the efficient market hypothesis
and that the stock evolution is based on a martingale process, we should be unable to
predict tomorrows stock value, based on historic values. We therefore recommend
not to use this algorithm with real money.
Most of the models we encountered so far were autoregressive. But there are more.
8.8 Zoo of Models
In Sect. 8.2 we already addressed MA, AR, and ARMA models, which were defined
through (8.3), (8.6), and (8.7). In this section we will discuss a number of generalizations.
ARIMA
ARMA models with coefficients θ and φ only work satisfactorily if the underlying
process is stationary, rather than having a trend or seasonal variations superimposed.
We already observed and remedied this in Sect. 8.1, where we discussed the CO 2
