@Test public void testCompute() { portfolio.setEquities(createEquities()); portfolio.compute(); assertEquals(66d, portfolio.getTotalQuantity(), 0.1); assertEquals(30500d, portfolio.getTotalValue(), 0.1); assertEquals(0d, portfolio.getYieldYear(), 0.1); assertEquals(12700d, portfolio.getTotalGain(), 0.1); assertNotNull(portfolio.getLastCompanyUpdate()); }
public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject();  }