Skip to content

Instantly share code, notes, and snippets.

@kennedysean
Created May 12, 2020 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennedysean/fcffff85bb5a08e23c64c9391a07a97c to your computer and use it in GitHub Desktop.
Save kennedysean/fcffff85bb5a08e23c64c9391a07a97c to your computer and use it in GitHub Desktop.
double DodStockPortfolio::getPortfolioValue()
{
double returnVal = 0;
for (unsigned int i = 0; i < size; i++)
{
// std::cout << &(numShares[i]) << std::endl;
// std::cout << &(stockValues[i]) << std::endl;
returnVal += (numShares[i] * stockValues[i]);
}
return returnVal;
}
double DodStockPortfolio::getPortfolioCost()
{
double returnVal = 0;
for (unsigned int i = 0; i < size; i++)
{
returnVal += (numShares[i] * stockAverageCosts[i]);
}
return returnVal;
}
double DodStockPortfolio::getTotalReturn()
{
return (getPortfolioValue() / getPortfolioCost()) * 100 - 100.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment