For the first time, investors can make bets in the safety of regulated exchanges on whether home prices will rise or fall in these shaky times — earning money either way.

Even if a house is “underwater” — that is, in hock for a mortgage higher than the home’s shrinking market value — the novel new Wall Street gamble could be something of a life preserver to help an owner hedge that lopsided predicament.

Think the economy will tank more? Buy a bet home prices will drop further, and collect profits if they fall.

Optimists who bet home prices will rise can reap a payoff, as well.

While it might sound too good to be true, it’s very much a real Wall Street product that went on sale last week from investment firm MacroMarkets at US exchanges to some 20,000 avid followers.

Acclaimed Yale University economist Robert Shiller, and a husband-wife team of veteran Wall Street pros — Diane and Sam Masucci — launched the two new products to give investors a more affordable entrée to hedge housing’s price swings.

“Housing is a $20 trillion market, but it’s hard to get in without buying a house or selling one,” said Sam Masucci, CEO of MacroMarkets.

Backed by US Treasuries and cash from a public offering last year, their price-swing fund offers just two kinds of shares: a bet for an upswing in prices (UMM) and a bet for declines (DMM), both based on actual home sales in the nation’s top 10 metro markets.

The bet’s value rises or falls based on changes in the Case-Shiller Index, a widely respected measure of factual home-sale prices. Shiller, a co-inventor of the Case Shiller Index, is no longer involved in calculating the index.

After their first four trading days, buyers of down-bets were ahead 3 percent, while optimists’ bets lost 8.3 percent.