Heimstaden, the Swedish real estate owner and developer, has agreed to buy a residential portfolio from Niam for SEK16.6 billion (€1.63 billion) in what is the largest ever real estate transaction in Denmark.