예제 #1
0
template <class numericType> numericType calculatePERatio<numericType>::operator() (const Stock<numericType>& stock) {
  if ((stock.getTickerPrice() == 0) || (stock.getLastDividend() == 0)) {
    return (numericType)0;
  }
  
  return (numericType)(stock.getTickerPrice()/stock.getLastDividend());
}
예제 #2
0
double StockUtil::PERatio(Stock stock, double marketPrice)
{
	double div = stock.getLastDividend();
	if(div == 0.0){return 0;}
	return marketPrice/div;

}
예제 #3
0
double StockUtil::DividendYield(Stock stock, double marketPrice)
{
	if(marketPrice == 0.0){return 0;}

	switch(stock.getStockType() )
	{
	case COMMON:
		return (stock.getLastDividend() / marketPrice);
	case PREFFERED:
		return (stock.getFixedDividend() * stock.getParValue())/ marketPrice;
	default:
		return 0;
	}
}