Permalink
Browse files

add some stuff for persisting trade prices

  • Loading branch information...
1 parent 92bd5a1 commit bde644d8c36537a56707f36f2ff056f529ed0f81 @mikedanese mikedanese committed Dec 30, 2013
View
4 src/main/java/com/raskol/tradebot/dao/TradeDAO.java
@@ -0,0 +1,4 @@
+package com.raskol.tradebot.dao;
+
+public class TradeDAO {
+}
View
81 src/main/java/com/raskol/tradebot/dto/TradeDTO.java
@@ -0,0 +1,81 @@
+package com.raskol.tradebot.dto;
+
+import org.joda.money.BigMoney;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class TradeDTO implements Serializable, Comparable<TradeDTO> {
+ /* Amount that was traded */
+ private final BigDecimal tradableAmount;
+
+ /* An identifier that uniquely identifies the tradable */
+ private final String tradableIdentifier;
+
+ /* The currency used to settle the market order transaction */
+ private final String transactionCurrency;
+ private final BigMoney price;
+ private final Date timestamp;
+ private final long id;
+
+ /**
+ * @param tradableAmount The depth of this trade
+ * @param tradableIdentifier The exchange identifier (e.g. "BTC/USD")
+ * @param transactionCurrency The transaction currency (e.g. USD in BTC/USD)
+ * @param price The price (either the bid or the ask)
+ * @param timestamp The timestamp when the order was placed. Exchange matching is
+ * usually price first then timestamp asc to clear older orders
+ * @param id The id of the trade
+ */
+ public TradeDTO(BigDecimal tradableAmount, String tradableIdentifier, String transactionCurrency, BigMoney price, Date timestamp, long id) {
+
+ this.tradableAmount = tradableAmount;
+ this.tradableIdentifier = tradableIdentifier;
+ this.transactionCurrency = transactionCurrency;
+ this.price = price;
+ this.timestamp = timestamp;
+ this.id = id;
+ }
+
+ public BigDecimal getTradableAmount() {
+ return tradableAmount;
+ }
+
+ public String getTradableIdentifier() {
+ return tradableIdentifier;
+ }
+
+ public String getTransactionCurrency() {
+ return transactionCurrency;
+ }
+
+ public BigMoney getPrice() {
+ return price;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "TradeDTO{" +
+ "tradableAmount=" + tradableAmount +
+ ", tradableIdentifier='" + tradableIdentifier + '\'' +
+ ", transactionCurrency='" + transactionCurrency + '\'' +
+ ", price=" + price +
+ ", timestamp=" + timestamp +
+ ", id=" + id +
+ '}';
+ }
+
+ @Override
+ public int compareTo(TradeDTO trade) {
+ return getTimestamp().compareTo(trade.getTimestamp());
+ }
+}

0 comments on commit bde644d

Please sign in to comment.