ANY American who bought a top-of-the-range Maytag Maxima front-loading washing machine a few years ago contributed in his own small way to the country’s persistent trade deficit; the machine was made in Germany. Not so anyone who has bought one in the past six months, because Whirlpool, the manufacturer, has since moved production to a plant in Clyde, Ohio.

That shift helps explain a remarkable improvement in America’s external accounts. At the end of 2005 the current-account deficit reached 6.2% of GDP, the sign of a society living dangerously beyond its means. But by the third quarter of 2013 it had dropped to 2.2%, the lowest since 1998, a level it could easily sustain indefinitely.

The deficit has narrowed, in part, thanks to a rising surplus in investment income and growth in the traditional surplus in services trade, such as royalties. But the biggest factor has been the deficit in trade in goods, which has shrunk by 2.2% of GDP. In previous expansions the deficit widened as the domestic appetite of households and businesses for foreign-made stuff outpaced exports. This time, though exports and imports both fell during the recession, exports rebounded more strongly, exceeding 9% of GDP in the third quarter (above pre-recession levels), whereas imports have stabilised around their prerecession level, just below 14% of GDP.

David Woo, a currency and bond strategist at Bank of America Merrill Lynch, thinks three distinct factors are at work. One is the surge in domestically produced oil and gas from shale-rock formations. Americans produced 70% of the energy they consumed in 2008; that has since risen to 89%. Another factor is demographics. As baby-boomers age they spend less on goods, many of them imported, and more on services, which are mostly produced at home. Mr Woo reckons that medical care, recreation, restaurant meals and hotels now take up almost 27% of household budgets, up from 25% six years ago.