Even as the slump in China threatens to pitch Germany, Europe and much of the rest of the world into recession, authorities in Berlin are boasting about a budget surplus that is the polar opposite of what a responsible government should be doing.

Germany trumpeted the news this week that not only did it register a budget surplus last year, but it was an “historic” one — twice as big as forecast at 12 billion euros and the biggest-ever postwar surplus.

Moreover, Finance Minister Wolfgang Schäuble is planning to keep a balanced budget for the next several years, even though a fiscal stimulus in the form of deficit spending could head off or at least mitigate a potential recession.

Germany continues to defy the urgent recommendations of international organizations, European allies and most every economist outside the country to run a budget deficit, especially at a time when investors are practically willing to pay the Berlin government to take their money.

Instead, Schäuble and his minions insist on pedaling their 19th-century single-speed bicycle in a high-speed 21st-century global economy.

After forcing austerity policies on euro members that have torn apart the European Union, Berlin still considers its model of unbending fiscal rectitude as part of its civilizing mission to the rest of the benighted world.

The blinkered approach continues even though Germany is getting hit the hardest by the worsening slowdown in China and will show only minimal growth while the rest of Europe could sink again into recession.

British bank RBS startled markets this week with a recommendation to sell everything except high-quality government bonds in the face of a looming crisis that could take on catastrophic proportions.

RBS economist Andrew Roberts forecast global equities down 10% to 20%, the oil price plunging further to $26 a barrel and possibly as low as $16, and a collapse in commodities and emerging markets that together would create a deflationary spiral and a crisis on the order of 2008.

Berlin authorities tried to make news of the budget surplus more palatable by saying they would use the windfall to pay for the influx of refugees into the country — though the 12 billion euros only begins to cover the estimated 25 billion to 55 billion euro tab for settling more than a million migrants.

In the meantime, urgent infrastructure and social investments needed in Germany go unfunded so that Schäuble can take his place in history as the man who balanced the budget, whatever the cost.

Industrial production, the motor of the German economy, fell 0.3% month-on-month in November and was unchanged year-on-year. Consumer confidence, which had been steadily declining since June, stabilized in December and January, but the impact of the refugee crisis — especially the New Year’s attacks in Cologne — may take its toll going forward.

The government touted the 1.7% economic growth in 2015 as proof of the German economy’s resilience, but the BGA trade group in Berlin cautioned last week that a hard landing in China could push Germany into recession.

In a gloomy forecast about the possibility of global recession this year, MarketWatch contributor Satyajit Das warned this week that no one should believe that China’s economy is really growing at a 6% to 7% annual rate.

“Official growth does not reconcile to underlying individual statistics such as trade, investment, consumption or real production,” Das wrote. “With China contributing around one-third to half of global growth annually, a deceleration in Chinese demand hurts the 40 or so countries that count China as their biggest export customer.”

On top of everything else, Das notes, the Volkswagen CH:VW emissions scandal raises doubts about Germany’s vaunted technical prowess.

In short, all the self-congratulatory backslapping in Berlin should be taken with a grain of salt.

This week’s German-bashing headline in Britain’s Daily Express — “Europe on the brink of financial MELTDOWN as Germany faces economic ruin” — may seem a bit extreme, but the picture is hardly as rosy as mainstream reporting indicates.

Pride, as the proverb says, goes before a fall.