Skip to content

Commit

Permalink
Add proper ids to trade history response
Browse files Browse the repository at this point in the history
  • Loading branch information
ww3456 committed Oct 10, 2014
1 parent 3461ede commit 4fa3f99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ public static Trades adaptTradeHistory(BitfinexTradeResponse[] trades, String sy
for (BitfinexTradeResponse trade : trades) {
OrderType orderType = trade.getType().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK;

String id = String.valueOf(trade.hashCode());

pastTrades.add(new Trade(orderType, trade.getAmount(), currencyPair, trade.getPrice(), new Date((long) (trade.getTimestamp() * 1000L)), id));
pastTrades.add(new Trade(orderType, trade.getAmount(), currencyPair, trade.getPrice(), new Date((long) (trade.getTimestamp() * 1000L)), trade.getTradeId(), trade.getOrderId()));
}

return new Trades(pastTrades, TradeSortType.SortByTimestamp);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@ public class BitfinexTradeResponse {
private final float timestamp;
private final String exchange;
private final String type;
private final String tradeId;
private final String orderId;

/**
* Constructor
*
*
* @param price
* @param amount
* @param timestamp
* @param exchange
* @param type
* @param tradeId
* @param orderId
*/
public BitfinexTradeResponse(@JsonProperty("price") BigDecimal price, @JsonProperty("amount") BigDecimal amount, @JsonProperty("timestamp") float timestamp,
@JsonProperty("exchange") String exchange, @JsonProperty("type") String type) {
public BitfinexTradeResponse(@JsonProperty("price") final BigDecimal price, @JsonProperty("amount") final BigDecimal amount, @JsonProperty("timestamp") final float timestamp,
@JsonProperty("exchange") final String exchange, @JsonProperty("type") final String type, @JsonProperty("tid") final String tradeId, @JsonProperty("order_id") final String orderId) {

this.price = price;
this.amount = amount;
this.timestamp = timestamp;
this.exchange = exchange;
this.type = type;
this.tradeId = tradeId;
this.orderId = orderId;
}

public BigDecimal getPrice() {
Expand All @@ -51,10 +57,20 @@ public String getType() {
return type;
}

public String getOrderId() {

return orderId;
}

public String getTradeId() {

return tradeId;
}

@Override
public String toString() {

StringBuilder builder = new StringBuilder();
final StringBuilder builder = new StringBuilder();
builder.append("BitfinexTradeResponse [price=");
builder.append(price);
builder.append(", amount=");
Expand All @@ -66,6 +82,12 @@ public String toString() {
builder.append(", type=");
builder.append(type);
builder.append("]");
builder.append(", tradeId=");
builder.append(tradeId);
builder.append("]");
builder.append(", orderId=");
builder.append(orderId);
builder.append("]");
return builder.toString();
}
}

0 comments on commit 4fa3f99

Please sign in to comment.