Revisiting barrier bond

In Analyse einer Barriere-Anleihe I was estimating the present value of a barrier bond emitted by Berliner Landesbank, which referred to the stock price of Daimler: The payout would be 100, if the price was either allways above the barrier of 70%, or, if it dipped below the barrier, but closed above the initial price at the maturity of the bond. In every other case, the buyer would get the value of the stock at maturity. For details on the bond, go here.

Using stochastic modelling on a 13 year history of the Daimler stock price, I estimated a present value at offering of 98.6% assuming a risk free rate of 2% for the 2 year maturity (I checked the sensitivity of the result to the risk free rate, but even at a -0.5% the mean present value is at 99.4%, so a slight loss).

Today I wanted to check what the actual payout would have been.

payoutEnd = function(basis, barriere, kurse)
  basis = as.numeric(basis)
  barriere = as.numeric(barriere)
  kurse = as.numeric(kurse)
  if(all(kurse >= barriere))
    res = kurse[1]
  } else if( last(kurse)>basis)
    res = kurse[1]   
  } else 
    res = last(kurse)
## [1] "DAI.DE"

plot of chunk unnamed-chunk-2

Okay, so it seems the price never went below the barrier of 42.462, and the final payout was 100%:

payoutEnd(1,0.7, DAI.DE[,3]/DAI.DE[1,3])
## [1] 1

So, using hindsight, this would have been a good investment given the 7% coupon.

So I finally understood Monty Hall

Lately I have been binge-watching Mythbusters, and one of the more curios myths they took on was the Monty Hall problem. The Monty Hall problem is named after a US TV show, were the candidate had the chance to win whatever price was behind one of three doors, where the other two doors had no price. The twist is that after the candidate choose, the moderator would show what was behind one of the other two doors, obviously one, where no price is, and the candidate now had the chance to switch the door.

Now, intuitively one would say that being shown what is behind a door will not change the chances, and the candidate has a 1 in 3 chance to win the price. Now the myth is, that switching the door will increase the chance to win substantially.

One might say, this is not really a myth, as it can be shown statistically to be true. But I am bad at combinatoric, so after seeing in Mythbusters how far ahead the switching strategy is, I wanted to redo their experiment as a Monte Carlo simulation.

First, we set up the experiment, and sample the winning doors, and the initial selection by the candidate.

# monty hall problem

n = 100000

prices = sample(3,n,1)

selected = sample(3,n,1)

df = data.frame(prices = prices,
                selected = selected,
                shown = NA,
                wins_stay = NA,
                wins_switch = NA)

##   prices selected shown wins_stay wins_switch
## 1      2        1    NA        NA          NA
## 2      3        2    NA        NA          NA
## 3      3        2    NA        NA          NA
## 4      3        2    NA        NA          NA
## 5      1        1    NA        NA          NA
## 6      2        3    NA        NA          NA

Next, we define how the moderator has to choose, which door to show in each case. And this is the first hint to why the likelihood to win is higher if the candidate switches: We need to differ between the cases were the candidate chose the winning door or not, because in the case of the candidate choosing a losing door, the door to be opened by the moderator is predetermined – it’s the one which is not winning.

shown = apply(df, 1, function(x){
  x = unlist(x)

  # x[1] - winning door, x[2] - choosen door
  # candidate choose winning door

  } else {
    return((1:3)[-c(x[1], x[2])])
df$shown = shown
##   prices selected shown wins_stay wins_switch
## 1      2        1     3        NA          NA
## 2      3        2     1        NA          NA
## 3      3        2     1        NA          NA
## 4      3        2     1        NA          NA
## 5      1        1     2        NA          NA
## 6      2        3     1        NA          NA

Next, we calculate the winning likelihood, if the candidate always stays with the initial selection

selected_stay = selected

df$wins_stay = prices == selected_stay
##   prices selected shown wins_stay wins_switch
## 1      2        1     3     FALSE          NA
## 2      3        2     1     FALSE          NA
## 3      3        2     1     FALSE          NA
## 4      3        2     1     FALSE          NA
## 5      1        1     2      TRUE          NA
## 6      2        3     1     FALSE          NA
## [1] 0.33196

It’s not very surprising that the percentage is 1 in 3, which is the initial likelihood without any additional information.

Finally, we have to compute the door the candidate chooses if he switches.

selected_switch = apply(df,1,function(x){
  x = unlist(x)
  (1:3)[!(1:3)%in%c(x[2], x[3])]

df$wins_switch = prices == selected_switch
##   prices selected shown wins_stay wins_switch
## 1      2        1     3     FALSE        TRUE
## 2      3        2     1     FALSE        TRUE
## 3      3        2     1     FALSE        TRUE
## 4      3        2     1     FALSE        TRUE
## 5      1        1     2      TRUE       FALSE
## 6      2        3     1     FALSE        TRUE
## [1] 0.66804

Following the switching strategy, the candidates chances are 2 in 3, which counter-intuitively is quite logical: The candidate will loose in each case where his initial selection was correct (1 in 3), but will win in each case where his initial selection was wrong (2 in 3).

Oh, and here is a nice clip explaining it much better:

What happens with my AAA-rated bond portfolio in the next 30 years?

One question a client asked was how rating migrations would effect their portfolio in the long term, and how to adjust the asset allocation to keep a stable average rating. As a small demo and proof of concept, I wrote a small shiny app. It allows you to adjust the portfolio weights based on the rating categories, the duration of the portfolio, and  the growth rate of the portfolio.

Going off the peg – the Swiss case

So, the Swiss National Bank dropped its peg of the CHF against the EUR of 1.20, to the complete surprise of … well, anbydody, I suppose. As a result, the EUR dropped to lows of 0.975, according to yahoo, and remaining at 0.99 at pixel time.


The Swiss case is different from the normal case of a central bank stopping to defend a peg, because usually it has to defend against a depreciation of its currency, usually by selling its foreign reserves. Of course, such a defense is not sustainable in the long run, as foreign reserves are finite, if the fundamentals favor a depreciation.

Theoretically, these mechanisms have been well understood since the papers from Krugman on currency crises and later by Obstfeld on multiple equilibria, which explain speculative effects in a grey zone of so-so fundamentals, which could, for example, be effected by contagion. The practical results were very visible in the Asian crisis of 1997, and but for the political costs of leaving the EUR, we would have witnessed it in Europe in the last couple of years.

This is a matter close to my heart, as I wrote my diploma thesis on this subject, in an attempt to develop an early warning indicator. But even if that indicator would be still updated, and worked reasonably well, it would have missed the Swiss case – it was looking for depreciations against the central currency. But the SNB defended against appreciation, and theoretically, it should have been able to do so indefinitely, as it could just have kept on selling CHF against EUR.

Another indicator apparently also proved desastrous for a number of retail FX brokers – Value at Risk based on historical volatility. At least one broker declared insolvency, another is talking with regulators and investors about raising fresh capital, a number halted trading CHF. Here is an overview.

With a peg, of course the volatility would decline continously, lowering VaR. This allowed these brokers to decrease the required margin for their retail traders, or increase their leverage, with many brokers requiring only 2% margin. Those trades of course are completely underwater, and unless the traders answer the margin calls, the brokers have serious liquidity shortfall.

So, why did the SNB act like it acted? I can only speculate, of course, but here are some points whih I think are at least noteworthy:

  • While having a positive current account overall, it’s current account with the EU is negative, therefore appreciation would help closing this gap.
  • In a similar way, pegging to the EUR lead to depreciation against the USD and other major currencies, which might have lead to the impression that the pressure to appreciate the CHF against the trade wheighted basket has vanished to a manageable degree.
  • Expectations of European quantitative easing would weaken the EUR further, accelerating the growth of the SNB’s balance sheet, which might have been seen as a political liability.  This I don’t find very convincing, as the SNB is independent from direct government intervention, and a referendum to prescribe a minimum holding of gold as reserves just lost a popular vote, strengthening its independence further.

Bitcoin market mechanism vs money market mechanism

Lateley, i have become interested in the question of the utility of the cryptocurrency bitcoin, especially in relation to traditional currencies like USD or EUR, which I will call fiat currency in the remainder, signifying a currency wich is not commodity based, as is the norm.

TL, DR: Compared to a fiat money economcy, gdp growth in a bitcoin economy is limited by the constant growth rate of the money supply.

In the following, I want to compare the market mechanism of bitcoin in relation to the money market mechanism of a fiat currency.

The analysis is based on following assumptions, first regarding supply and demand of bitcoin

  • Bitcoins are mined by solving mathematical puzzles, which have no further value, the creation of bitcoin is the only source of income for the miners
  • The cost of mining results solely from hardware and energy costs, whose prices move proportionally to the general price index of the economy. Demand from miners is assumed to have no influence on the general price index.
  • The difficulty of the puzzles is instantly adjusted, so that the global increase in the stock of bitcoin is constant.
  • Consumers can freely borrow or save bitcoin at the nominal interest rate
  • The bitcoin is the sole currency used in a small closed economy.

With regard to the fiat currency, I make the following assumptions:

  • Fiat currency is generated by the central bank, which adjusts the supply of money in accordance with a constant rate of inflation.
  • Consumers can freely borrow or save fiat currency at the nominal interest rate
  • The fiat currency is the sole currency used in a small closed economy.

With regard to money demand, I make the following assumptions:

  • Money demand changes proportional to economic activy as measured by gdp growth rate
  • The nominal interest rate increases with an increase in excess money demand.
  • Interest rates adjust instantaniously, price index adjustments are sluggish
  • The price index increases with a increase in excess money supply, and an excess in goods demand.
  • The gdp growth rate increases with a decrease of the real interest rate

Both economies are assumed to be in steady state before an exogene shock to the economy, both money stocks increase at the current gdp growth rate. This shock is an increase in the gdp growth rate following an increase in government spending.

First, the reaction in the bitcoin economy:

  1. Excess goods demand lead to an increase in the demand for bitcoin.
  2. The increase in bitcoin supply is insufficient to satisfy the excess demand, leading to an increase in the nominal interest rate and a decrease of the price index.
  3. Both effects lead to an increase in the real interest rate, leading to a decrease of the gdp growth rate, which leads to a decrease of excess bitcoin demand. This continues until the excess demand for bitcoin is zero, and gdp growth is back to steady state.

Now, the reaction in the fiat currency economy.

  1. Excess godds demands lead to an increase in money demand and increase in price index
  2. Increase in money demand leads to rising nominal interest rates. Increase in price index leads to central bank increasing money supply undtil the excess money demand is zero.
  3. Relative to the starting point, the real interest rate is higher than before, leading to a decrease in gdp growth rate.

In contrast to the bitcoin case, there is no necessety for the gdp growth rate to return to the old steady state, which depends on constant growth of money supply.