1 package org.oxerr.okcoin.websocket.dto; 2 3 import java.math.BigDecimal; 4 import java.time.Instant; 5 6 import javax.json.JsonObject; 7 import javax.json.JsonValue; 8 9 import org.oxerr.okcoin.rest.dto.Status; 10 import org.oxerr.okcoin.rest.dto.Type; 11 12 public class Trade extends BaseObject { 13 14 private static final long serialVersionUID = 2015030601L; 15 16 private final BigDecimal averagePrice; 17 private final BigDecimal completedTradeAmount; 18 private final Instant createdDate; 19 private long id; 20 private long orderId; 21 private BigDecimal sigTradeAmount; 22 private BigDecimal sigTradePrice; 23 private Status status; 24 private String symbol; 25 private BigDecimal tradeAmount; 26 private BigDecimal tradePrice; 27 private Type tradeType; 28 private BigDecimal tradeUnitPrice; 29 private BigDecimal unTrade; 30 31 public Trade(JsonValue jsonValue) { 32 this((JsonObject) jsonValue); 33 } 34 35 public Trade(JsonObject jsonObject) { 36 this.averagePrice = new BigDecimal(jsonObject.getString("averagePrice")); 37 this.completedTradeAmount = new BigDecimal(jsonObject.getString("completedTradeAmount")); 38 this.createdDate = Instant.ofEpochMilli(jsonObject.getJsonNumber("createdDate").longValue()); 39 this.id = jsonObject.getJsonNumber("id").longValue(); 40 this.orderId = jsonObject.getJsonNumber("orderId").longValue(); 41 this.sigTradeAmount = new BigDecimal(jsonObject.getString("sigTradeAmount")); 42 this.sigTradePrice = new BigDecimal(jsonObject.getString("sigTradePrice")); 43 this.status = Status.of(jsonObject.getInt("status")); 44 this.symbol = jsonObject.getString("symbol"); 45 this.tradeAmount = new BigDecimal(jsonObject.getString("tradeAmount")); 46 this.tradePrice = new BigDecimal(jsonObject.getString("tradePrice")); 47 this.tradeType = Type.of(jsonObject.getString("tradeType")); 48 this.tradeUnitPrice = new BigDecimal(jsonObject.getString("tradeUnitPrice")); 49 this.unTrade = new BigDecimal(jsonObject.getString("unTrade")); 50 } 51 52 public long getId() { 53 return id; 54 } 55 56 public void setId(long id) { 57 this.id = id; 58 } 59 60 public long getOrderId() { 61 return orderId; 62 } 63 64 public void setOrderId(long orderId) { 65 this.orderId = orderId; 66 } 67 68 public BigDecimal getSigTradeAmount() { 69 return sigTradeAmount; 70 } 71 72 public void setSigTradeAmount(BigDecimal sigTradeAmount) { 73 this.sigTradeAmount = sigTradeAmount; 74 } 75 76 public BigDecimal getSigTradePrice() { 77 return sigTradePrice; 78 } 79 80 public void setSigTradePrice(BigDecimal sigTradePrice) { 81 this.sigTradePrice = sigTradePrice; 82 } 83 84 public Status getStatus() { 85 return status; 86 } 87 88 public void setStatus(Status status) { 89 this.status = status; 90 } 91 92 public String getSymbol() { 93 return symbol; 94 } 95 96 public void setSymbol(String symbol) { 97 this.symbol = symbol; 98 } 99 100 public BigDecimal getTradeAmount() { 101 return tradeAmount; 102 } 103 104 public void setTradeAmount(BigDecimal tradeAmount) { 105 this.tradeAmount = tradeAmount; 106 } 107 108 public BigDecimal getTradePrice() { 109 return tradePrice; 110 } 111 112 public void setTradePrice(BigDecimal tradePrice) { 113 this.tradePrice = tradePrice; 114 } 115 116 public Type getTradeType() { 117 return tradeType; 118 } 119 120 public void setTradeType(Type tradeType) { 121 this.tradeType = tradeType; 122 } 123 124 public BigDecimal getTradeUnitPrice() { 125 return tradeUnitPrice; 126 } 127 128 public void setTradeUnitPrice(BigDecimal tradeUnitPrice) { 129 this.tradeUnitPrice = tradeUnitPrice; 130 } 131 132 public BigDecimal getUnTrade() { 133 return unTrade; 134 } 135 136 public void setUnTrade(BigDecimal unTrade) { 137 this.unTrade = unTrade; 138 } 139 140 public BigDecimal getAveragePrice() { 141 return averagePrice; 142 } 143 144 public BigDecimal getCompletedTradeAmount() { 145 return completedTradeAmount; 146 } 147 148 public Instant getCreatedDate() { 149 return createdDate; 150 } 151 152 }