Examples of PositionData


Examples of com.google.gdata.data.finance.PositionData

    }
    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());
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.