Which method should I use to predict stock prices (part 1)? Brown’s double exponential smoothing


It’s obviously of interest to be able to predict future stock prices. In this post and a series of posts I will look at different forecasting methods and compare their performances using the one-step-ahead forecast error*.

Method: Brown’s double exponential smoothing
Brown et al.’s** method for forecasting stock prices is described in the appendix. What is important to know is that the method requires a discount factor which must be decided by forecaster. This factor is the emphasizes that is put on the most recent stock price, relative to previous prices, when the future price is predicted. We will try different factors to see which one minimizes the forecast error.

Daily closing prices for all 355 stocks listed on Stockholm OMX, from October 2012 to September 2017, were analyzed.***

Figure 1 shows the mean absolute percentage error (MAPE)**** for different discount factors. It turns out that the error is minimized given a discount factor of 0.4. Then the forecast differs from the actual value by about 2.0 percent each day.


Before we can decide if a 2.0 percent deviation is good or bad we must have another method to compare this performance with. We will look at another method in an upcoming post.

Brown et al. demonstrate that:


The operators are given by:

St(n)(x) = αSt(n-1)(x) + (1 – αSt(n-1) (x),

where α is a discount factor (decided by the forecaster) and

St(0) = xt.

We will use a linear trend model to forecast one-day-ahead-of-day-t stock prices. Such a model has the following form:

xt+1 = at + bt,


at = 2 * St(1)(x) – St(2),
bt = α / (1 – α) * (St(1)(x) – St(2)),

as shown in the article. The smoothing operators require recursive computations and we will use the first value in the time series as initial value:

S0(1) = S0(2) = x0.

*This is the difference between the stock price and the forecast that was made one day before.
**Brown, Robert G., et al. “The Fundamental Theorem of Exponential Smoothing.” Operations Research, vol. 9, no. 5, 1961, pp. 673–687.
***To collect the data I used Web Scraping with Python.
****This is the absolute value of the forecast error divided by the actual price, i.e. the relative forecast error without regard to its sign.


Is it time to sell my Stockholm apartment?

personal finance

I’m currently renting out my Stockholm apartment which earns me a steady profit of about 30 USD per square meter per month. There is talk of a housing bubble in Sweden. Should I sell the apartment or keep renting it out?

Theory and method: Time series analysis and forecasting
Let’s do some time series analysis. Figure 1 shows the average price per square meter in the district where the apartment is located (Svensk Maklarstatistik). It also includes a forecast and a prediction interval which is expected to cover 95% of all possible outcomes*. It can be seen that, thanks to the rent income, the downside is somewhat limited whereas the potential upside is quite large.

Figure 1

How about a housing bubble? Figure 2 shows the difference between supply and demand for new apartments**, the lending rate*** and the average price per square meter relative to the median income in Stockholm 1999-2017 (Statistics Sweden; Sveriges Riksbank). It can be seen that that changes in supply and demand is unlikely to explain the rising prices because there is no clear pattern. However it is striking that the square meter price relative to the median income has almost doubled during the period. Also it is clear that the bank lending rate has fallen significantly. This is a reason for concern because it signals that the higher prices cannot be explained by a higher level of productivity (if one assumes that the median income reflects productivity). Perhaps it’s because the lower lending rates has induced individuals to spend beyond their true/long-term income.

Figure 2

If the recent trend continuous it seems like a safe bet to keep renting out the apartment since the downside is mitigated by the rent income. However I will follow the Central Bank’s interest rate policy very closely. If it decides to increase the interest rate this could very well lead to a scenario where individuals are less inclined to borrow money and spend it on housing. A follow-up analysis would be to investigate the historical average price per square meter relative to median income. Has it been closer to 10% (year 2000 level) or 20% (year 2015 level)?

*The forecast is based on second-order exponential smoothing with a discount factor equal to 0.3 (Montgomery et al. 2008). The prediction interval assumes that the average forecast error is constant and follows a normal distribution.
**New demand is calculated as the population increase times the share of the Stockholm population who lives in apartments (78%) divided by the average household size (3.0 individuals). New supply is the number of newly constructed apartments each year.
***The rate of interest banks pay when they borrow overnight funds from the Central Bank (The Riksbank).

An Optimal Portfolio Among 150 000 Choices

personal finance

Want to maximize returns for a given volatility level (a proxy for risk).

Theory: diversify to reduce risk
The expected return of a portfolio is simply the weighted mean value of the returns of the individual stocks:

Rp = ∑ixiRi

where Ri is the expected return of stock i and xi is the investment in that stock relative to sum of all investments i.e. its weight. The variance of a portfolio is:

Var(Rp) = ∑ijxixjCov(Ri,Rj)

where Cov is the covariance of the returns of stock i and j. To calculate the volatility one takes the square root of the variance.  It is easy to show (e.g. Berk and DeMarzos’ Corporate Finance) that the volatility of a portfolio reaches its maximum when the returns of all stocks are perfectly correlated. Thus, by combining stocks which aren’t perfectly correlated, one could reduce risks. This is called diversification. According to Berk and DeMarzo most of the benefit of diversification can be achieved with about 30 stocks, which is the number of stocks I will include in my portfolio.

Data and method
I downloaded daily returns for about 300 stocks listed on Nasdaq OMX Stockholm using Web Scraping with Python and calculated their monthly returns adjusted for dividend yields (years 2015-2017). A practical problem when one tries to find the best combination of 30 stocks among 300 is that the number of combinations is extremely large: 1.73*10^41 (!). Further, each combination can be varied in infinitely many ways by changing the weights of the stocks. Therefore it is impossible to test all combinations. However it’s possible to do random sampling to have some probability of finding a portfolio that offers a competitive expected return relative to its volatility. I consequently sampled stocks randomly 5 000 times and assigned weights randomly 30 times for each sample, i.e. the total number of tested portfolios was 150 000.

Result and decision: My optimal portfolio based on random samples
Figure 1 shows the outcome of the experiment. The red line crosses the portfolio which has the highest expected return per month, 2.63%, relative to its volatility, 2.74%. This monthly return corresponds to an annual return of  37% and an annual volatility of 38%.

Figure 1.


The best portfolio is quite risky (many of the stocks are growth stocks listed on OMX Small Cap). I will therefore combine it with a risk-free bank deposit which earns me a small return of 0,7% per year (0,058% per month, which is the point where the line cuts the y-axis). My expected return is then:

Rp/rf = Rrf + xp(Rp – Rrf)

where Rrf is the return of the risk-free investment and xp is the share invested in the stock market (note that we will remain on the red line in in Figure 1). I somewhat arbitrary decide to invest two-thirds of my capital in the stock-market and put the rest in the bank deposit. My expected return per month is then 1.77% or 23% per year. The volatility of the risk free investment is, of course, 0% and the remaining volatility is only due to the stocks and is reduced by one-third to 1,83% or 24% year.

The optimal portfolio combines the following stocks (weights within parentheses): Svenska Cellulosa AB B (0.097), Profil Gruppen AB B (0.102), Fingerprint Cards AB B (0.026), Getinge AB B (0.028), Lundin Petroleum AB (0.028), Semafo Inc (0.085), NP3 Fastigheter AB (0.109), VBG GROUP B (0.032), NCC AB B (0.013), Volvo AB B (0.006), Scandi Standard AB (0.028), Industrivärden AB A (0.010), Corem Property Group AB (0.049), Industrivärden AB C (0.045), Bong AB (0.022), Oasmia Pharmaceutical AB (0.006). Nobia AB (0.021), ASSA ABLOY AB B (0.014), Med Cap AB (0.002), Strax AB (0.021), Boule Diagnostics AB (0.010), Svenska Cellulosa AB A (0.011). Öresund Investment AB (0.004), Klövern AB A (0.010), BTS Group AB B (0.015), Ratos AB B (0.011), Husqvarna AB A (0.033), Probi AB (0.003). Hexatronic Group AB (0.158), CTT Systems AB (0.002).

Historical returns are not equal to future returns, the data only covers the last three years, shorting (selling stocks you don’t own) is not considered and potential diversification by buying stocks in non-Swedish markets have not been taken into account. Note that by taking additional random samples my chances of finding a even better portoflio would have been higher.

Currency Speculation Based on Bank Deposits and Exchange rates 1999-2017

personal finance


Is the Swedish Krona (SEK) likely to appreciate (increase in value) relative to the Euro (EUR) when the Swedish Riksbank lowers bank deposit rates? If so I might be able to make a profit by reacting quickly to official statements by the bank.

Theory: A rise in interest rate causes exchange rate movements

The principle of interest parity implies that deposits of two currencies must offer the same expected rate of return. Given expectations regarding future exchange rates and given the offered rates of returns in each currency, it is possible identify the equilibrium exchange rate. If we assume that future expectations remain the same, then a changed rate of return in one currency relative to the other should cause a new exchange rate. This argument is elaborated in e.g. Krugman and Obsfeld’s International Economics.

To test this theory I have collected data on average exchange rates and bank deposit rates per month from 1999 to 2017 (225 observations in total; sources: Statistics Sweden, European Central Bank, Swedish Riksbank). The bank deposit rates are the rates banks may use to make overnight deposits with the Swedish Riksbank and the Eurosystem. If no future exchange rate moments are expected then each time the return on deposits in SEK increases more than return on deposits in EUR, the SEK/EUR exchange rate should decrease. The result is displayed in Figure 1. Indeed the long term trend* is that a greater (SEK-EUR) difference is associated with a lower exchange rate. But the variance is quite large so any conclusions should be drawn with caution.

Exchage rates and difference deposit rates


The exchange rate currently predicted by the trend is 9.51. This value doesn’t differ much from today’s actual value which is 9.54. It might be a bit naïve to assume exchange rate equilibrium and that market actors aren’t already taking into account likely interest changes, but it probably doesn’t hurt to make future investment in accordance with the trend. Especially if one is prepared to react quickly to announcements by the central banks.

*The trend is given by Y = 0.0826*X^2 – 0.2874*X + 9.2133. Where Y is the exchangre rate and X is the difference between the deposit rates. The curve is fitted using a Microsoft Excel’s built-in function.

Why I don’t sell my Katherine Bernhardt painting at auction

personal finance

Financial dilemma

I bought a beautiful Katherine Bernhardt painting in 2008 (for money that I had earned through a summer job). I have now decided to sell the painting to make room for other investments. A dilemma is whether I should sell it back to a gallery, sell it to a private collector or sell it at auction. Also, I must figure out how much to sell it for.


It seems difficult to find a private collector since my personal network contains very few art buyers.

I contacted an auction house which said they were interested in including the painting in their upcoming contemporary art auction. A benefit with an auction house is that that the painting would be well marketed and the price would be set directly by the market, rather than me negotiating with a private collector or a gallery. However the auction house would charge a sales commission of 15% on the hammer price.

I also contacted a gallery (which had exhibited her art in the past) and they were interested in buying the painting. To come up with a reasonable price I looked at web sites like invaluable.com and artsy.net.

My decision

The gallery option seemed most attractive to me since it is very convenient and they would not charge me a commission fee. I offered the painting to them and they accepted my suggested price. They did so without negotiating, which of course made think that I had set the price too low. But I’m still confident that my estimated price is no less than 85% of the “true” market price that would be fetched at auction.

By the way, my profit on this art investment corresponds to a return of 1.8% per year. The value of the 30 most traded stocks at Nasdaq Stockholm, by comparison, have risen by 5.2% per year during the same period. So although I have enjoyed the painting the alternative cost for not making other investments was rather high.

What do you think? Did I make a good decision, please comment.

Should I invest my tuition fee money?

personal finance

Financial dilemma

Should I buy stocks for money that I have saved for paying my upcoming university tuition fee? Currently I lend the money to a large bank which gives me a small return of 0.7 % per year. I want to make sure that I lose no more than 10 % of my savings. The fee is to be paid on 28 January 2018.

Theory: Buy put options to limit risks

If I buy stocks and put options (allows me to sell the stocks at a fixed/strike price) I could limit my risks and perhaps earn a better return. Table 1 shows the stocks I consider buying and the most suitable (American) options contracts. The companies are large Swedish firms in different sectors and all put options expire on Mars 16 2018.

Table 1: Stocks to buy?

Company Spot price (SEK) Strike price (SEK) Option price (SEK)
Ericsson B 45,96 42,00 2,45
ABB Ltd 194,10 180,00 4,75
H&M B 209,10 190,00 8,50
SEB A 102,70 95,00 2,70
Electrolux B 284,60 260,00 10,50

For the investments to make sense e.g. the price of Ericsson B, between Sep 13 2017 (today) and Mars 16, should be expected to rise to about:

45.96*(1.007)^6/12 (alternative cost for no bank return for six months) + 2.45 (price option) = 48.57 SEK

That corresponds to an increase by 5.7 %. Similarly ABB, H&M, SEB and Electrolux must increase by 2.8 %, 4.4 %, 3.0 %, 4.0 %, respectively, which gives an average increase of 4.0 %. Historically (last three years) the stock prices for the largest companies in Sweden have risen by about 2.2 % during each half-year period.

(Note: The increases till 28 January would need to be somewhat smaller than 4.0 % since I would keep any remaining market value if the option is not used at that point. The brokerage fees are marginal in this case.)

My decision

I decided not to buy the stocks since this rough analysis shows that the expected return from the stock market isn’t enough to compensate for the costs associated with buying the put options.

More theory can be found in: John C. Hull’s Options, Futures and Other Derivatives (6th Edition)