Created
May 12, 2020 00:26
-
-
Save kennedysean/72691bd3d17cb127f0ce2830e468d6e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double OopStockPortfolio::getPortfolioValue() | |
{ | |
double returnVal = 0; | |
std::for_each(stockPortfolio.begin(), stockPortfolio.end(), | |
[&returnVal](const StockPosition &a) { returnVal += (a.numShares * a.stockValue); }); | |
return returnVal; | |
} | |
double OopStockPortfolio::getPortfolioCost() | |
{ | |
double returnVal = 0; | |
std::for_each(stockPortfolio.begin(), stockPortfolio.end(), | |
[&returnVal](const StockPosition &a) { returnVal += (a.numShares * a.stockAverageCost); }); | |
return returnVal; | |
} | |
double OopStockPortfolio::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