From c3344ec38dc8ba93bcd29e2c9ee21f3df03466a5 Mon Sep 17 00:00:00 2001 From: Martin Stachon Date: Sat, 11 Apr 2015 14:20:43 +0200 Subject: [PATCH] open orders, cancel order, error checking --- .../xchange/coinmate/CoinmateAdapters.java | 41 +- .../coinmate/CoinmateAuthenticated.java | 20 +- .../xchange/coinmate/CoinmateException.java | 39 ++ .../trade/CoinmateCancelOrderResponse.java | 45 ++ .../dto/trade/CoinmateOpenOrders.java | 43 ++ .../dto/trade/CoinmateOpenOrdersData.java | 35 + .../dto/trade/CoinmateOpenOrdersEntry.java | 92 +++ .../trade/CoinmateTransactionHistoryData.java | 2 +- ...a => CoinmateTransactionHistoryEntry.java} | 4 +- .../polling/CoinmateAccountServiceRaw.java | 4 +- .../polling/CoinmateBasePollingService.java | 8 + .../polling/CoinmateMarketDataServiceRaw.java | 18 +- .../service/polling/CoinmateTradeService.java | 13 +- .../polling/CoinmateTradeServiceRaw.java | 25 +- .../coinmate/dto/account/BalanceJSONTest.java | 3 +- .../dto/account/OpenOrdersJSONTest.java | 60 ++ .../service/polling/TradeServiceTest.java | 21 +- .../example-balance.json | 0 .../account/example-open-orders.json | 622 ++++++++++++++++++ 19 files changed, 1076 insertions(+), 19 deletions(-) create mode 100644 xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateException.java create mode 100644 xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateCancelOrderResponse.java create mode 100644 xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrders.java create mode 100644 xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersData.java create mode 100644 xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersEntry.java rename xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/{CoinmateTransactionHistoryDataEntry.java => CoinmateTransactionHistoryEntry.java} (96%) create mode 100644 xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/OpenOrdersJSONTest.java rename xchange-coinmate/src/test/resources/{marketdata => account}/example-balance.json (100%) create mode 100644 xchange-coinmate/src/test/resources/account/example-open-orders.json diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAdapters.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAdapters.java index 8b4bf9a9fc0..9e971e77f8f 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAdapters.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAdapters.java @@ -31,8 +31,10 @@ import com.xeiam.xchange.coinmate.dto.marketdata.CoinmateTicker; import com.xeiam.xchange.coinmate.dto.marketdata.CoinmateTransactions; import com.xeiam.xchange.coinmate.dto.marketdata.CoinmateTransactionsEntry; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrders; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrdersEntry; import com.xeiam.xchange.coinmate.dto.trade.CoinmateTransactionHistory; -import com.xeiam.xchange.coinmate.dto.trade.CoinmateTransactionHistoryDataEntry; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateTransactionHistoryEntry; import com.xeiam.xchange.currency.CurrencyPair; import com.xeiam.xchange.dto.Order; import com.xeiam.xchange.dto.account.AccountInfo; @@ -41,6 +43,7 @@ import com.xeiam.xchange.dto.marketdata.Trade; import com.xeiam.xchange.dto.marketdata.Trades; import com.xeiam.xchange.dto.trade.LimitOrder; +import com.xeiam.xchange.dto.trade.OpenOrders; import com.xeiam.xchange.dto.trade.UserTrade; import com.xeiam.xchange.dto.trade.UserTrades; import com.xeiam.xchange.dto.trade.Wallet; @@ -48,7 +51,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Map; /** * @@ -121,7 +123,7 @@ public static AccountInfo adaptAccountInfo(CoinmateBalance coinmateBalance) { public static UserTrades adaptTradeHistory(CoinmateTransactionHistory coinmateTradeHistory) { List trades = new ArrayList(coinmateTradeHistory.getData().size()); - for (CoinmateTransactionHistoryDataEntry entry : coinmateTradeHistory.getData()) { + for (CoinmateTransactionHistoryEntry entry : coinmateTradeHistory.getData()) { Order.OrderType orderType; if (entry.getTransactionType().equals("BUY")) { orderType = Order.OrderType.BID; @@ -148,5 +150,38 @@ public static UserTrades adaptTradeHistory(CoinmateTransactionHistory coinmateTr return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp); } + + public static OpenOrders adaptOpenOrders(CoinmateOpenOrders coinmateOpenOrders) throws CoinmateException { + + List ordersList = new ArrayList(coinmateOpenOrders.getData().size()); + + for (CoinmateOpenOrdersEntry entry : coinmateOpenOrders.getData()) { + + Order.OrderType orderType; + //TODO + if ("BUY".equals(entry.getType())) { + orderType = Order.OrderType.BID; + } else if ("SELL".equals(entry.getType())) { + orderType = Order.OrderType.ASK; + } else { + throw new CoinmateException("Unknown order type"); + } + + // the api does not provide currency for open orders, so just assume the default BTC_USD pair + CurrencyPair currencyPair = CurrencyPair.BTC_USD; + + LimitOrder limitOrder = new LimitOrder( + orderType, + entry.getAmount(), + currencyPair, + Long.toString(entry.getId()), + new Date(entry.getTimestamp()), + entry.getPrice()); + + ordersList.add(limitOrder); + } + + return new OpenOrders(ordersList); + } } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAuthenticated.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAuthenticated.java index e2c1ec55d0d..d0692cd4919 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAuthenticated.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateAuthenticated.java @@ -24,6 +24,8 @@ package com.xeiam.xchange.coinmate; import com.xeiam.xchange.coinmate.dto.account.CoinmateBalance; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateCancelOrderResponse; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrders; import com.xeiam.xchange.coinmate.dto.trade.CoinmateTransactionHistory; import java.io.IOException; import javax.ws.rs.Consumes; @@ -46,7 +48,8 @@ public interface CoinmateAuthenticated extends Coinmate { @POST @Path("balances") - public CoinmateBalance getBalances(@FormParam("clientId") String clientId, @FormParam("signature") ParamsDigest signer, + public CoinmateBalance getBalances(@FormParam("clientId") String clientId, + @FormParam("signature") ParamsDigest signer, @FormParam("nonce") SynchronizedValueFactory nonce) throws IOException; @POST @@ -57,4 +60,19 @@ public CoinmateTransactionHistory getTransactionHistory(@FormParam("clientId") S @FormParam("offset") int offset, @FormParam("limit") int limit, @FormParam("sort") String sort) throws IOException; + + @POST + @Path("openOrders") + public CoinmateOpenOrders getOpenOrders(@FormParam("clientId") String clientId, + @FormParam("signature") ParamsDigest signer, + @FormParam("nonce") SynchronizedValueFactory nonce, + @FormParam("currencyPair") String currencyPair) throws IOException; + + @POST + @Path("cancelOrder") + public CoinmateCancelOrderResponse cancelOder(@FormParam("clientId") String clientId, + @FormParam("signature") ParamsDigest signer, + @FormParam("nonce") SynchronizedValueFactory nonce, + @FormParam("orderId") String orderId ) throws IOException; + } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateException.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateException.java new file mode 100644 index 00000000000..560168e2754 --- /dev/null +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateException.java @@ -0,0 +1,39 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate; + +import com.xeiam.xchange.exceptions.ExchangeException; + +/** + * + * @author Martin Stachon + */ +public class CoinmateException extends ExchangeException { + + public CoinmateException(String errorMessage) { + super(errorMessage); + } + +} diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateCancelOrderResponse.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateCancelOrderResponse.java new file mode 100644 index 00000000000..0984d7e4355 --- /dev/null +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateCancelOrderResponse.java @@ -0,0 +1,45 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate.dto.trade; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.xeiam.xchange.coinmate.dto.CoinmateBaseResponse; + +/** + * + * @author Martin Stachon + */ +public class CoinmateCancelOrderResponse extends CoinmateBaseResponse { + + public CoinmateCancelOrderResponse(@JsonProperty("error") boolean error, + @JsonProperty("errorMessage") String errorMessage, + @JsonProperty("data") Boolean data) { + + super(error, errorMessage, data); + } + + + +} diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrders.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrders.java new file mode 100644 index 00000000000..030eda95dcf --- /dev/null +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrders.java @@ -0,0 +1,43 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate.dto.trade; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.xeiam.xchange.coinmate.dto.CoinmateBaseResponse; + +/** + * + * @author Martin Stachon + */ +public class CoinmateOpenOrders extends CoinmateBaseResponse { + + public CoinmateOpenOrders(@JsonProperty("error") boolean error, + @JsonProperty("errorMessage") String errorMessage, + @JsonProperty("data") CoinmateOpenOrdersData data) { + + super(error, errorMessage, data); + } + +} diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersData.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersData.java new file mode 100644 index 00000000000..c1519756190 --- /dev/null +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersData.java @@ -0,0 +1,35 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate.dto.trade; + +import java.util.ArrayList; + +/** + * + * @author Martin Stachon + */ +public class CoinmateOpenOrdersData extends ArrayList { + +} diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersEntry.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersEntry.java new file mode 100644 index 00000000000..18d41f790b1 --- /dev/null +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateOpenOrdersEntry.java @@ -0,0 +1,92 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate.dto.trade; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.math.BigDecimal; + +/** + * + * @author Martin Stachon + */ +public class CoinmateOpenOrdersEntry { + + private final long id; + private final long timestamp; + private final String type; + private final BigDecimal price; + private final BigDecimal amount; + + public CoinmateOpenOrdersEntry(@JsonProperty("id") long id, + @JsonProperty("timestamp") long timestamp, + @JsonProperty("type") String type, + @JsonProperty("price") BigDecimal price, + @JsonProperty("amount") BigDecimal amount) { + + this.id = id; + this.timestamp = timestamp; + this.type = type; + this.price = price; + this.amount = amount; + } + + /** + * @return the id + */ + public long getId() { + return id; + } + + /** + * @return the timestamp + */ + public long getTimestamp() { + return timestamp; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @return the price + */ + public BigDecimal getPrice() { + return price; + } + + /** + * @return the amount + */ + public BigDecimal getAmount() { + return amount; + } + + + +} diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryData.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryData.java index 86498d2872e..a01e1cbb7d0 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryData.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryData.java @@ -30,6 +30,6 @@ * * @author Martin Stachon */ -public class CoinmateTransactionHistoryData extends ArrayList { +public class CoinmateTransactionHistoryData extends ArrayList { } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryDataEntry.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryEntry.java similarity index 96% rename from xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryDataEntry.java rename to xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryEntry.java index 7546ddcf06f..28c21846bff 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryDataEntry.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/dto/trade/CoinmateTransactionHistoryEntry.java @@ -31,7 +31,7 @@ * * @author Martin Stachon */ -public class CoinmateTransactionHistoryDataEntry { +public class CoinmateTransactionHistoryEntry { private final long transactionId; private final long timestamp; @@ -46,7 +46,7 @@ public class CoinmateTransactionHistoryDataEntry { private final String status; private final long orderId; // ? - public CoinmateTransactionHistoryDataEntry(@JsonProperty("transactionId") long transactionId, + public CoinmateTransactionHistoryEntry(@JsonProperty("transactionId") long transactionId, @JsonProperty("timestamp") long timestamp, @JsonProperty("transactionType") String transactionType, @JsonProperty("amount") BigDecimal amount, diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateAccountServiceRaw.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateAccountServiceRaw.java index 1b04a70b578..2442e59fa8c 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateAccountServiceRaw.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateAccountServiceRaw.java @@ -54,9 +54,7 @@ public CoinmateBalance getCoinmateBalance() throws IOException { CoinmateBalance coinmateBalance = coinmateAuthenticated.getBalances(exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory()); - if (coinmateBalance.isError()) { - throw new ExchangeException("Error getting balance. " + coinmateBalance.getErrorMessage()); - } + throwExceptionIfError(coinmateBalance); return coinmateBalance; } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingService.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingService.java index bf262600d63..154f579d74b 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingService.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingService.java @@ -25,6 +25,8 @@ package com.xeiam.xchange.coinmate.service.polling; import com.xeiam.xchange.Exchange; +import com.xeiam.xchange.coinmate.CoinmateException; +import com.xeiam.xchange.coinmate.dto.CoinmateBaseResponse; import com.xeiam.xchange.currency.CurrencyPair; import com.xeiam.xchange.service.polling.BasePollingExchangeService; import com.xeiam.xchange.service.polling.BasePollingService; @@ -45,5 +47,11 @@ public CoinmateBasePollingService(Exchange exchange) { public List getExchangeSymbols() throws IOException { return exchange.getMetaData().getCurrencyPairs(); } + + protected static void throwExceptionIfError(CoinmateBaseResponse response) throws CoinmateException { + if (response.isError()) { + throw new CoinmateException(response.getErrorMessage()); + } + } } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataServiceRaw.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataServiceRaw.java index a0484352993..02f4e5fb327 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataServiceRaw.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataServiceRaw.java @@ -46,16 +46,28 @@ public CoinmateMarketDataServiceRaw(Exchange exchange) { } public CoinmateTicker getCoinmateTicker(String currencyPair) throws IOException { - return coinmate.getTicker(currencyPair); + CoinmateTicker ticker = coinmate.getTicker(currencyPair); + + throwExceptionIfError(ticker); + + return ticker; } public CoinmateOrderBook getCoinmateOrderBook(String currencyPair, boolean groupByPriceLimit) throws IOException { - return coinmate.getOrderBook(currencyPair, groupByPriceLimit); + CoinmateOrderBook orderBook = coinmate.getOrderBook(currencyPair, groupByPriceLimit); + + throwExceptionIfError(orderBook); + + return orderBook; } public CoinmateTransactions getCoinmateTransactions(int minutesIntoHistory) throws IOException { - return coinmate.getTransactions(minutesIntoHistory); + CoinmateTransactions transactions = coinmate.getTransactions(minutesIntoHistory); + + throwExceptionIfError(transactions); + + return transactions; } } diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeService.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeService.java index 5e8d94a1c8e..05cfc680929 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeService.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeService.java @@ -26,6 +26,9 @@ import com.xeiam.xchange.Exchange; import com.xeiam.xchange.coinmate.CoinmateAdapters; +import com.xeiam.xchange.coinmate.CoinmateUtils; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateCancelOrderResponse; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrders; import com.xeiam.xchange.currency.CurrencyPair; import com.xeiam.xchange.dto.trade.LimitOrder; import com.xeiam.xchange.dto.trade.MarketOrder; @@ -51,7 +54,11 @@ public CoinmateTradeService(Exchange exchange) { @Override public OpenOrders getOpenOrders() throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + // BTC_USD by default + String currencyPair = CoinmateUtils.getPair(CurrencyPair.BTC_USD); + + CoinmateOpenOrders coinmateOpenOrders = getCoinmateOpenOrders(currencyPair); + return CoinmateAdapters.adaptOpenOrders(coinmateOpenOrders); } @Override @@ -66,7 +73,9 @@ public String placeLimitOrder(LimitOrder limitOrder) throws ExchangeException, N @Override public boolean cancelOrder(String orderId) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + CoinmateCancelOrderResponse response = cancelCoinmateOrder(orderId); + + return response.getData(); } @Override diff --git a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeServiceRaw.java b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeServiceRaw.java index 61773aa5780..87a924e48ec 100644 --- a/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeServiceRaw.java +++ b/xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateTradeServiceRaw.java @@ -26,6 +26,8 @@ import com.xeiam.xchange.Exchange; import com.xeiam.xchange.coinmate.CoinmateAuthenticated; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateCancelOrderResponse; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrders; import com.xeiam.xchange.coinmate.dto.trade.CoinmateTransactionHistory; import com.xeiam.xchange.coinmate.service.CoinmateDigest; import java.io.IOException; @@ -49,8 +51,29 @@ public CoinmateTradeServiceRaw(Exchange exchange) { } public CoinmateTransactionHistory getCoinmateTradeHistory(int offset, int limit, String sort) throws IOException { - return coinmateAuthenticated.getTransactionHistory(exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory(), + CoinmateTransactionHistory tradeHistory = coinmateAuthenticated.getTransactionHistory(exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory(), offset, limit, sort); + + throwExceptionIfError(tradeHistory); + + return tradeHistory; + } + + public CoinmateOpenOrders getCoinmateOpenOrders(String currencyPair) throws IOException { + CoinmateOpenOrders openOrders = coinmateAuthenticated.getOpenOrders(exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory(), currencyPair); + + throwExceptionIfError(openOrders); + + return openOrders; + + } + + public CoinmateCancelOrderResponse cancelCoinmateOrder(String orderId) throws IOException { + CoinmateCancelOrderResponse response = coinmateAuthenticated.cancelOder(exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory(), orderId); + + throwExceptionIfError(response); + + return response; } } diff --git a/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/BalanceJSONTest.java b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/BalanceJSONTest.java index 4be76c85b3e..a61499943d4 100644 --- a/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/BalanceJSONTest.java +++ b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/BalanceJSONTest.java @@ -25,7 +25,6 @@ package com.xeiam.xchange.coinmate.dto.account; import com.fasterxml.jackson.databind.ObjectMapper; -import com.xeiam.xchange.coinmate.dto.marketdata.CoinmateOrderBook; import com.xeiam.xchange.coinmate.dto.marketdata.OrderBookJSONTest; import java.io.IOException; import java.io.InputStream; @@ -43,7 +42,7 @@ public class BalanceJSONTest { public void testUnmarshal() throws IOException { // Read in the JSON from the example resources - InputStream is = OrderBookJSONTest.class.getResourceAsStream("/marketdata/example-balance.json"); + InputStream is = OrderBookJSONTest.class.getResourceAsStream("/account/example-balance.json"); ObjectMapper mapper = new ObjectMapper(); CoinmateBalance coinmateBalance = mapper.readValue(is, CoinmateBalance.class); diff --git a/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/OpenOrdersJSONTest.java b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/OpenOrdersJSONTest.java new file mode 100644 index 00000000000..838a92ae8a4 --- /dev/null +++ b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/dto/account/OpenOrdersJSONTest.java @@ -0,0 +1,60 @@ +/* + * The MIT License + * + * Copyright 2015 Coinmate. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.xeiam.xchange.coinmate.dto.account; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xeiam.xchange.coinmate.dto.marketdata.OrderBookJSONTest; +import com.xeiam.xchange.coinmate.dto.trade.CoinmateOpenOrders; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import static org.fest.assertions.api.Assertions.assertThat; +import org.junit.Test; + +/** + * + * @author Martin Stachon + */ +public class OpenOrdersJSONTest { + + + @Test + public void testUnmarshall() throws IOException { + + // Read in the JSON from the example resources + InputStream is = OrderBookJSONTest.class.getResourceAsStream("/account/example-open-orders.json"); + + ObjectMapper mapper = new ObjectMapper(); + CoinmateOpenOrders coinmateOrders = mapper.readValue(is, CoinmateOpenOrders.class); + + + // Verify that the example data was unmarshalled correctly + assertThat(coinmateOrders.getData().get(0).getId()).isEqualTo(32780L); + assertThat(coinmateOrders.getData().get(0).getTimestamp()).isEqualTo(1404383652640L); + assertThat(coinmateOrders.getData().get(0).getType()).isEqualTo("BUY"); + assertThat(coinmateOrders.getData().get(0).getPrice()).isEqualTo(new BigDecimal("1")); + assertThat(coinmateOrders.getData().get(0).getAmount()).isEqualTo(new BigDecimal("1")); + } +} diff --git a/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/service/polling/TradeServiceTest.java b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/service/polling/TradeServiceTest.java index 79f512cdb04..e1921c1b791 100644 --- a/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/service/polling/TradeServiceTest.java +++ b/xchange-coinmate/src/test/java/com/xeiam/xchange/coinmate/service/polling/TradeServiceTest.java @@ -3,6 +3,8 @@ import com.xeiam.xchange.Exchange; import com.xeiam.xchange.coinmate.ExchangeUtils; import com.xeiam.xchange.dto.marketdata.Trade; +import com.xeiam.xchange.dto.trade.LimitOrder; +import com.xeiam.xchange.dto.trade.OpenOrders; import com.xeiam.xchange.dto.trade.UserTrades; import com.xeiam.xchange.service.polling.trade.PollingTradeService; import org.junit.Test; @@ -10,7 +12,7 @@ import static org.junit.Assert.assertNotNull; /** - * Integration tests for AccountInfo retrieval. + * Integration tests for TradeService. * * For these tests to function, a file 'exchangeConfiguration.json' must be on * the classpath and contain valid api and secret keys. @@ -34,4 +36,21 @@ public void transactionHistoryTest() throws Exception { System.out.println(trade.toString()); } } + + @Test + public void openOrdersTest() throws Exception { + Exchange exchange = ExchangeUtils.createExchangeFromJsonConfiguration(); + if (exchange == null) { + return; // forces pass if not configuration is available + } + assertNotNull(exchange); + PollingTradeService service = exchange.getPollingTradeService(); + assertNotNull(service); + OpenOrders orders = service.getOpenOrders(); + assertNotNull(orders); + System.out.println("Got " + orders.getOpenOrders().size() + " orders."); + for (LimitOrder order : orders.getOpenOrders()) { + System.out.println(order.toString()); + } + } } diff --git a/xchange-coinmate/src/test/resources/marketdata/example-balance.json b/xchange-coinmate/src/test/resources/account/example-balance.json similarity index 100% rename from xchange-coinmate/src/test/resources/marketdata/example-balance.json rename to xchange-coinmate/src/test/resources/account/example-balance.json diff --git a/xchange-coinmate/src/test/resources/account/example-open-orders.json b/xchange-coinmate/src/test/resources/account/example-open-orders.json new file mode 100644 index 00000000000..a4f9da7b936 --- /dev/null +++ b/xchange-coinmate/src/test/resources/account/example-open-orders.json @@ -0,0 +1,622 @@ +{ + "error": false, + "errorMessage": null, + "data": [ + { + "id": 32780, + "timestamp": 1404383652640, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32784, + "timestamp": 1404383662360, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32807, + "timestamp": 1404389352547, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32810, + "timestamp": 1404389358072, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32705, + "timestamp": 1404315812833, + "type": "SELL", + "price": 1000, + "amount": 0.975 + }, + { + "id": 32423, + "timestamp": 1404306314334, + "type": "SELL", + "price": 1000, + "amount": 1.22155851 + }, + { + "id": 32431, + "timestamp": 1404306323983, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32440, + "timestamp": 1404306355735, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32448, + "timestamp": 1404306390212, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32456, + "timestamp": 1404306533012, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32332, + "timestamp": 1404301914163, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32464, + "timestamp": 1404306544471, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32472, + "timestamp": 1404306611364, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32480, + "timestamp": 1404306676064, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32494, + "timestamp": 1404307595421, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32502, + "timestamp": 1404307790221, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32729, + "timestamp": 1404378039899, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32737, + "timestamp": 1404378121082, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32813, + "timestamp": 1404390138986, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32300, + "timestamp": 1404297699047, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32306, + "timestamp": 1404297810337, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32311, + "timestamp": 1404297998137, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32316, + "timestamp": 1404298062448, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32321, + "timestamp": 1404298088713, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32326, + "timestamp": 1404299174783, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32371, + "timestamp": 1404304221400, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32574, + "timestamp": 1404310255608, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32575, + "timestamp": 1404310255786, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32630, + "timestamp": 1404311655210, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32631, + "timestamp": 1404311655399, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32638, + "timestamp": 1404311729078, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32639, + "timestamp": 1404311729278, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32646, + "timestamp": 1404311800689, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32647, + "timestamp": 1404311800850, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32654, + "timestamp": 1404311888092, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32655, + "timestamp": 1404311888257, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32664, + "timestamp": 1404312005447, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32672, + "timestamp": 1404312035291, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32692, + "timestamp": 1404315449399, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32697, + "timestamp": 1404315490522, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32787, + "timestamp": 1404388854016, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32789, + "timestamp": 1404388858810, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32792, + "timestamp": 1404388877162, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32794, + "timestamp": 1404388879723, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32797, + "timestamp": 1404388925241, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32799, + "timestamp": 1404388927887, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32802, + "timestamp": 1404389215915, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32804, + "timestamp": 1404389218166, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32208, + "timestamp": 1404231955278, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32210, + "timestamp": 1404232090891, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32212, + "timestamp": 1404232119150, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32249, + "timestamp": 1404292346856, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32254, + "timestamp": 1404292405216, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32259, + "timestamp": 1404292537654, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32264, + "timestamp": 1404292620342, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32269, + "timestamp": 1404292914841, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32510, + "timestamp": 1404309365092, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32511, + "timestamp": 1404309365316, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32518, + "timestamp": 1404309427711, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32519, + "timestamp": 1404309428229, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32526, + "timestamp": 1404309689125, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32527, + "timestamp": 1404309689324, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32534, + "timestamp": 1404309757247, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32535, + "timestamp": 1404309757420, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32542, + "timestamp": 1404309771946, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32543, + "timestamp": 1404309772098, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32550, + "timestamp": 1404309867636, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32551, + "timestamp": 1404309867894, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32487, + "timestamp": 1404306926984, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32488, + "timestamp": 1404306927204, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32285, + "timestamp": 1404296713855, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32290, + "timestamp": 1404296888282, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32295, + "timestamp": 1404297320485, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32590, + "timestamp": 1404310755203, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32598, + "timestamp": 1404310969469, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32599, + "timestamp": 1404310970177, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32606, + "timestamp": 1404310984873, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32607, + "timestamp": 1404310985073, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32614, + "timestamp": 1404311003150, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32615, + "timestamp": 1404311003334, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32622, + "timestamp": 1404311018667, + "type": "SELL", + "price": 1000, + "amount": 2 + }, + { + "id": 32678, + "timestamp": 1404314697420, + "type": "SELL", + "price": 1000, + "amount": 1 + }, + { + "id": 32759, + "timestamp": 1404378655792, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32763, + "timestamp": 1404378658214, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32766, + "timestamp": 1404378710782, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32770, + "timestamp": 1404378713383, + "type": "SELL", + "price": 1000000, + "amount": 1 + }, + { + "id": 32773, + "timestamp": 1404383286817, + "type": "BUY", + "price": 1, + "amount": 1 + }, + { + "id": 32777, + "timestamp": 1404383292245, + "type": "SELL", + "price": 1000000, + "amount": 1 + } + ] +} \ No newline at end of file