@Override public void stopSelling(boolean flag) { if (flag != portfolioTable.isStopSelling()) { portfolioTable.setStopSelling(flag); jpaHelper.updateObject(portfolioTable); } }
@Override public long getCurrentWorth() { long currentWorth = getUnusedAmount(); for (int i = 0; i < portfolioTable.getHistory().size(); i++) { final PortfolioHistory portfolioHistory = portfolioTable.getHistory().get(i); if (portfolioHistory.getSoldDate() == null) { final StockPrices latest = jpaHelper.getLatestStockPrice(portfolioHistory.getStockPrice()); currentWorth += latest.getSell() * portfolioHistory.getAmount(); } } return currentWorth; }
@Override public boolean investAmount(final long amount) { return jpaHelper.investMoney(amount, portfolioTable); }
@Override public long getInvestedAmount() { return jpaHelper.getTotalInvestedAmount(portfolioTable); }
@Override public List<Pair<StockPrices, StockPrices>> getHistoryStocks() { return jpaHelper.getOldStocks(portfolioTable); }
@Override public List<StockPrices> getCurrentStocks() { return jpaHelper.getCurrentStocks(portfolioTable); }
@Override public List<StockNames> getAvalibleStocks() { return jpaHelper.getStockNames(portfolioTable); }