If you want to invest in stocks and do well at it, you need to choose your holdings carefully. There are two key factors to keep in mind -- quality and price.

Imagine buying a home, or a car, or even a pair of shoes. You probably won't just buy the loveliest house you see -- as you may not be able to afford it. You probably won't buy the cheapest car you can find, either, because it's not likely to perform well. It's the same when you target stock bargains. A true bargain will be both attractively priced and high-quality.

Seek high quality
Quality matters when you want to target stock bargains, because a high-quality company will have sustainable competitive advantages that will help it keep performing well. Its size might give it economies of scale, for example, or might have consumers sort of locked into its system and reluctant to switch. That can happen with email service providers, as it's a headache to send everyone your new email address. Or consider robotic surgery giant Intuitive Surgical (NASDAQ:ISRG). Once a hospital buys its machines, it won't be likely to buy one from a competing company, as its doctors will have learned how to use Intuitive's machines. Meanwhile, Intuitive will get to collect a lot of recurring revenue from the hospital, in the form of service contracts and supplies for the machines.

A beautiful business model is a big advantage. Think of eBay (NASDAQ:EBAY), a company that helps people procure lots of items that they need or want, as many retailers do. But whereas traditional retailers need to build and maintain brick-and-mortar stores and staff them with many people, eBay doesn't. Its business is very light, essentially just connecting buyers and sellers. Thus, its profit margin can be much higher, and it can more easily grow.

Similarly, Silver Wheaton (NYSE:SLW) is in the precious metals business, but its own beautiful business model has it not in the capital-intensive and risky business of mining, but instead financing mining companies in exchange for a cut of their proceeds, generally at prices well below market rates.

Seek low prices
Another critical part of how to target stock bargains is to seek high-quality companies that are trading at attractive prices. That's easier said than done, though. For one thing, valuing a company involves guessing about its future, even if the guessing is based on lots of research and deep thinking.

Still, you can at least get a rough idea about a stock's value. You might assess its price-to-earnings ratio, for example. eBay, for example, has a recent P/E near the top of its five-year range, suggesting that it might not be a bargain right now. Don't compare P/Es across industries, as there can be wide variation, and rapid growth rates can support steeper P/E rates. If you're not sure about a stock's value, you might wait for a lower price, to build in a greater margin of safety.

So target stock bargains by demanding both high quality and low prices. That's the best way to position your stock portfolio for success.