/** * Prints detailed contents for a transaction (i.e. a Transaction Feed entry) * * @param transactionEntry The transaction entry of interest */ private static void printTransactionEntry(TransactionEntry transactionEntry) { System.out.println("\nTransaction Entry\n-----------------"); printBasicEntryDetails(transactionEntry); TransactionData transactionData = transactionEntry.getTransactionData(); System.out.println("\tTransaction Data:"); System.out.println( "\t\tType: " + (transactionData.getType() == null ? "no type" : transactionData.getType())); System.out.println( "\t\tDate: " + (transactionData.getDate() == null ? "no date" : transactionData.getDate())); System.out.printf("\t\tShares: %.2f\n", transactionData.getShares()); if (transactionData.getPrice() == null) { System.out.println("\t\tPrice not specified"); } else { for (int i = 0; i < transactionData.getPrice().getMoney().size(); i++) { Money m = transactionData.getPrice().getMoney().get(i); System.out.printf( "\t\tThis transaction had a unit price of %.2f %s.\n", m.getAmount(), m.getCurrencyCode()); } } if (transactionData.getCommission() == null) { System.out.println("\t\tCommission not specified"); } else { for (int i = 0; i < transactionData.getCommission().getMoney().size(); i++) { Money m = transactionData.getCommission().getMoney().get(i); System.out.printf( "\t\tThis transaction had a commission of %.2f %s.\n", m.getAmount(), m.getCurrencyCode()); } } System.out.println( "\t\tNotes: " + (null == transactionData.getNotes() ? "none" : transactionData.getNotes())); }
/** * Prints detailed contents for a position (i.e. a Position Feed entry) * * @param positionEntry The position entry of interest */ private static void printPositionEntry(PositionEntry positionEntry) { System.out.println("\nPosition Entry\n--------------"); printBasicEntryDetails(positionEntry); System.out.println("\tFeed Link: " + positionEntry.getFeedLink().getHref()); if (positionEntry.getFeedLink().getFeed() == null) { System.out.println("\tNo inlined feed."); } else { System.out.println("********** Beginning of inline feed ***************"); printBasicFeedDetails(positionEntry.getFeedLink().getFeed()); TransactionFeed inlinedFeed = positionEntry.getFeedLink().getFeed(); printBasicFeedDetails(inlinedFeed); for (int i = 0; i < inlinedFeed.getEntries().size(); i++) { TransactionEntry transactionEntry = inlinedFeed.getEntries().get(i); printTransactionEntry(transactionEntry); } System.out.println("************* End of inlined feed *****************"); } System.out.println("\tTicker:"); System.out.println("\t\tExchange: " + positionEntry.getSymbol().getExchange()); System.out.println("\t\tSymbol: " + positionEntry.getSymbol().getSymbol()); System.out.println("\t\tFull Name: " + positionEntry.getSymbol().getFullName()); PositionData positionData = positionEntry.getPositionData(); System.out.println("\tPosition Data:"); System.out.printf("\t\tShare count: %.2f\n", positionData.getShares()); System.out.printf("\t\tPercent Gain is %.2f%%\n", positionData.getGainPercentage() * 100.0); System.out.println("\t\tReturns:"); System.out.printf("\t\t\tOne week: %.2f%%\n", positionData.getReturn1w() * 100.0); System.out.printf("\t\t\tFour weeks: %.2f%%\n", positionData.getReturn4w() * 100.0); System.out.printf("\t\t\tThree months: %.2f%%\n", positionData.getReturn3m() * 100.0); System.out.printf("\t\t\tYear-to-date: %.2f%%\n", positionData.getReturnYTD() * 100.0); System.out.printf("\t\t\tOne year: %.2f%%\n", positionData.getReturn1y() * 100.0); System.out.printf("\t\t\tThree years: %.2f%%\n", positionData.getReturn3y() * 100.0); System.out.printf("\t\t\tFive years: %.2f%%\n", positionData.getReturn5y() * 100.0); System.out.printf("\t\t\tOverall: %.2f%%\n", positionData.getReturnOverall() * 100.0); if (positionData.getCostBasis() == null) { System.out.println("\t\tCost Basis not specified"); } else { for (int i = 0; i < positionData.getCostBasis().getMoney().size(); i++) { Money m = positionData.getCostBasis().getMoney().get(i); System.out.printf("\t\tThis position cost %.2f %s.\n", m.getAmount(), m.getCurrencyCode()); } } if (positionData.getDaysGain() == null) { System.out.println("\t\tDay's Gain not specified"); } else { for (int i = 0; i < positionData.getDaysGain().getMoney().size(); i++) { Money m = positionData.getDaysGain().getMoney().get(i); System.out.printf( "\t\tThis position made %.2f %s today.\n", m.getAmount(), m.getCurrencyCode()); } } if (positionData.getGain() == null) { System.out.println("\t\tTotal Gain not specified"); } else { for (int i = 0; i < positionData.getGain().getMoney().size(); i++) { Money m = positionData.getGain().getMoney().get(i); System.out.printf( "\t\tThis position has a total gain of %.2f %s.\n", m.getAmount(), m.getCurrencyCode()); } } if (positionData.getMarketValue() == null) { System.out.println("\t\tMarket Value not specified"); } else { for (int i = 0; i < positionData.getMarketValue().getMoney().size(); i++) { Money m = positionData.getMarketValue().getMoney().get(i); System.out.printf( "\t\tThis position is worth %.2f %s.\n", m.getAmount(), m.getCurrencyCode()); } } }