The nationwide median price of a home has eclipsed its pre-recession peak. The number of distressed properties available for purchase across the country has steadily dwindled. Construction costs, meanwhile, have increased sharply in recent years, as labor and materials have become pricier.

A sign of a strengthening economy? Absolutely. A potential problem for house flippers? Yes, that, too.

In the third quarter of last year, the average gross profit that a property flipper received tumbled nationwide, as flippers found it more difficult to find cheap properties to buy — and inexpensive materials to use to flip them. Flippers in the United States received an average gross profit of $66,448 per flip in July through September last year, representing a 47.7 percent return on investment, according to Attom Data Solutions, a real estate data company. That's down from 51.2 percent the year before and is the lowest return on investment that flippers have received since the second quarter of 2015.

Like the nationwide average, the typical return on investment for a Philadelphia-area flipper did tick down slightly from the year before, too. However, the data also show that unlike other markets, Philadelphia was a flipping gold mine.

In the third quarter of 2017, Philadelphia metro area flippers earned an average $95,875 gross profit, according to Attom. That's a 114 percent return on investment — the third highest in the nation. The local area trails only the Pittsburgh metro area, where flippers earned an average return on investment of 147.7 percent in the third quarter, and the Baton Rouge, La., area, where flippers earned an average 122.2 percent.

(Attom defines the Philadelphia metro area to include Philadelphia, Chester, Bucks, Delaware, and Montgomery Counties in Pennsylvania; Camden, Gloucester, Burlington, and Salem Counties in New Jersey; New Castle County in Delaware; and Cecil County in Maryland. A flip is defined as any residential property bought by an investor and sold to an unrelated person within one year.)

Reasons for the Philadelphia-area's profitability are related to the fact that Philadelphia has one of the oldest housing stocks in the nation — and the fact that the area continues to suffer from higher foreclosure rates compared with other markets. In the Philadelphia metro area, one out of every 80 homes in 2017 experienced a foreclosure proceeding, according to Attom. Nationwide, in contrast, the 2017 rate was one out of every 197 units.

Together, that often means local flippers here, more than many other markets, can buy aging or distressed properties for a discount and then sell for a premium.

"In the Philadelphia area, the median year built for a home being flipped is 1951," said Daren Blomquist, senior vice president of communications for Attom. "Nationwide, it's 1978. So in Philadelphia, there are older properties that have more value-add opportunities. That helps flippers get a discount when they buy."

According to Attom's data, the median purchase price of a Philadelphia-area flipped home during the third quarter was $84,125. The average sale price, the company found, was $180,000.

Even as the Philadelphia area offers significant profitability, Attom's data show that the local market has not reached the same amount of flipping that the region saw during the housing bubble of the mid-2000s. Philadelphia's flipping peaked in the second quarter of 2005, according to Attom, with 2,074 flips in the three-month period. In the third quarter of 2017, by contrast, flippers completed nearly 30 percent fewer — 1,452 flips in July through September, accounting for 6.3 percent of all home sales.

"Low inventory and rising home prices is making it tough to find properties to buy," Blomquist said. "… Because foreclosures are drying up in many markets, [flippers] are getting more creative and are buying what they would refer to as 'off-market homes.'"

In general, Blomquist said, "off-market homes" are typically the ones that flippers will attempt to acquire by methods such as sending "We Can Buy Your Home As Is" letters.

Even with low inventory and steeper competition to find homes, local flippers were able to find success across the city, Attom's data show. For the metro area, the most active flipping areas were the 19150 zip code (the Stenton and Cedarbrook area in Philadelphia), the 08046 zip code (the Willingboro Township area in New Jersey), and the 19138 zip code (the East Germantown and Belfield area in Philadelphia).

The most profitable zip codes for flippers in the metro area during the third quarter of 2017 were the 19131 zip code (the Parkside and Wynnefield area), the 19146 zip code (the Graduate Hospital area), and the 08094 zip code (the Monroe Township area in New Jersey).