It's been a good few years for the world's major investment banks. From early 2003 to the beginning of 2007, Goldman Sachs (NYSE:GS) stock was up 226%. Lehman Brothers (NYSE:LEH) gained 221%. Bear Stearns (NYSE:BSC) ran up 186%. Overseas, Credit Suisse (NYSE:CS), Deutsche Bank (NYSE:DB), and Nomura Holdings appreciated 282%, 239%, and 101%, respectively.

Excesses in the housing and credit markets seem to be taking their toll on the markets now, though, as some money has left the market through loan defaults and withdrawals from hedge funds, which I wrote about here.

But how bad will it get?
Right now I'm not on board with expecting a major investment bank to go out of business. However, if there isn't a 180-degree turn in the markets -- and quickly -- the banks will be feeling a little lighter in the wallet in the coming quarters.

As I've shown, the major investment banks do a lot more than investment banking. These days, in addition to true investment banking, most of the bulge-bracket banks are involved in trading both on behalf of clients and their own accounts, and asset management. The contaminants fouling up the market could take a bite out of each one of the banks' business lines.

Investment banking
True investment banking consists of providing advisory services to companies. Initial public offerings (IPOs) may be the best-known flavor of advising on raising capital, while providing input on mergers and acquisitions is the most prominent of the strategic advisory activities that the banks offer.

The vast majority of capital raising tends to happen during good times, when company managers have a lot of confidence in the business environment, so many businesses will consider growth strategies that would require outside capital. It's likewise at those times when lenders will be more confident about companies' ability to execute growth plans and pay back debt or generate good returns on equity -- and therefore are willing to lend at lower rates or invest at higher prices.

The M&A environment is similar. Acquirers tend to be more aggressive about pursuing deals when they are confident in a strong economy, and sellers tend to be more willing to sell when confident buyers are offering high prices. There also tends to be more M&A activity when there is reasonably priced capital (debt or equity) around to help finance the acquisition. Recently, a good chunk of acquisition activity came from private equity funds like Blackstone (NYSE:BX) and KKR, which were spurred on by cheap debt.

With capital suddenly less plentiful and Mr. Market rechecking his optimism for the near future, the number of companies interested in raising capital is likely to fall. At the same time, the number of companies or private equity funds looking to make large acquisitions could slip -- particularly for those that need outside financing.

This would all be bad news for investment banking arms, which rely on the fees they collect for the completion of successful deals.

Asset management
Even though they are not the most profitable asset management vehicles, much of the money managed by investment banks is held in traditional investment funds. These funds make money by collecting fees for the total assets under management (AUM).

The potential impact here is twofold. First, if the assets lose value with the rest of the market, the funds managed fall, leaving the firm with fewer assets to collect a fee on. Compounding that is the fact that when the market starts doing poorly, investors tend to be less likely to put in new money and more likely to yank money they have in there. This puts a similar drag on AUM and fees.

The other more profitable and high-profile asset management area for the banks is alternative asset management, primarily of private equity and hedge funds. These funds also collect fees on total AUM, but have the added bonus of bringing in hefty performance fees should the funds do well.

As most market watchers know, there is whole boatload of hedge funds out there right now that are about as comfortable as Al Gore riding in a Hummer. With returns sorely lacking in many funds, performance fees are right out the window. As an added bonus, lagging performance can serve as a deterrent for new investors.

Trading and principal transactions
This segment of investment bank operations can be somewhat of a black box. While outsiders have a pretty good idea of what goes on in theory, it's tough to gauge at any given time exactly what's going down.

The less mysterious activity of this segment is aiding clients with various capital markets activities. These include -- but aren't limited to -- selling new issues of debt and equity (which is generally done in conjunction with the investment banking teams), facilitating trades in various products, and structuring and trading derivatives.

Clients' interest in structuring complex derivatives to act as hedges -- a relatively high-profit activity for the banks -- could increase if the market continues to do weird things. However, trading and capital markets activity in general tends to be slow when the markets are sputtering, and on balance lower levels of activity would likely take a toll on this part of the business.

The tricky part of this segment, though, is the banks' principal transactions. This is where many of the banks stick their best and brightest and give them access to firm capital to make proprietary trades on behalf of the bank. For competitive reasons, investment banks tend to be very squirrelly about disclosing exactly what they're doing when it comes to prop trading, so it's tough to figure what effect the market will have on this area. Good performance here could help buoy results, as was the case for Lehman in its latest quarter. On the other hand, missteps in a market like this can leave you up a creek without that proverbial paddle really quickly.

But how bad will it really get?
To a large extent, the major investment banks are a leveraged play on the broad market. A look at the major banks over the past five years shows them climbing right along with the S&P index -- though outperformers like Goldman and Lehman beat out the rest, particularly over the past two years.

The take-home here is that the industry is cyclical. The current problems facing banks are serious and will take some time to work through, but it doesn't seem likely that they will lead to some extraordinary industrywide blowup. As the operating environment gets tougher, the banks will end up limping along for a while -- who knows, maybe there could even be some consolidation. When the next big market cycle starts, though, guess who's going to be there to provide capital raising, advice on deals, and asset management, and help with trades? Oh yeah, you got it.

The upshot of all of this, then, is that if this all does play out and the investment banks start struggling, there should be good opportunities to pick up high-quality banks at some point. There's a lot of uncertainty right now, but keep an eye out for the appearance of a Goldman Sachs or a Merrill Lynch (NYSE:MER) in that ol' bargain bin -- it could happen.

More financial Foolishness:

Think you could pitch your favorite stock -- or ditch your least favorite -- in 27 seconds or less? That's what we're doing over at Motley Fool CAPS. Check out our new stock videos.

Fool contributor Matt Koppenheffer does not own shares of any of the companies mentioned, though he's got his eye out for bargains. The Fool's disclosure policy was never an investment banker, but once lifted 100 pounds straight up over its head.