use of org.opentransactions.otapi.TradeDataNym in project otapij by FellowTraveler.
the class Market method getNymTrades.
public static Map getNymTrades(String serverID, String nymID) {
Map tradeNymData = new HashMap();
TradeListNym tradeListNym = Helpers.getNYMTrades(serverID, nymID);
if (tradeListNym == null) {
System.out.println("getNymTrades - tradeListNym returns null");
return null;
}
for (int j = 0; j < tradeListNym.GetTradeDataNymCount(); j++) {
TradeDataNym tradeDataNym = tradeListNym.GetTradeDataNym(j);
if (tradeDataNym == null) {
continue;
}
String[] tradeDataRow = new String[5];
tradeDataRow[0] = !Utility.VerifyStringVal(tradeDataNym.getTransaction_id()) ? "" : tradeDataNym.getTransaction_id();
tradeDataRow[1] = !Utility.VerifyStringVal(tradeDataNym.getPrice()) ? "" : tradeDataNym.getPrice();
tradeDataRow[2] = !Utility.VerifyStringVal(tradeDataNym.getAmount_sold()) ? "" : tradeDataNym.getAmount_sold();
tradeDataRow[3] = !Utility.VerifyStringVal(tradeDataNym.getCompleted_count()) ? "" : tradeDataNym.getCompleted_count();
tradeDataRow[4] = !Utility.VerifyStringVal(tradeDataNym.getDate()) ? "" : tradeDataNym.getDate();
if (!tradeDataRow[4].equals("")) {
try {
tradeDataRow[4] = String.valueOf(new Date(Long.parseLong(tradeDataRow[4]) * 1000));
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
System.out.println("Invalid number returned by timestmp:" + tradeDataRow[4]);
tradeDataRow[4] = "";
}
}
tradeNymData.put(tradeDataNym.getTransaction_id(), tradeDataRow);
}
return tradeNymData;
}
Aggregations