diff --git a/pom.xml b/pom.xml index 2cd7afb84f0..b588f7180f0 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,6 @@ xchange-stream-service-core xchange-stream-service-netty xchange-stream-service-pubnub - xchange-therock xchange-tradeogre xchange-truefx xchange-upbit diff --git a/xchange-examples/pom.xml b/xchange-examples/pom.xml index 04799f32d7d..373a05413cd 100755 --- a/xchange-examples/pom.xml +++ b/xchange-examples/pom.xml @@ -308,11 +308,6 @@ xchange-ripple ${project.version} - - ${project.groupId} - xchange-therock - ${project.version} - ${project.groupId} xchange-upbit diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockExampleUtils.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockExampleUtils.java deleted file mode 100644 index 10626db0a81..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockExampleUtils.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.examples.therock; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.therock.TheRockExchange; - -public class TheRockExampleUtils { - - private TheRockExampleUtils() {} - - public static Exchange createTestExchange() { - Exchange exchange = ExchangeFactory.INSTANCE.createExchange(TheRockExchange.class); - exchange.getExchangeSpecification().setApiKey("API Key"); - exchange.getExchangeSpecification().setSecretKey("Secret=="); - exchange.getExchangeSpecification().setUserName("user"); - exchange.applySpecification(exchange.getExchangeSpecification()); - return exchange; - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockMetaDataDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockMetaDataDemo.java deleted file mode 100644 index 4f68c618148..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/TheRockMetaDataDemo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.knowm.xchange.examples.therock; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.dto.meta.ExchangeMetaData; -import org.knowm.xchange.instrument.Instrument; -import org.knowm.xchange.therock.TheRockExchange; - -public class TheRockMetaDataDemo { - - public static void main(String[] args) throws IOException { - - // Use the factory to get The Rock exchange API using default settings - Exchange exchange = ExchangeFactory.INSTANCE.createExchange(TheRockExchange.class); - ExchangeMetaData exchangeMetaData = exchange.getExchangeMetaData(); - System.out.println(exchangeMetaData.toString()); - - for (Instrument currencyPair : exchangeMetaData.getInstruments().keySet()) { - System.out.println(currencyPair.toString()); - } - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/account/TheRockAccountDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/account/TheRockAccountDemo.java deleted file mode 100644 index 9869de81a8e..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/account/TheRockAccountDemo.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.knowm.xchange.examples.therock.account; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.examples.therock.TheRockExampleUtils; -import org.knowm.xchange.therock.service.TheRockAccountServiceRaw; - -public class TheRockAccountDemo { - - public static void main(String[] args) throws IOException { - Exchange loyalbitExchange = TheRockExampleUtils.createTestExchange(); - - generic(loyalbitExchange); - raw(loyalbitExchange); - } - - private static void generic(Exchange loyalbitExchange) throws IOException { - AccountInfo accountInfo = loyalbitExchange.getAccountService().getAccountInfo(); - System.out.println("Account Info: " + accountInfo); - } - - private static void raw(Exchange loyalbitExchange) throws IOException { - TheRockAccountServiceRaw rawTheRockAcctService = - (TheRockAccountServiceRaw) loyalbitExchange.getAccountService(); - System.out.println("Balance Info: " + rawTheRockAcctService.balances()); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/marketdata/TheRockMarketDataDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/marketdata/TheRockMarketDataDemo.java deleted file mode 100644 index 7be9ab3c33d..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/marketdata/TheRockMarketDataDemo.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.knowm.xchange.examples.therock.marketdata; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.service.marketdata.MarketDataService; -import org.knowm.xchange.therock.TheRockExchange; - -public class TheRockMarketDataDemo { - - public static void main(String[] args) throws IOException { - - // Use the factory to get TheRock exchange API using default settings - Exchange theRockExchange = ExchangeFactory.INSTANCE.createExchange(TheRockExchange.class); - - generic(theRockExchange); - } - - private static void generic(Exchange loyalbitExchange) throws IOException { - - // Interested in the public market data feed (no authentication) - MarketDataService loyalbitMarketDataService = loyalbitExchange.getMarketDataService(); - - // Get the ticker - System.out.println("Ticker: " + loyalbitMarketDataService.getTicker(CurrencyPair.BTC_USD)); - - // Get the order book - System.out.println( - "Order book: " + loyalbitMarketDataService.getOrderBook(CurrencyPair.BTC_USD)); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeDemo.java deleted file mode 100644 index f724cb8418b..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.knowm.xchange.examples.therock.trade; - -import java.io.IOException; -import java.math.BigDecimal; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.examples.therock.TheRockExampleUtils; -import org.knowm.xchange.therock.service.TheRockTradeService; - -public class TheRockTradeDemo { - - public static final CurrencyPair BTC_EUR = CurrencyPair.BTC_EUR; - - public static void main(String[] args) throws Exception { - Exchange theRockExchange = TheRockExampleUtils.createTestExchange(); - generic(theRockExchange); - } - - private static void generic(Exchange theRockExchange) throws IOException, InterruptedException { - // create - TheRockTradeService tradeService = (TheRockTradeService) theRockExchange.getTradeService(); - BigDecimal amount = new BigDecimal("0.01"); - BigDecimal price = new BigDecimal("50.0"); - LimitOrder limitOrder = new LimitOrder(OrderType.BID, amount, BTC_EUR, null, null, price); - String id = tradeService.placeLimitOrder(limitOrder); - Thread.sleep(3000); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeRawDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeRawDemo.java deleted file mode 100644 index a56e73f8fc1..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/therock/trade/TheRockTradeRawDemo.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.knowm.xchange.examples.therock.trade; - -import java.io.IOException; -import java.math.BigDecimal; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.examples.therock.TheRockExampleUtils; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrder.Side; -import org.knowm.xchange.therock.dto.trade.TheRockOrder.Type; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; -import org.knowm.xchange.therock.service.TheRockTradeServiceRaw; - -public class TheRockTradeRawDemo { - - public static final CurrencyPair BTC_EUR = CurrencyPair.BTC_EUR; - - public static void main(String[] args) throws Exception { - Exchange theRockExchange = TheRockExampleUtils.createTestExchange(); - raw(theRockExchange); - } - - private static void raw(Exchange theRockExchange) throws IOException, InterruptedException { - TheRockTradeServiceRaw tradeService = - (TheRockTradeServiceRaw) theRockExchange.getTradeService(); - - // create order - BigDecimal amount = new BigDecimal("0.01"); - BigDecimal price = new BigDecimal("50.0"); - TheRock.Pair pair = new TheRock.Pair(BTC_EUR); - TheRockOrder order = new TheRockOrder(pair, Side.buy, Type.limit, amount, price); - TheRockOrder orderResult = tradeService.placeTheRockOrder(BTC_EUR, order); - print(orderResult); - Thread.sleep(3000); - - // show-order - orderResult = tradeService.showTheRockOrder(BTC_EUR, orderResult.getId()); - print(orderResult); - Thread.sleep(3000); - - // get-orders (without any parameters besides pair, only open orders will be returned) - TheRockOrders orders = tradeService.getTheRockOrders(BTC_EUR); - print(orders); - Thread.sleep(3000); - - // get execute orders, only page 1 - TheRockOrders executedOrders = - tradeService.getTheRockOrders(BTC_EUR, null, null, "executed", null, null, 1); - print(executedOrders); - Thread.sleep(3000); - - // get only executed sell order, starting on page 3 - TheRockOrders execSellOrders = - tradeService.getTheRockOrders(BTC_EUR, null, null, "executed", Side.sell, null, 1); - print(execSellOrders); - Thread.sleep(3000); - - // cancel - tradeService.cancelTheRockOrder(BTC_EUR, orderResult.getId()); - Thread.sleep(3000); - } - - private static void print(Object object) { - System.out.println(); - } -} diff --git a/xchange-therock/api-specification.txt b/xchange-therock/api-specification.txt deleted file mode 100644 index 2b66bfc3d46..00000000000 --- a/xchange-therock/api-specification.txt +++ /dev/null @@ -1,6 +0,0 @@ -The Rock Trading Exchange API specification -================================ - -Documentation -------------- -https://api.therocktrading.com/doc/v1/ diff --git a/xchange-therock/pom.xml b/xchange-therock/pom.xml deleted file mode 100644 index 15dcc3087f9..00000000000 --- a/xchange-therock/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - 4.0.0 - - - org.knowm.xchange - xchange-parent - 5.2.1-SNAPSHOT - - - xchange-therock - - XChange The Rock Trading - XChange implementation for The Rock Trading Exchange - - http://knowm.org/open-source/xchange/ - 2012 - - - Knowm Inc. - http://knowm.org/open-source/xchange/ - - - - - - - org.knowm.xchange - xchange-core - ${project.version} - - - - - diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRock.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRock.java deleted file mode 100644 index 617ace23c34..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRock.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.knowm.xchange.therock; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.MediaType; -import java.io.IOException; -import java.util.Date; -import java.util.Objects; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.marketdata.TheRockOrderBook; -import org.knowm.xchange.therock.dto.marketdata.TheRockTicker; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrades; -import org.knowm.xchange.utils.jackson.CurrencyPairDeserializer; - -// see https://www.therocktrading.com/pages/api -@Path("v1") -@Produces(MediaType.APPLICATION_JSON) -public interface TheRock { - - // TODO review - inconsistent https://www.therocktrading.com/pages/api - @GET - @Path("funds/{id}/ticker") - TheRockTicker getTicker(@PathParam("id") Pair currencyPair) throws TheRockException, IOException; - - // TODO review - inconsistent https://www.therocktrading.com/pages/api - @GET - @Path("funds/{id}/orderbook") - TheRockOrderBook getOrderbook(@PathParam("id") Pair currencyPair) - throws TheRockException, IOException; - - @GET - @Path("funds/{id}/trades") - TheRockTrades getTrades(@PathParam("id") Pair currencyPair, @QueryParam("after") Date after) - throws IOException; - - class Pair { - public final CurrencyPair pair; - - public Pair(CurrencyPair pair) { - if (pair == null) { - throw new IllegalArgumentException("Currency pair required."); - } - this.pair = pair; - } - - public Pair(String pair) { - this(CurrencyPairDeserializer.getCurrencyPairFromString(pair)); - } - - @Override - public boolean equals(Object o) { - return this == o - || !(o == null || getClass() != o.getClass()) && Objects.equals(pair, ((Pair) o).pair); - } - - @Override - public int hashCode() { - return Objects.hash(pair); - } - - @Override - public String toString() { - return String.format("%s%s", pair.base.getCurrencyCode(), pair.counter.getCurrencyCode()); - } - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAdapters.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAdapters.java deleted file mode 100644 index 6891ab863ee..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAdapters.java +++ /dev/null @@ -1,210 +0,0 @@ -package org.knowm.xchange.therock; - -import static org.knowm.xchange.dto.Order.OrderType.ASK; -import static org.knowm.xchange.dto.Order.OrderType.BID; -import static org.knowm.xchange.utils.DateUtils.fromISODateString; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.dto.account.Balance; -import org.knowm.xchange.dto.account.Wallet; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Trade; -import org.knowm.xchange.dto.marketdata.Trades; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.therock.dto.account.TheRockBalance; -import org.knowm.xchange.therock.dto.marketdata.TheRockBid; -import org.knowm.xchange.therock.dto.marketdata.TheRockOrderBook; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrade; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrade.Side; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrades; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; -import org.knowm.xchange.therock.dto.trade.TheRockUserTrade; -import org.knowm.xchange.therock.dto.trade.TheRockUserTrades; - -public final class TheRockAdapters { - - private TheRockAdapters() {} - - public static TheRockOrder.Side adaptSide(OrderType type) { - return type == BID ? TheRockOrder.Side.buy : TheRockOrder.Side.sell; - } - - public static AccountInfo adaptAccountInfo(List trBalances, String userName) { - ArrayList balances = new ArrayList<>(trBalances.size()); - for (TheRockBalance blc : trBalances) { - Currency currency = Currency.getInstance(blc.getCurrency()); - balances.add(new Balance(currency, blc.getBalance(), blc.getTradingBalance())); - } - - return new AccountInfo(userName, Wallet.Builder.from(balances).id("spot").build()); - } - - public static OrderBook adaptOrderBook(TheRockOrderBook theRockOrderBook) { - final List asks = new ArrayList<>(); - final List bids = new ArrayList<>(); - for (TheRockBid theRockBid : theRockOrderBook.getAsks()) { - asks.add( - adaptBid( - theRockOrderBook.getCurrencyPair(), ASK, theRockBid, theRockOrderBook.getDate())); - } - for (TheRockBid theRockBid : theRockOrderBook.getBids()) { - bids.add( - adaptBid( - theRockOrderBook.getCurrencyPair(), BID, theRockBid, theRockOrderBook.getDate())); - } - return new OrderBook(theRockOrderBook.getDate(), asks, bids); - } - - private static LimitOrder adaptBid( - CurrencyPair currencyPair, Order.OrderType orderType, TheRockBid theRockBid, Date timestamp) { - return new LimitOrder.Builder(orderType, currencyPair) - .limitPrice(theRockBid.getPrice()) - .originalAmount(theRockBid.getAmount()) - .timestamp(timestamp) - .build(); - } - - public static Trades adaptTrades(TheRockTrades trades, CurrencyPair currencyPair) { - - List tradesList = new ArrayList<>(trades.getCount()); - long lastTradeId = 0; - for (int i = 0; i < trades.getCount(); i++) { - TheRockTrade trade = trades.getTrades()[i]; - if (trade.getSide() != Side.buy && trade.getSide() != Side.sell) { - continue; // process buys and sells only - } - long tradeId = trade.getId(); - if (tradeId > lastTradeId) lastTradeId = tradeId; - tradesList.add(adaptTrade(trade, currencyPair)); - } - return new Trades(tradesList, lastTradeId, Trades.TradeSortType.SortByID); - } - - public static Trade adaptTrade(TheRockTrade trade, CurrencyPair currencyPair) { - final String tradeId = String.valueOf(trade.getId()); - return new Trade.Builder() - .type(trade.getSide() == Side.sell ? OrderType.ASK : BID) - .originalAmount(trade.getAmount()) - .currencyPair(currencyPair) - .price(trade.getPrice()) - .timestamp(trade.getDate()) - .id(tradeId) - .build(); - } - - public static UserTrade adaptUserTrade(TheRockUserTrade trade, CurrencyPair currencyPair) { - final String tradeId = String.valueOf(trade.getId()); - // return new UserTrade(trade.getSide() == Side.sell ? OrderType.ASK : BID, trade.getAmount(), - // currencyPair, trade.getPrice(), trade.getDate(), tradeId); - return UserTrade.builder() - .id(tradeId) - .originalAmount(trade.getAmount()) - .currencyPair(currencyPair) - .price(trade.getPrice()) - .timestamp(trade.getDate()) - .orderId(String.valueOf(trade.getOrderId())) - .type(trade.getSide() == Side.buy ? OrderType.BID : OrderType.ASK) - .feeAmount(trade.getFeeAmount()) - .feeCurrency( - trade.getFeeCurrency() == null ? null : Currency.getInstance(trade.getFeeCurrency())) - .build(); - } - - public static UserTrades adaptUserTrades(TheRockUserTrades trades, CurrencyPair currencyPair) { - - List tradesList = new ArrayList<>(trades.getCount()); - long lastTradeId = 0; - for (int i = 0; i < trades.getCount(); i++) { - TheRockUserTrade trade = trades.getTrades()[i]; - long tradeId = trade.getId(); - if (tradeId > lastTradeId) lastTradeId = tradeId; - tradesList.add(adaptUserTrade(trade, currencyPair)); - } - return new UserTrades(tradesList, lastTradeId, Trades.TradeSortType.SortByID); - } - - public static LimitOrder adaptOrder(TheRockOrder order) { - Date timestamp; - try { - timestamp = order.getDate() == null ? null : fromISODateString(order.getDate()); - } catch (Exception e) { - timestamp = null; - } - BigDecimal amount = order.getAmount(); - BigDecimal unfilled = order.getAmountUnfilled(); - BigDecimal cumulative = (unfilled != null && amount != null) ? amount.subtract(unfilled) : null; - - return new LimitOrder( - adaptOrderType(order.getSide()), - order.getAmount(), - order.getFundId().pair, - Long.toString(order.getId()), - timestamp, - order.getPrice(), // limitPrice - order.getPrice(), // averagePrice - cumulative, - null, - adaptOrderStatus(order)); - } - - public static OrderType adaptOrderType(TheRockOrder.Side orderSide) { - return orderSide.equals(TheRockOrder.Side.buy) ? OrderType.BID : OrderType.ASK; - } - - public static OpenOrders adaptOrders(TheRockOrders theRockOrders) { - List orders = new ArrayList<>(theRockOrders.getOrders().length); - - for (TheRockOrder theRockOrder : theRockOrders.getOrders()) { - orders.add(adaptOrder(theRockOrder)); - } - - return new OpenOrders(orders); - } - - /** - * The status from the {@link TheRock} object converted to xchange status By the API documentation - * available order states are the follow: (active|conditional|executed|deleted) - */ - public static org.knowm.xchange.dto.Order.OrderStatus adaptOrderStatus(TheRockOrder order) { - if ("active".equalsIgnoreCase(order.getStatus())) { - return org.knowm.xchange.dto.Order.OrderStatus.NEW; - } else if ("conditional".equalsIgnoreCase(order.getStatus())) { - return org.knowm.xchange.dto.Order.OrderStatus.NEW; - } else if ("executed".equalsIgnoreCase(order.getStatus())) { - return org.knowm.xchange.dto.Order.OrderStatus.FILLED; - } else if ("deleted".equalsIgnoreCase(order.getStatus())) { - return org.knowm.xchange.dto.Order.OrderStatus.CANCELED; - } else return org.knowm.xchange.dto.Order.OrderStatus.UNKNOWN; - } - - /* - * public static LimitOrder adaptOrder(TheRockOrder o) { return new LimitOrder(adaptOrderType(o.getSide()), o.getAmount(), o.getFundId().pair, - * Long.toString(o.getId()), null, o.getPrice()); } public static Order.OrderType adaptOrderType(TheRockOrder.Side orderSide) { return - * orderSide.equals(TheRockOrder.Side.buy) ? Order.OrderType.BID : Order.OrderType.ASK; } public static OrderBook adaptOrderBook(TheRockOrderBook - * therockOrderBook) { List asks = new ArrayList(); List bids = new ArrayList(); for - * (TheRockOrderBook.Entry obe : therockOrderBook.getData()) { if (TheRockOrder.Type.Buy.equals(obe.getType())) { bids.add(new - * LimitOrder(Order.OrderType.BID, obe.getQuantity(), obe.getCurrencyPair(), null, obe.getCreated(), obe.getPrice())); } else { asks.add(new - * LimitOrder(Order.OrderType.ASK, obe.getQuantity(), obe.getCurrencyPair(), null, obe.getCreated(), obe.getPrice())); } } Collections.sort(bids, - * BID_COMPARATOR); Collections.sort(asks, ASK_COMPARATOR); return new OrderBook(new Date(), asks, bids); } public static UserTrades - * adaptTradeHistory(TheRockUserTrade[] therockUserTrades) { List trades = new ArrayList(); long lastTradeId = 0; for - * (TheRockUserTrade therockUserTrade : therockUserTrades) { lastTradeId = Math.max(lastTradeId, therockUserTrade.getTradeId()); - * trades.add(adaptTrade(therockUserTrade)); } return new UserTrades(trades, lastTradeId, TradeSortType.SortByID); } public static UserTrade - * adaptTrade(TheRockUserTrade therockUserTrade) { CurrencyPair currencyPair = therockUserTrade.getCurrencyPair(); return new UserTrade( - * adaptOrderType(therockUserTrade.getType()), therockUserTrade.getQuantity(), currencyPair, therockUserTrade.getPrice().abs(), - * therockUserTrade.getExecuted(), String.valueOf(therockUserTrade.getTradeId()), String.valueOf(therockUserTrade.getOrderId()), - * therockUserTrade.getFee(), therockUserTrade.getType() == TheRockOrder.Type.Buy ? currencyPair.counter.getCurrencyCode() : - * currencyPair.base.getCurrencyCode()); } - */ -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticated.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticated.java deleted file mode 100644 index e85e24b223b..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticated.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.knowm.xchange.therock; - -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.DELETE; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.HeaderParam; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.MediaType; -import java.io.IOException; -import java.util.Date; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.account.TheRockBalance; -import org.knowm.xchange.therock.dto.account.TheRockBalances; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawal; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawalResponse; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; -import org.knowm.xchange.therock.dto.trade.TheRockTransactions; -import org.knowm.xchange.therock.dto.trade.TheRockUserTrades; -import org.knowm.xchange.therock.service.TheRockDigest; -import si.mazi.rescu.SynchronizedValueFactory; - -@Path("v1") -@Produces(MediaType.APPLICATION_JSON) -public interface TheRockAuthenticated { - - String X_TRT_SIGN = "X-TRT-SIGN"; - String X_TRT_KEY = "X-TRT-KEY"; - String X_TRT_NONCE = "X-TRT-NONCE"; - - // account - - @GET - @Path("balances/{currency}") - TheRockBalance balance( - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - @PathParam("currency") String currency) - throws TheRockException, IOException; - - @GET - @Path("balances") - TheRockBalances balances( - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory) - throws TheRockException, IOException; - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("atms/withdraw") - TheRockWithdrawalResponse withdraw( - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - TheRockWithdrawal withdrawal) - throws TheRockException, IOException; - - // trading - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("funds/{fund_id}/orders") - TheRockOrder placeOrder( - @PathParam("fund_id") TheRock.Pair currencyPair, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - TheRockOrder order) - throws TheRockException, IOException; - - @DELETE - @Path("funds/{fund_id}/orders/{id}") - TheRockOrder cancelOrder( - @PathParam("fund_id") TheRock.Pair currencyPair, - @PathParam("id") Long orderId, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory) - throws TheRockException, IOException; - - @GET - @Path("funds/{fund_id}/orders") - TheRockOrders orders( - @PathParam("fund_id") TheRock.Pair currencyPair, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory) - throws TheRockException, IOException; - - @GET - @Path("funds/{fund_id}/orders") - TheRockOrders orders( - @PathParam("fund_id") TheRock.Pair currencyPair, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - @QueryParam("after") Date after, - @QueryParam("before") Date before, - @QueryParam("status") String status, - @QueryParam("side") TheRockOrder.Side side, - @QueryParam("position_id") Long positionId, - @QueryParam("page") int page) - throws TheRockException, IOException; - - @GET - @Path("funds/{fund_id}/orders/{id}") - TheRockOrder showOrder( - @PathParam("fund_id") TheRock.Pair currencyPair, - @PathParam("id") Long orderId, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory) - throws TheRockException, IOException; - - @GET - @Path("funds/{fund_id}/trades") - TheRockUserTrades trades( - @PathParam("fund_id") TheRock.Pair currencyPair, - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - @QueryParam("trade_id") Long sinceTradeId, - @QueryParam("after") Date after, - @QueryParam("before") Date before, - @QueryParam("per_page") int perPage, - @QueryParam("page") int page) - throws TheRockException, IOException; - - @GET - @Path("transactions") - TheRockTransactions transactions( - @HeaderParam(X_TRT_KEY) String publicKey, - @HeaderParam(X_TRT_SIGN) TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - @QueryParam("type") String type, - @QueryParam("after") Date after, - @QueryParam("before") Date before, - @QueryParam("currency") String currency, - @QueryParam("page") Integer page) - throws TheRockException, IOException; -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticatedV0.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticatedV0.java deleted file mode 100644 index fe7ccd654bb..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockAuthenticatedV0.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.knowm.xchange.therock; - -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.HeaderParam; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; -import java.io.IOException; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.service.TheRockDigest; -import si.mazi.rescu.SynchronizedValueFactory; - -/** The old API V0 https://api.therocktrading.com/doc/v0/index.html#api-Trading_API-GetOrders */ -@Path("api") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public interface TheRockAuthenticatedV0 { - - String X_TRT_NONCE = "X-TRT-NONCE"; - - // account - - @POST - @Path("get_orders") - TheRockOrder placeOrder( - @HeaderParam("X-TRT-KEY") String publicKey, - @HeaderParam("X-TRT-SIGN") TheRockDigest signer, - @HeaderParam(X_TRT_NONCE) SynchronizedValueFactory nonceFactory, - TheRockOrder order) - throws TheRockException, IOException; -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockExchange.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockExchange.java deleted file mode 100644 index 35d513af530..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/TheRockExchange.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.knowm.xchange.therock; - -import org.knowm.xchange.BaseExchange; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.therock.service.TheRockAccountService; -import org.knowm.xchange.therock.service.TheRockMarketDataService; -import org.knowm.xchange.therock.service.TheRockTradeService; -import org.knowm.xchange.utils.nonce.TimestampIncrementingNonceFactory; -import si.mazi.rescu.SynchronizedValueFactory; - -/** - * @author Matija Mazi - */ -public class TheRockExchange extends BaseExchange implements Exchange { - /** - * @deprecated use TheRockCancelOrderParams instead - */ - public static final String CURRENCY_PAIR = "CURRENCY_PAIR"; - - private SynchronizedValueFactory nonceFactory = new TimestampIncrementingNonceFactory(); - - @Override - public void applySpecification(ExchangeSpecification exchangeSpecification) { - super.applySpecification(exchangeSpecification); - } - - @Override - protected void initServices() { - this.marketDataService = new TheRockMarketDataService(this); - if (exchangeSpecification.getApiKey() != null && exchangeSpecification.getSecretKey() != null) { - this.tradeService = new TheRockTradeService(this); - this.accountService = new TheRockAccountService(this); - } - } - - @Override - public ExchangeSpecification getDefaultExchangeSpecification() { - ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass()); - exchangeSpecification.setSslUri("https://api.therocktrading.com"); - exchangeSpecification.setHost("api.therocktrading.com"); - exchangeSpecification.setPort(80); - exchangeSpecification.setExchangeName("The Rock Trading"); - return exchangeSpecification; - } - - @Override - public SynchronizedValueFactory getNonceFactory() { - return nonceFactory; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockCancelOrderParams.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockCancelOrderParams.java deleted file mode 100644 index 91e8d722287..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockCancelOrderParams.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.knowm.xchange.therock.dto; - -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair; -import org.knowm.xchange.service.trade.params.CancelOrderByIdParams; - -public class TheRockCancelOrderParams implements CancelOrderByIdParams, CancelOrderByCurrencyPair { - public final CurrencyPair currencyPair; - public final Long orderId; - - public TheRockCancelOrderParams(CurrencyPair currencyPair, Long orderId) { - this.currencyPair = currencyPair; - this.orderId = orderId; - } - - @Override - public CurrencyPair getCurrencyPair() { - return currencyPair; - } - - @Override - public String getOrderId() { - return orderId.toString(); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockException.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockException.java deleted file mode 100644 index 5f0bba03573..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/TheRockException.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.knowm.xchange.therock.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; -import java.util.Map; -import si.mazi.rescu.HttpStatusExceptionSupport; - -public class TheRockException extends HttpStatusExceptionSupport { - - private List errors; - - protected TheRockException() {} - - public TheRockException(@JsonProperty("errors") List errors) { - super(getFirstMessage(errors)); - this.errors = errors; - } - - private static String getFirstMessage(List errors) { - return errors == null || errors.isEmpty() ? null : errors.get(0).getMessage(); - } - - public List getErrors() { - return errors; - } - - public static class Error { - private String message; - private Integer code; - private Map meta; - - public String getMessage() { - return message; - } - - public Integer getCode() { - return code; - } - - public Map getMeta() { - return meta; - } - - @Override - public String toString() { - return String.format("Error{message='%s', code=%d, meta=%s}", message, code, meta); - } - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalance.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalance.java deleted file mode 100644 index 7ae9f1546bd..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalance.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.knowm.xchange.therock.dto.account; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.math.BigDecimal; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockBalance { - - private String currency; - - private BigDecimal balance; - - private BigDecimal tradingBalance; - - public String getCurrency() { - return currency; - } - - public BigDecimal getBalance() { - return balance; - } - - public BigDecimal getTradingBalance() { - return tradingBalance; - } - - @Override - public String toString() { - return String.format( - "TheRockBalance{currency='%s', balance=%s, trandingBalance=%s}", - currency, balance, tradingBalance); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalances.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalances.java deleted file mode 100644 index f3593994bf8..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockBalances.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.knowm.xchange.therock.dto.account; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.util.List; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockBalances { - - private List balances; - - public List getBalances() { - return balances; - } - - @Override - public String toString() { - return String.format("TheRockBalances{balances=%s}", balances); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawal.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawal.java deleted file mode 100644 index dd8930c2c9c..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawal.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.knowm.xchange.therock.dto.account; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.math.BigDecimal; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockWithdrawal { - - private String currency; - - /** Should be null for the default method (ie. not Ripple) */ - private Method withdrawMethod; - - private String destinationAddress; - - private Long destinationTag = null; - - private BigDecimal amount; - - private TheRockWithdrawal(String currency, BigDecimal amount, String destinationAddress) { - this(currency, amount, destinationAddress, null, null); - } - - private TheRockWithdrawal( - String currency, - BigDecimal amount, - String destinationAddress, - Method withdrawMethod, - Long destinationTag) { - this.currency = currency; - this.amount = amount; - this.destinationAddress = destinationAddress; - this.withdrawMethod = withdrawMethod; - this.destinationTag = destinationTag; - } - - public static TheRockWithdrawal createRippleWithdrawal( - String currency, BigDecimal amount, String destinationAddress, Long destinationTag) { - return new TheRockWithdrawal( - currency, amount, destinationAddress, Method.RIPPLE, destinationTag); - } - - public static TheRockWithdrawal createDefaultWithdrawal( - String currency, BigDecimal amount, String destinationAddress) { - return new TheRockWithdrawal(currency, amount, destinationAddress); - } - - public String getCurrency() { - return currency; - } - - public Method getWithdrawMethod() { - return withdrawMethod; - } - - public String getDestinationAddress() { - return destinationAddress; - } - - public Long getDestinationTag() { - return destinationTag; - } - - public BigDecimal getAmount() { - return amount; - } - - @Override - public String toString() { - return String.format( - "TheRockWithdrawal{currency='%s', withdrawMethod='%s', destinationAddress='%s', amount=%s}", - currency, - withdrawMethod == null ? "" : withdrawMethod, - destinationAddress, - amount); - } - - public enum Method { - RIPPLE - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawalResponse.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawalResponse.java deleted file mode 100644 index 054430b662c..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/account/TheRockWithdrawalResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.therock.dto.account; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockWithdrawalResponse { - - private Integer transactionId; - - public Integer getTransactionId() { - return transactionId; - } - - @Override - public String toString() { - return String.format("TheRockWithdrawalResponse{transactionId=%d}", transactionId); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockBid.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockBid.java deleted file mode 100644 index e2fcebe268d..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockBid.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.knowm.xchange.therock.dto.marketdata; - -import java.math.BigDecimal; - -public class TheRockBid { - private BigDecimal price, amount; - - public BigDecimal getPrice() { - return price; - } - - public BigDecimal getAmount() { - return amount; - } - - @Override - public String toString() { - return String.format("TheRockBid{price=%s, amount=%s}", price, amount); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockOrderBook.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockOrderBook.java deleted file mode 100644 index 8a67ddb18ed..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockOrderBook.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.knowm.xchange.therock.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.util.Date; -import java.util.List; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.utils.jackson.CurrencyPairDeserializer; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockOrderBook { - - @JsonProperty("fund_id") - @JsonDeserialize(using = CurrencyPairDeserializer.class) - private CurrencyPair currencyPair; - - private Date date; - - private List bids; - - private List asks; - - public CurrencyPair getCurrencyPair() { - return currencyPair; - } - - public Date getDate() { - return date; - } - - public List getBids() { - return bids; - } - - public List getAsks() { - return asks; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTicker.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTicker.java deleted file mode 100644 index 795c7dce37d..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTicker.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.knowm.xchange.therock.dto.marketdata; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.math.BigDecimal; -import java.util.Date; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.utils.jackson.CurrencyPairDeserializer; - -/** - * @author Matija Mazi - */ -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockTicker { - - @JsonDeserialize(using = CurrencyPairDeserializer.class) - private CurrencyPair fundId; - - private Date date; - - private BigDecimal bid, ask, last, volume, volumeTraded, open, high, low, close; - - public CurrencyPair getFundId() { - return fundId; - } - - public Date getDate() { - return date; - } - - public BigDecimal getBid() { - return bid; - } - - public BigDecimal getAsk() { - return ask; - } - - public BigDecimal getLast() { - return last; - } - - public BigDecimal getVolume() { - return volume; - } - - public BigDecimal getVolumeTraded() { - return volumeTraded; - } - - public BigDecimal getOpen() { - return open; - } - - public BigDecimal getHigh() { - return high; - } - - public BigDecimal getLow() { - return low; - } - - public BigDecimal getClose() { - return close; - } - - @Override - public String toString() { - return String.format( - "TheRockTicker{currencyPair=%s, date=%s, bid=%s, ask=%s, last=%s, volume=%s, volumeTraed=%s, open=%s, high=%s, low=%s, close=%s}", - fundId, date, bid, ask, last, volume, volumeTraded, open, high, low, close); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrade.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrade.java deleted file mode 100644 index 111b3828a24..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrade.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.knowm.xchange.therock.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -public class TheRockTrade { - - private final BigDecimal amount; - private final Date date; - private final BigDecimal price; - private final long id; - private final Side side; - - public TheRockTrade( - @JsonProperty("amount") BigDecimal amount, - @JsonProperty("date") Date date, - @JsonProperty("price") BigDecimal price, - @JsonProperty("id") long id, - @JsonProperty("side") Side tradeSide) { - this.amount = amount; - this.date = date; - this.price = price; - this.id = id; - this.side = tradeSide; - } - - public BigDecimal getAmount() { - return amount; - } - - public Date getDate() { - return date; - } - - public BigDecimal getPrice() { - return price; - } - - public long getId() { - return id; - } - - public Side getSide() { - return side; - } - - @Override - public String toString() { - return "TheRockTrade [amount=" - + amount - + ", date=" - + date - + ", price=" - + price - + ", id=" - + id - + ", side=" - + side - + "]"; - } - - public enum Side { - sell, - buy, - close_long, - close_short - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrades.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrades.java deleted file mode 100644 index 5893f07eab1..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/marketdata/TheRockTrades.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.knowm.xchange.therock.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Arrays; - -public class TheRockTrades { - - private final TheRockTrade[] trades; - - public TheRockTrades( - @JsonProperty("trades") TheRockTrade[] trades, @JsonProperty("meta") Object ignored) { - this.trades = trades; - } - - public int getCount() { - return trades.length; - } - - public TheRockTrade[] getTrades() { - return trades; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("TheRockTrades [count="); - builder.append(trades.length); - builder.append(", trades="); - builder.append(Arrays.toString(trades)); - builder.append("]"); - return builder.toString(); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMeta.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMeta.java deleted file mode 100644 index 3721b4c7dd7..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMeta.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -/** - * @author Pnk - */ -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockMeta { - - private long totalCount; - private TheRockMetaItem first; - private TheRockMetaItem previous; - private TheRockMetaItem current; - private TheRockMetaItem next; - private TheRockMetaItem last; - - public long getTotalCount() { - return totalCount; - } - - public TheRockMetaItem getFirst() { - return first; - } - - public TheRockMetaItem getPrevious() { - return previous; - } - - public TheRockMetaItem getCurrent() { - return current; - } - - public TheRockMetaItem getNext() { - return next; - } - - public TheRockMetaItem getLast() { - return last; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMetaItem.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMetaItem.java deleted file mode 100644 index cfeb30219cd..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockMetaItem.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -/** - * @author Pnk - */ -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class TheRockMetaItem { - - private int page; - private String href; - - public int getPage() { - return page; - } - - public String getHref() { - return href; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrder.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrder.java deleted file mode 100644 index 01cf3443936..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrder.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import java.math.BigDecimal; -import org.knowm.xchange.therock.TheRock; - -/** - * @author Matija Mazi - * @author Pnk - */ -@JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class) -public class TheRockOrder { - - private Long id; - private TheRock.Pair fundId; - private Side side; - private Type type; - private String status; - private BigDecimal amount; - private BigDecimal amountUnfilled; - private BigDecimal price; - private String conditionalType; - private BigDecimal conditionalPrice; - private String date; - private String closeOn; - private boolean dark; - private BigDecimal leverage; - private long positionId; - - protected TheRockOrder() {} - - public TheRockOrder( - TheRock.Pair fundId, Side side, Type type, BigDecimal amount, BigDecimal price) { - this.fundId = fundId; - this.side = side; - this.type = type; - this.amount = amount; - this.price = price; - } - - public Long getId() { - return id; - } - - public TheRock.Pair getFundId() { - return fundId; - } - - public Side getSide() { - return side; - } - - public Type getType() { - return type; - } - - public String getStatus() { - return status; - } - - public BigDecimal getAmount() { - return amount; - } - - public BigDecimal getAmountUnfilled() { - return amountUnfilled; - } - - public BigDecimal getPrice() { - return price; - } - - public String getConditionalType() { - return conditionalType; - } - - public BigDecimal getConditionalPrice() { - return conditionalPrice; - } - - public String getDate() { - return date; - } - - public String getCloseOn() { - return closeOn; - } - - public boolean isDark() { - return dark; - } - - public BigDecimal getLeverage() { - return leverage; - } - - public long getPositionId() { - return positionId; - } - - @Override - public String toString() { - return String.format( - "TheRockOrder{id=%d, side=%s, type=%s, amount=%s, amountUnfilled=%s, price=%s, fundId=%s, status='%s'}", - id, side, type, amount, amountUnfilled, price, fundId, status); - } - - public enum Side { - buy, - sell - } - - public enum Type { - market, - limit - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrders.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrders.java deleted file mode 100644 index e448b9e9c60..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockOrders.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -/** - * @author Pnk - */ -@JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class) -public class TheRockOrders { - - private TheRockOrder[] orders; - private TheRockMeta meta; - - protected TheRockOrders() {} - - public TheRockOrders(TheRockOrder[] orders) { - this.orders = orders; - } - - public TheRockOrder[] getOrders() { - return orders; - } - - public TheRockMeta getMeta() { - return meta; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransaction.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransaction.java deleted file mode 100644 index 3d85d07e05a..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransaction.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -public class TheRockTransaction { - - private final long id; - private final Date date; - private final String type; - private final BigDecimal price; - private final String currency; - private final Long orderId; - private final Long tradeId; - private final TransferDetail transferDetail; - - public TheRockTransaction( - @JsonProperty("id") long id, - @JsonProperty("date") Date date, - @JsonProperty("type") String type, - @JsonProperty("price") BigDecimal price, - @JsonProperty("currency") String currency, - @JsonProperty("order_id") Long orderId, - @JsonProperty("trade_id") Long tradeId, - @JsonProperty("transfer_detail") TransferDetail transferDetail) { - this.id = id; - this.date = date; - this.type = type; - this.price = price; - this.currency = currency; - this.orderId = orderId; - this.tradeId = tradeId; - this.transferDetail = transferDetail; - } - - public long getId() { - return id; - } - - public Date getDate() { - return date; - } - - public String getType() { - return type; - } - - public BigDecimal getPrice() { - return price; - } - - public String getCurrency() { - return currency; - } - - public Long getOrderId() { - return orderId; - } - - public Long getTradeId() { - return tradeId; - } - - public TransferDetail getTransferDetail() { - return transferDetail; - } - - @Override - public String toString() { - return "TheRockTransaction [id=" - + id - + ", date=" - + date - + ", type=" - + type - + ", price=" - + price - + ", currency=" - + currency - + ", orderId=" - + orderId - + ", tradeId=" - + tradeId - + ", transferDetail=" - + transferDetail - + "]"; - } - - public static class TransferDetail { - private final String method; - private final String id; - private final String recipient; - private final int confirmations; - - public TransferDetail( - @JsonProperty("method") String method, - @JsonProperty("id") String id, - @JsonProperty("recipient") String recipient, - @JsonProperty("confirmations") int confirmations) { - this.method = method; - this.id = id; - this.recipient = recipient; - this.confirmations = confirmations; - } - - @Override - public String toString() { - return "TransferDetail [method=" - + method - + ", id=" - + id - + ", recipient=" - + recipient - + ", confirmations=" - + confirmations - + "]"; - } - - public String getMethod() { - return method; - } - - public String getId() { - return id; - } - - public String getRecipient() { - return recipient; - } - - public int getConfirmations() { - return confirmations; - } - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransactions.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransactions.java deleted file mode 100644 index eb91663595f..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockTransactions.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Map; - -/** https://api.therocktrading.com/doc/v1/index.html#api-Trading_API-Transactions */ -public class TheRockTransactions { - - private final TheRockTransaction[] transactions; - private final Map meta; - - public TheRockTransactions( - @JsonProperty("transactions") TheRockTransaction[] transactions, - @JsonProperty("meta") Map meta) { - this.transactions = transactions; - this.meta = meta; - } - - public int getCount() { - return transactions.length; - } - - public TheRockTransaction[] getTransactions() { - return transactions; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrade.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrade.java deleted file mode 100644 index 84f683aad23..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrade.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrade.Side; - -public class TheRockUserTrade { - - private final long id; - private final String fundId; - private final BigDecimal amount; - private final Date date; - private final BigDecimal price; - private final Side side; - private final long orderId; - private final TheRockUserTradeTransaction feeTransaction; - - public TheRockUserTrade( - @JsonProperty("id") long id, - @JsonProperty("fund_id") String fundId, - @JsonProperty("amount") BigDecimal amount, - @JsonProperty("price") BigDecimal price, - @JsonProperty("date") Date date, - @JsonProperty("side") Side tradeSide, - @JsonProperty("order_id") long orderId, - @JsonProperty("transactions") TheRockUserTradeTransaction[] transactions) { - this.id = id; - this.fundId = fundId; - this.amount = amount; - this.price = price; - this.date = date; - this.side = tradeSide; - this.orderId = orderId; - - // try to find the fee transaction - TheRockUserTradeTransaction ft = null; - for (TheRockUserTradeTransaction t : transactions) { - if (t.type == TransactionType.paid_commission) { - ft = t; - break; - } - } - feeTransaction = ft; - } - - public long getId() { - return id; - } - - public String getFundId() { - return fundId; - } - - public BigDecimal getAmount() { - return amount; - } - - public BigDecimal getPrice() { - return price; - } - - public Date getDate() { - return date; - } - - public Side getSide() { - return side; - } - - public long getOrderId() { - return orderId; - } - - public BigDecimal getFeeAmount() { - return feeTransaction == null ? BigDecimal.ZERO : feeTransaction.price; - } - - public String getFeeCurrency() { - return feeTransaction == null ? null : feeTransaction.currency; - } - - @Override - public String toString() { - return "TheRockTrade [amount=" - + amount - + ", date=" - + date - + ", price=" - + price - + ", id=" - + id - + ", side=" - + side - + "]"; - } - - private enum TransactionType { - sold_currency_to_fund, - released_currency_to_fund, - paid_commission, - bought_currency_from_fund, - acquired_currency_from_fund, - unknown; - - @JsonCreator - public static TransactionType fromString(String string) { - try { - return TransactionType.valueOf(string); - } catch (Throwable e) { - return unknown; - } - } - } - - private static class TheRockUserTradeTransaction { - private final long id; - private final Date date; - private final TransactionType type; - private final BigDecimal price; - private final String currency; - - public TheRockUserTradeTransaction( - @JsonProperty("id") long id, - @JsonProperty("date") Date date, - @JsonProperty("type") TransactionType type, - @JsonProperty("price") BigDecimal price, - @JsonProperty("currency") String currency) { - super(); - this.id = id; - this.date = date; - this.type = type; - this.price = price; - this.currency = currency; - } - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrades.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrades.java deleted file mode 100644 index f145d06c86d..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/dto/trade/TheRockUserTrades.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.knowm.xchange.therock.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** https://api.therocktrading.com/doc/v1/index.html#api-Trading_API-Trades */ -public class TheRockUserTrades { - - private final TheRockUserTrade[] trades; - - public TheRockUserTrades( - @JsonProperty("trades") TheRockUserTrade[] trades, @JsonProperty("meta") Object ignored) { - this.trades = trades; - } - - public int getCount() { - return trades.length; - } - - public TheRockUserTrade[] getTrades() { - return trades; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountService.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountService.java deleted file mode 100644 index 84b989121e6..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountService.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.dto.account.FundingRecord; -import org.knowm.xchange.exceptions.NotAvailableFromExchangeException; -import org.knowm.xchange.service.account.AccountService; -import org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams; -import org.knowm.xchange.service.trade.params.HistoryParamsFundingType; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency; -import org.knowm.xchange.service.trade.params.TradeHistoryParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan; -import org.knowm.xchange.service.trade.params.WithdrawFundsParams; -import org.knowm.xchange.therock.TheRockAdapters; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawalResponse; -import org.knowm.xchange.therock.dto.trade.TheRockTransaction; -import org.knowm.xchange.therock.dto.trade.TheRockTransactions; - -/** - * @author Matija Mazi - */ -public class TheRockAccountService extends TheRockAccountServiceRaw implements AccountService { - - public TheRockAccountService(Exchange exchange) { - super(exchange); - } - - private static FundingRecord adapt(TheRockTransaction txn, FundingRecord.Type type) { - TheRockTransaction.TransferDetail transferDetail = txn.getTransferDetail(); - - String transferDetailId = null; - String address = null; - if (transferDetail != null) { - transferDetailId = transferDetail.getId(); - address = transferDetail.getRecipient(); - } - - return new FundingRecord( - address, - txn.getDate(), - Currency.getInstance(txn.getCurrency()), - txn.getPrice(), - String.valueOf(txn.getId()), - transferDetailId, - type, - FundingRecord.Status.COMPLETE, - null, - null, - null); - } - - @Override - public AccountInfo getAccountInfo() throws IOException { - return TheRockAdapters.adaptAccountInfo( - balances(), exchange.getExchangeSpecification().getUserName()); - } - - @Override - public String withdrawFunds(Currency currency, BigDecimal amount, String address) - throws IOException { - final TheRockWithdrawalResponse response = withdrawDefault(currency, amount, address); - return String.format("%d", response.getTransactionId()); - } - - @Override - public String withdrawFunds(WithdrawFundsParams params) throws IOException { - if (params instanceof DefaultWithdrawFundsParams) { - DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params; - return withdrawFunds( - defaultParams.getCurrency(), defaultParams.getAmount(), defaultParams.getAddress()); - } - throw new IllegalStateException("Don't know how to withdraw: " + params); - } - - @Override - public String requestDepositAddress(Currency currency, String... arguments) throws IOException { - throw new NotAvailableFromExchangeException(); - } - - @Override - public TradeHistoryParams createFundingHistoryParams() { - return new TheRockFundingHistoryParams(); - } - - @Override - public List getFundingHistory(TradeHistoryParams params) throws IOException { - - Currency currency = null; - Date after = null; - Date before = null; - FundingRecord.Type type = null; - - if (params instanceof TradeHistoryParamCurrency) { - TradeHistoryParamCurrency tradeHistoryParamCurrency = (TradeHistoryParamCurrency) params; - currency = tradeHistoryParamCurrency.getCurrency(); - } - - if (params instanceof TradeHistoryParamsTimeSpan) { - TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params; - after = tradeHistoryParamsTimeSpan.getStartTime(); - before = tradeHistoryParamsTimeSpan.getEndTime(); - } - - if (params instanceof HistoryParamsFundingType) { - HistoryParamsFundingType historyParamsFundingType = (HistoryParamsFundingType) params; - type = historyParamsFundingType.getType(); - } - - List all = new ArrayList<>(); - - if (type == null || type == FundingRecord.Type.DEPOSIT) { - int page = 1; - while (true) { - TheRockTransactions txns = deposits(currency, after, before, page++); - if (txns.getTransactions().length == 0) break; - - for (TheRockTransaction txn : txns.getTransactions()) { - all.add(adapt(txn, FundingRecord.Type.DEPOSIT)); - } - } - } - if (type == null || type == FundingRecord.Type.WITHDRAWAL) { - int page = 1; - while (true) { - TheRockTransactions txns = withdrawls(currency, after, before, page++); - if (txns.getTransactions().length == 0) break; - - for (TheRockTransaction txn : txns.getTransactions()) { - all.add(adapt(txn, FundingRecord.Type.WITHDRAWAL)); - } - } - } - return all; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java deleted file mode 100644 index 676f4047f81..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockAccountServiceRaw.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.therock.TheRockAuthenticated; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.account.TheRockBalance; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawal; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawalResponse; -import org.knowm.xchange.therock.dto.trade.TheRockTransactions; - -public class TheRockAccountServiceRaw extends TheRockBaseService { - - private final TheRockDigest signatureCreator; - - private final TheRockAuthenticated theRockAuthenticated; - - private final String apiKey; - - protected TheRockAccountServiceRaw(Exchange exchange) { - super(exchange); - final ExchangeSpecification spec = exchange.getExchangeSpecification(); - this.theRockAuthenticated = - ExchangeRestProxyBuilder.forInterface(TheRockAuthenticated.class, spec).build(); - apiKey = spec.getApiKey(); - this.signatureCreator = new TheRockDigest(spec.getSecretKey()); - } - - /** Withdraw using the default method */ - public TheRockWithdrawalResponse withdrawDefault( - Currency currency, BigDecimal amount, String destinationAddress) - throws TheRockException, IOException { - final TheRockWithdrawal withdrawal = - TheRockWithdrawal.createDefaultWithdrawal( - currency.getCurrencyCode(), amount, destinationAddress); - return theRockAuthenticated.withdraw( - apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); - } - - /** Withdraw to Ripple */ - public TheRockWithdrawalResponse withdrawRipple( - Currency currency, BigDecimal amount, String destinationAddress, Long destinationTag) - throws TheRockException, IOException { - final TheRockWithdrawal withdrawal = - TheRockWithdrawal.createRippleWithdrawal( - currency.getCurrencyCode(), amount, destinationAddress, destinationTag); - return theRockAuthenticated.withdraw( - apiKey, signatureCreator, exchange.getNonceFactory(), withdrawal); - } - - public List balances() throws TheRockException, IOException { - return theRockAuthenticated - .balances(apiKey, signatureCreator, exchange.getNonceFactory()) - .getBalances(); - } - - public TheRockTransactions withdrawls(Currency currency, Date after, Date before, Integer page) - throws IOException { - return theRockAuthenticated.transactions( - apiKey, - signatureCreator, - exchange.getNonceFactory(), - "withdraw", - after, - before, - currency == null ? null : currency.getCurrencyCode(), - page); - } - - public TheRockTransactions deposits(Currency currency, Date after, Date before, Integer page) - throws IOException { - return theRockAuthenticated.transactions( - apiKey, - signatureCreator, - exchange.getNonceFactory(), - "atm_payment", - after, - before, - currency == null ? null : currency.getCurrencyCode(), - page); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockBaseService.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockBaseService.java deleted file mode 100644 index 4caa9078a0b..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockBaseService.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.knowm.xchange.therock.service; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.service.BaseExchangeService; -import org.knowm.xchange.service.BaseService; - -public class TheRockBaseService extends BaseExchangeService implements BaseService { - - public TheRockBaseService(Exchange exchange) { - super(exchange); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockDigest.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockDigest.java deleted file mode 100644 index 7fa0bd7cf38..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockDigest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.knowm.xchange.therock.service; - -import jakarta.ws.rs.HeaderParam; -import java.math.BigInteger; -import javax.crypto.Mac; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import org.knowm.xchange.therock.TheRockAuthenticated; -import si.mazi.rescu.ParamsDigest; -import si.mazi.rescu.RestInvocation; - -public class TheRockDigest implements ParamsDigest { - - public static final String HMAC_SHA_512 = "HmacSHA512"; - - private final Mac mac; - - public TheRockDigest(String secretKeyStr) { - try { - final SecretKey secretKey = new SecretKeySpec(secretKeyStr.getBytes(), HMAC_SHA_512); - mac = Mac.getInstance(HMAC_SHA_512); - mac.init(secretKey); - } catch (Exception e) { - throw new RuntimeException("Error initializing The Rock Signer", e); - } - } - - @Override - public String digestParams(RestInvocation restInvocation) { - final String nonce = - restInvocation - .getParamValue(HeaderParam.class, TheRockAuthenticated.X_TRT_NONCE) - .toString(); - mac.update(nonce.getBytes()); - mac.update(restInvocation.getInvocationUrl().getBytes()); - - return String.format("%0128x", new BigInteger(1, mac.doFinal())); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockFundingHistoryParams.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockFundingHistoryParams.java deleted file mode 100644 index b209be2e6da..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockFundingHistoryParams.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.knowm.xchange.therock.service; - -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.dto.account.FundingRecord; -import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamsTimeSpan; -import org.knowm.xchange.service.trade.params.HistoryParamsFundingType; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency; - -public class TheRockFundingHistoryParams extends DefaultTradeHistoryParamsTimeSpan - implements TradeHistoryParamCurrency, HistoryParamsFundingType { - - private Currency currency; - private FundingRecord.Type type; - - public TheRockFundingHistoryParams() {} - - @Override - public FundingRecord.Type getType() { - return type; - } - - @Override - public void setType(FundingRecord.Type type) { - this.type = type; - } - - @Override - public Currency getCurrency() { - return currency; - } - - @Override - public void setCurrency(Currency currency) { - this.currency = currency; - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataService.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataService.java deleted file mode 100644 index e81de26d487..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataService.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.util.Date; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Ticker; -import org.knowm.xchange.dto.marketdata.Trades; -import org.knowm.xchange.service.marketdata.MarketDataService; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.TheRockAdapters; -import org.knowm.xchange.therock.dto.marketdata.TheRockOrderBook; -import org.knowm.xchange.therock.dto.marketdata.TheRockTicker; - -/** - * @author Matija Mazi - */ -public class TheRockMarketDataService extends TheRockMarketDataServiceRaw - implements MarketDataService { - - public TheRockMarketDataService(Exchange exchange) { - super(exchange); - } - - @Override - public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException { - TheRockTicker t = getTheRockTicker(new TheRock.Pair(currencyPair)); - return new Ticker.Builder() - .currencyPair(currencyPair) - .last(t.getLast()) - .bid(t.getBid()) - .ask(t.getAsk()) - .high(t.getHigh()) - .low(t.getLow()) - .volume(t.getVolumeTraded()) - .timestamp(new Date()) - .build(); - } - - @Override - public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException { - final TheRockOrderBook theRockOrderBook = getTheRockOrderBook(new TheRock.Pair(currencyPair)); - return TheRockAdapters.adaptOrderBook(theRockOrderBook); - } - - @Override - public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException { - return TheRockAdapters.adaptTrades( - getTheRockTrades(new TheRock.Pair(currencyPair), args), currencyPair); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataServiceRaw.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataServiceRaw.java deleted file mode 100644 index 7c7e9115d59..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockMarketDataServiceRaw.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.util.Date; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.marketdata.TheRockOrderBook; -import org.knowm.xchange.therock.dto.marketdata.TheRockTicker; -import org.knowm.xchange.therock.dto.marketdata.TheRockTrades; - -public class TheRockMarketDataServiceRaw extends TheRockBaseService { - - private final TheRock theRock; - - public TheRockMarketDataServiceRaw(Exchange exchange) { - super(exchange); - this.theRock = - ExchangeRestProxyBuilder.forInterface(TheRock.class, exchange.getExchangeSpecification()) - .build(); - } - - public TheRockTicker getTheRockTicker(TheRock.Pair currencyPair) - throws TheRockException, IOException { - return theRock.getTicker(currencyPair); - } - - public TheRockOrderBook getTheRockOrderBook(TheRock.Pair currencyPair) - throws TheRockException, IOException { - return theRock.getOrderbook(currencyPair); - } - - public TheRockTrades getTheRockTrades(TheRock.Pair currencyPair, Object[] args) - throws IOException { - Date after = null; - if (args.length == 1) { - Object arg = args[0]; - if (arg instanceof Number) { - after = new Date(((Number) arg).longValue() * 1000); - } else if (arg instanceof Date) { - after = (Date) arg; - } - } - return theRock.getTrades(currencyPair, after); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockOpenOrdersParams.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockOpenOrdersParams.java deleted file mode 100644 index f03108d745a..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockOpenOrdersParams.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.knowm.xchange.therock.service; - -import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair; - -public class TheRockOpenOrdersParams extends DefaultOpenOrdersParamCurrencyPair {} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeService.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeService.java deleted file mode 100644 index 8efb61b581f..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeService.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Date; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.exceptions.NotAvailableFromExchangeException; -import org.knowm.xchange.service.trade.TradeService; -import org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair; -import org.knowm.xchange.service.trade.params.CancelOrderByIdParams; -import org.knowm.xchange.service.trade.params.CancelOrderParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParamPaging; -import org.knowm.xchange.service.trade.params.TradeHistoryParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsIdSpan; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan; -import org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair; -import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams; -import org.knowm.xchange.therock.TheRockAdapters; -import org.knowm.xchange.therock.TheRockExchange; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; - -/** - * @author Matija Mazi - * @author Pnk - */ -public class TheRockTradeService extends TheRockTradeServiceRaw implements TradeService { - - public TheRockTradeService(Exchange exchange) { - super(exchange); - } - - @Override - public String placeMarketOrder(MarketOrder order) throws IOException, ExchangeException { - final TheRockOrder placedOrder = - placeTheRockOrder( - order.getCurrencyPair(), - order.getOriginalAmount(), - BigDecimal.ZERO, - TheRockAdapters.adaptSide(order.getType()), - TheRockOrder.Type.market); - return placedOrder.getId().toString(); - } - - @Override - public String placeLimitOrder(LimitOrder order) throws IOException, ExchangeException { - final TheRockOrder placedOrder = - placeTheRockOrder( - order.getCurrencyPair(), - order.getOriginalAmount(), - order.getLimitPrice(), - TheRockAdapters.adaptSide(order.getType()), - TheRockOrder.Type.limit); - return placedOrder.getId().toString(); - } - - /** - * Not available from exchange since TheRock needs currency pair in order to return open orders - */ - @Override - public OpenOrders getOpenOrders() throws IOException { - return getOpenOrders(createOpenOrdersParams()); - } - - @Override - public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException { - CurrencyPair currencyPair = null; - - if (params instanceof OpenOrdersParamCurrencyPair) { - currencyPair = ((OpenOrdersParamCurrencyPair) params).getCurrencyPair(); - } - - if (currencyPair == null) { - throw new ExchangeException("CurrencyPair parameter must not be null."); - } - - return TheRockAdapters.adaptOrders(getTheRockOrders(currencyPair)); - } - - /** Not available from exchange since TheRock needs currency pair in order to cancel an order */ - @Override - public boolean cancelOrder(String orderId) throws IOException { - CurrencyPair cp = - (CurrencyPair) - exchange - .getExchangeSpecification() - .getExchangeSpecificParameters() - .get(TheRockExchange.CURRENCY_PAIR); - if (cp == null) { - throw new ExchangeException("Provide TheRockCancelOrderParams with orderId and currencyPair"); - } - - return cancelOrder(cp, orderId); - } - - @Override - public boolean cancelOrder(CancelOrderParams params) throws IOException { - if (!(params instanceof CancelOrderByIdParams)) { - return false; - } - CancelOrderByIdParams paramId = (CancelOrderByIdParams) params; - - CurrencyPair currencyPair; - if (params instanceof CancelOrderByCurrencyPair) { - CancelOrderByCurrencyPair paramCurrencyPair = (CancelOrderByCurrencyPair) params; - currencyPair = paramCurrencyPair.getCurrencyPair(); - } else { - currencyPair = null; - } - - return cancelOrder(currencyPair, paramId.getOrderId()); - } - - @Override - public Class[] getRequiredCancelOrderParamClasses() { - return new Class[] {CancelOrderByIdParams.class, CancelOrderByCurrencyPair.class}; - } - - private boolean cancelOrder(CurrencyPair currencyPair, String orderId) - throws TheRockException, NumberFormatException, IOException { - TheRockOrder cancelledOrder = cancelTheRockOrder(currencyPair, Long.parseLong(orderId)); - return "deleted".equals(cancelledOrder.getStatus()); - } - - /** - * Not available from exchange since TheRock needs currency pair in order to return/show the order - */ - @Override - public Collection getOrder(String... orderIds) throws IOException { - throw new NotAvailableFromExchangeException(); - } - - @Override - public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { - if (!(params instanceof TradeHistoryParamCurrencyPair)) { - throw new ExchangeException("TheRock API recquires " + TradeHistoryParamCurrencyPair.class); - } - - TradeHistoryParamCurrencyPair pairParams = (TradeHistoryParamCurrencyPair) params; - Long sinceTradeId = null; // get all trades starting from a specific trade_id - if (params instanceof TradeHistoryParamsIdSpan) { - TradeHistoryParamsIdSpan trId = (TradeHistoryParamsIdSpan) params; - try { - sinceTradeId = Long.valueOf(trId.getStartId()); - } catch (Throwable ignored) { - } - } - - Date after = null; - Date before = null; - if (params instanceof TradeHistoryParamsTimeSpan) { - TradeHistoryParamsTimeSpan time = (TradeHistoryParamsTimeSpan) params; - after = time.getStartTime(); - before = time.getEndTime(); - } - - int pageLength = 200; - int page = 0; - if (params instanceof TradeHistoryParamPaging) { - TradeHistoryParamPaging tradeHistoryParamPaging = (TradeHistoryParamPaging) params; - pageLength = tradeHistoryParamPaging.getPageLength(); - page = tradeHistoryParamPaging.getPageNumber(); - } - - return TheRockAdapters.adaptUserTrades( - getTheRockUserTrades( - pairParams.getCurrencyPair(), sinceTradeId, after, before, pageLength, page), - pairParams.getCurrencyPair()); - } - - @Override - public OpenOrdersParams createOpenOrdersParams() { - return new TheRockOpenOrdersParams(); - } -} diff --git a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeServiceRaw.java b/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeServiceRaw.java deleted file mode 100644 index 84970742ff7..00000000000 --- a/xchange-therock/src/main/java/org/knowm/xchange/therock/service/TheRockTradeServiceRaw.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.knowm.xchange.therock.service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Date; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.TheRockAuthenticated; -import org.knowm.xchange.therock.dto.TheRockException; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; -import org.knowm.xchange.therock.dto.trade.TheRockTransaction; -import org.knowm.xchange.therock.dto.trade.TheRockUserTrades; - -public class TheRockTradeServiceRaw extends TheRockBaseService { - - private final TheRockAuthenticated theRockAuthenticated; - private final TheRockDigest signatureCreator; - - public TheRockTradeServiceRaw(Exchange exchange) { - super(exchange); - final ExchangeSpecification spec = exchange.getExchangeSpecification(); - this.theRockAuthenticated = - ExchangeRestProxyBuilder.forInterface(TheRockAuthenticated.class, spec).build(); - this.signatureCreator = new TheRockDigest(spec.getSecretKey()); - } - - public TheRockOrder placeTheRockOrder( - CurrencyPair currencyPair, - BigDecimal amount, - BigDecimal price, - TheRockOrder.Side side, - TheRockOrder.Type type) - throws ExchangeException, IOException { - return placeTheRockOrder( - currencyPair, new TheRockOrder(new TheRock.Pair(currencyPair), side, type, amount, price)); - } - - public TheRockOrder placeTheRockOrder(CurrencyPair currencyPair, TheRockOrder order) - throws ExchangeException, IOException { - try { - return theRockAuthenticated.placeOrder( - new TheRock.Pair(currencyPair), - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory(), - order); - } catch (TheRockException e) { - throw new ExchangeException(e); - } - } - - public TheRockOrder cancelTheRockOrder(CurrencyPair currencyPair, Long orderId) - throws TheRockException, IOException { - try { - return theRockAuthenticated.cancelOrder( - new TheRock.Pair(currencyPair), - orderId, - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory()); - } catch (TheRockException e) { - throw new ExchangeException(e); - } - } - - public TheRockOrders getTheRockOrders(CurrencyPair currencyPair) - throws TheRockException, IOException { - try { - return theRockAuthenticated.orders( - new TheRock.Pair(currencyPair), - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory()); - } catch (TheRockException e) { - throw new ExchangeException(e); - } - } - - public TheRockOrders getTheRockOrders( - CurrencyPair currencyPair, - Date after, - Date before, - String status, - TheRockOrder.Side side, - Long positionId, - int page) - throws TheRockException, IOException { - try { - return theRockAuthenticated.orders( - new TheRock.Pair(currencyPair), - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory(), - after, - before, - status, - side, - positionId, - page); - } catch (TheRockException e) { - throw new ExchangeException(e); - } - } - - public TheRockOrder showTheRockOrder(CurrencyPair currencyPair, Long orderId) - throws TheRockException, IOException { - try { - return theRockAuthenticated.showOrder( - new TheRock.Pair(currencyPair), - orderId, - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory()); - } catch (TheRockException e) { - throw new ExchangeException(e); - } - } - - public TheRockUserTrades getTheRockUserTrades( - CurrencyPair currencyPair, Long sinceTradeId, Date after, Date before, int pageSize, int page) - throws IOException { - try { - - return theRockAuthenticated.trades( - new TheRock.Pair(currencyPair), - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory(), - sinceTradeId, - after, - before, - pageSize, - page); - } catch (Throwable e) { - throw new ExchangeException(e); - } - } - - public TheRockTransaction[] getTheRockTransactions(String type, Date after, Date before) - throws IOException { - try { - return theRockAuthenticated - .transactions( - exchange.getExchangeSpecification().getApiKey(), - signatureCreator, - exchange.getNonceFactory(), - type, - after, - before, - null, - 0) - .getTransactions(); - } catch (Throwable e) { - throw new ExchangeException(e); - } - } -} diff --git a/xchange-therock/src/main/resources/therocktrading.json b/xchange-therock/src/main/resources/therocktrading.json deleted file mode 100644 index f04d4c4847b..00000000000 --- a/xchange-therock/src/main/resources/therocktrading.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "currency_pairs": { - "BCH/BTC": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0050000000 - }, - "BTC/EUR": { - "price_scale": 2, - "trading_fee": 0.002, - "min_amount": 0.0050000000 - }, - "BTC/XRP": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0050000000 - }, - "LTC/EUR": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "LTC/BTC": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "EUR/XRP": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "USD/XRP": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "LTC/USD": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "PPC/EUR": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0500000000 - }, - "PPC/BTC": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0500000000 - }, - "ETH/EUR": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - }, - "ETH/BTC": { - "price_scale": 5, - "trading_fee": 0.002, - "min_amount": 0.0100000000 - } - }, - "currencies": { - "BCH": { - "scale": 8 - }, - "BTC": { - "scale": 8 - }, - "LTC": { - "scale": 8 - }, - "PPC": { - "scale": 8 - }, - "ETH": { - "scale": 8 - }, - "XRP": { - "scale": 8 - }, - "EUR": { - "scale": 2 - } - }, - "private_rate_limits": [ - { - "calls": 1, - "time_span": 1, - "time_unit": "SECONDS" - } - ], - "share_rate_limits": true -} diff --git a/xchange-therock/src/test/java/org/knowm/xchange/therock/dto/TheRockDtoTest.java b/xchange-therock/src/test/java/org/knowm/xchange/therock/dto/TheRockDtoTest.java deleted file mode 100644 index 01dae917ac5..00000000000 --- a/xchange-therock/src/test/java/org/knowm/xchange/therock/dto/TheRockDtoTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.knowm.xchange.therock.dto; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.LinkedList; -import org.junit.Test; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.dto.account.TheRockBalance; -import org.knowm.xchange.therock.dto.account.TheRockBalances; -import org.knowm.xchange.therock.dto.account.TheRockWithdrawalResponse; -import org.knowm.xchange.therock.dto.marketdata.TheRockTicker; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; - -public class TheRockDtoTest { - - private static ObjectMapper mapper = new ObjectMapper(); - - private static T parse(Class theClass) throws IOException { - LinkedList linkedList = - new LinkedList<>( - Arrays.asList(new Object() {}.getClass().getPackage().getName().split("\\."))); - linkedList.add(theClass.getSimpleName() + ".json"); - String filename = - Paths.get(linkedList.removeFirst(), linkedList.toArray(new String[0])).toString(); - return parse(filename, theClass); - } - - private static E parse(String filename, Class type) throws java.io.IOException { - InputStream is = TheRockDtoTest.class.getResourceAsStream("/" + filename); - return mapper.readValue(is, type); - } - - @Test - public void testTicker() throws Exception { - final TheRockTicker json = parse(TheRockTicker.class); - assertThat(json.getVolume()).isEqualTo(new BigDecimal("25726.86")); - assertThat(json.getDate()).isEqualTo(getDate("2015-06-13T17:17:45.847+00:00")); - assertThat(json.getFundId()).isEqualTo(CurrencyPair.BTC_EUR); - } - - @Test - public void testBalance() throws Exception { - final TheRockBalance json = parse(TheRockBalance.class); - assertThat(json.getCurrency()).isEqualTo("LTC"); - assertThat(json.getBalance()).isEqualTo(new BigDecimal("6.50884835")); - assertThat(json.getTradingBalance()).isEqualTo(new BigDecimal("2.30884835")); - } - - @Test - public void testBalances() throws Exception { - final TheRockBalances json = parse(TheRockBalances.class); - assertThat(json.getBalances()).hasSize(2); - final TheRockBalance balance = json.getBalances().get(0); - assertThat(balance.getCurrency()).isEqualTo("LTC"); - assertThat(balance.getBalance()).isEqualTo(new BigDecimal("6.50884835")); - assertThat(balance.getTradingBalance()).isEqualTo(new BigDecimal("2.30884835")); - } - - @Test - public void testOrder() throws Exception { - final TheRockOrder json = parse(TheRockOrder.class); - assertThat(json.getId()).isEqualTo(4325578); - assertThat(json.getFundId()).isEqualTo(new TheRock.Pair(CurrencyPair.BTC_EUR)); - assertThat(json.getPrice()).isEqualTo(new BigDecimal("0.0102")); - } - - @Test - public void testOrders() throws Exception { - final TheRockOrders json = parse(TheRockOrders.class); - TheRockOrder order1 = json.getOrders()[0]; - assertThat(order1.getId()).isEqualTo(54000000); - assertThat(order1.getFundId()).isEqualTo(new TheRock.Pair(CurrencyPair.BTC_EUR)); - assertThat(order1.getPrice()).isEqualTo(new BigDecimal("506.46")); - assertThat(order1.getAmount()).isEqualTo(new BigDecimal("0.624")); - assertThat(order1.getAmountUnfilled()).isEqualTo(new BigDecimal("0.624")); - - final TheRockOrder order2 = json.getOrders()[1]; - assertThat(order2.getId()).isEqualTo(54000001); - assertThat(order2.getFundId()).isEqualTo(new TheRock.Pair(CurrencyPair.BTC_EUR)); - assertThat(order2.getPrice()).isEqualTo(new BigDecimal("504.11")); - assertThat(order2.getAmount()).isEqualTo(new BigDecimal("0.399")); - assertThat(order2.getAmountUnfilled()).isEqualTo(new BigDecimal("0.399")); - } - - @Test - public void testException() throws Exception { - final TheRockException json = parse(TheRockException.class); - assertThat(json.getMessage()).contains("CNYUSD is not a valid value for param fund_id"); - assertThat(json.getErrors()).hasSize(1); - assertThat(json.getErrors().get(0).getMessage()) - .isEqualTo("CNYUSD is not a valid value for param fund_id"); - assertThat(json.getErrors().get(0).getCode()).isEqualTo(11); - } - - @Test - public void testWithdrawalResponse() throws Exception { - final TheRockWithdrawalResponse json = parse(TheRockWithdrawalResponse.class); - assertThat(json.getTransactionId()).isEqualTo(65088485); - } - - private Date getDate(String dateStr) throws ParseException { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse(dateStr); - } -} diff --git a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/AbstractTheRockTradeServiceIntegration.java b/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/AbstractTheRockTradeServiceIntegration.java deleted file mode 100644 index 5773c06c90d..00000000000 --- a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/AbstractTheRockTradeServiceIntegration.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.knowm.xchange.therock.service.trade; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.therock.TheRockExchange; - -public abstract class AbstractTheRockTradeServiceIntegration { - - /** - * Substitute apiKey, secretKey and userName in order to run the inherited integration tests - * - * @return an instance of class TheRockExchange - */ - protected static Exchange createExchange() { - Exchange exchange = ExchangeFactory.INSTANCE.createExchange(TheRockExchange.class); - exchange.getExchangeSpecification().setApiKey("ApiKey"); - exchange.getExchangeSpecification().setSecretKey("SecretKey"); - exchange.getExchangeSpecification().setUserName("UserName"); - exchange.applySpecification(exchange.getExchangeSpecification()); - return exchange; - } -} diff --git a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceIntegration.java b/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceIntegration.java deleted file mode 100644 index 16890d5d53b..00000000000 --- a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceIntegration.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.knowm.xchange.therock.service.trade; - -import java.io.IOException; -import java.math.BigDecimal; -import org.junit.Test; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.therock.service.TheRockOpenOrdersParams; -import org.knowm.xchange.therock.service.TheRockTradeService; -import org.knowm.xchange.therock.service.TheRockTradeServiceRaw; - -/** Remove abstract modifier and read parent class notes in order to run the integration test */ -public abstract class TheRockTradeServiceIntegration - extends AbstractTheRockTradeServiceIntegration { - - TheRockTradeServiceRaw unit = createUnit(); - - private static TheRockTradeService createUnit() { - return new TheRockTradeService(createExchange()); - } - - @Test - public void testPlaceLimitOrder() throws IOException { - TheRockTradeService unit = createUnit(); - BigDecimal amount = new BigDecimal("0.01"); - BigDecimal price = new BigDecimal("50.0"); - LimitOrder limitOrder = - new LimitOrder(OrderType.BID, amount, CurrencyPair.BTC_EUR, null, null, price); - String id = unit.placeLimitOrder(limitOrder); - assert id != null; - } - - @Test - public void testOpenOrders() throws IOException { - TheRockTradeService unit = createUnit(); - - TheRockOpenOrdersParams openOrdersParams = new TheRockOpenOrdersParams(); - openOrdersParams.setCurrencyPair(CurrencyPair.BTC_EUR); - - OpenOrders openOrders = unit.getOpenOrders(openOrdersParams); - assert openOrders != null; - } -} diff --git a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceRawIntegration.java b/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceRawIntegration.java deleted file mode 100644 index 8cb1d3dadea..00000000000 --- a/xchange-therock/src/test/java/org/knowm/xchange/therock/service/trade/TheRockTradeServiceRawIntegration.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.knowm.xchange.therock.service.trade; - -import java.io.IOException; -import java.math.BigDecimal; -import org.junit.Test; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.therock.TheRock; -import org.knowm.xchange.therock.dto.trade.TheRockOrder; -import org.knowm.xchange.therock.dto.trade.TheRockOrder.Side; -import org.knowm.xchange.therock.dto.trade.TheRockOrder.Type; -import org.knowm.xchange.therock.dto.trade.TheRockOrders; -import org.knowm.xchange.therock.service.TheRockTradeServiceRaw; - -/** Remove abstract modifier and read parent class notes in order to run the integration test */ -public abstract class TheRockTradeServiceRawIntegration - extends AbstractTheRockTradeServiceIntegration { - - private static TheRockTradeServiceRaw createUnit() { - return new TheRockTradeServiceRaw(createExchange()); - } - - @Test - public void testGetOrders() throws IOException { - TheRockTradeServiceRaw unit = createUnit(); - TheRockOrders result = unit.getTheRockOrders(CurrencyPair.BTC_EUR); - assert result.getOrders() != null; - assert result.getMeta() != null; - } - - @Test - public void testSuccessfulLifecycle() throws IOException { - // create - TheRockTradeServiceRaw unit = createUnit(); - BigDecimal amount = new BigDecimal("0.01"); - BigDecimal price = new BigDecimal("50.0"); - TheRock.Pair pair = new TheRock.Pair(CurrencyPair.BTC_EUR); - TheRockOrder order = new TheRockOrder(pair, Side.buy, Type.limit, amount, price); - TheRockOrder result = unit.placeTheRockOrder(CurrencyPair.BTC_EUR, order); - assert result.getId() != null; - // get - result = unit.showTheRockOrder(CurrencyPair.BTC_EUR, result.getId()); - assert result.getId() != null; - // cancel - unit.cancelTheRockOrder(CurrencyPair.BTC_EUR, result.getId()); - } -} diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalance.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalance.json deleted file mode 100644 index f42bc7ed222..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalance.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "currency": "LTC", - "balance": 6.50884835, - "trading_balance": 2.30884835 -} \ No newline at end of file diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalances.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalances.json deleted file mode 100644 index d0451f2f7b3..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockBalances.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "balances": [ - { - "currency": "LTC", - "balance": 6.50884835, - "trading_balance": 2.30884835 - }, - { - "currency": "BTC", - "balance": 3.50884835, - "trading_balance": 1.30884835 - } - ] -} \ No newline at end of file diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockException.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockException.json deleted file mode 100644 index e1a9d1a6eee..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockException.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "errors": [ - { - "message": "CNYUSD is not a valid value for param fund_id", - "code": "11", - "meta": { - "key": "fund_id", - "value": "CNYUSD" - } - } - ] -} diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockFunds.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockFunds.json deleted file mode 100644 index f3601565933..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockFunds.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "funds": [ - { - "id": "BTCEUR", - "description": "Trade Bitcoins with EURO", - "type": "currency", - "base_currency": "EUR", - "trade_currency": "BTC" - }, - { - "id": "BTCUSD", - "description": "Trade Bitcoins with USD", - "type": "currency", - "base_currency": "USD", - "trade_currency": "BTC" - }, - { - "id": "BTCXRP", - "description": "Trade Bitcoins with XRP", - "type": "currency", - "base_currency": "XRP", - "trade_currency": "BTC" - }, - { - "id": "LTCEUR", - "description": "Trade Litecoins with EURO", - "type": "currency", - "base_currency": "EUR", - "trade_currency": "LTC" - }, - { - "id": "LTCBTC", - "description": "Trade Litecoins with Bitcoins", - "type": "currency", - "base_currency": "BTC", - "trade_currency": "LTC" - }, - { - "id": "EURXRP", - "description": "Trade EURO with XRP", - "type": "currency", - "base_currency": "XRP", - "trade_currency": "EUR" - }, - { - "id": "USDXRP", - "description": "Trade USD with XRP", - "type": "currency", - "base_currency": "XRP", - "trade_currency": "USD" - }, - { - "id": "LTCUSD", - "description": "Trade Litecoins with USD", - "type": "currency", - "base_currency": "USD", - "trade_currency": "LTC" - }, - { - "id": "NMCBTC", - "description": "Trade Namecoins with Bitcoins", - "type": "currency", - "base_currency": "BTC", - "trade_currency": "NMC" - }, - { - "id": "PPCEUR", - "description": "Trade Peercoins with EUR", - "type": "currency", - "base_currency": "EUR", - "trade_currency": "PPC" - }, - { - "id": "EURDOG", - "description": "Trade EUR with Dogecoins", - "type": "currency", - "base_currency": "DOGE", - "trade_currency": "EUR" - }, - { - "id": "PPCBTC", - "description": "Trade Peercoins with Bitcoins", - "type": "currency", - "base_currency": "BTC", - "trade_currency": "PPC" - } - ] -} \ No newline at end of file diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrder.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrder.json deleted file mode 100644 index 218c8454369..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrder.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": 4325578, - "fund_id": "BTCEUR", - "side": "buy", - "type": "limit", - "status": "active", - "price": 0.0102, - "amount": 50.0, - "amount_unfilled": 50.0 -} \ No newline at end of file diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrders.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrders.json deleted file mode 100644 index 60cf86b3c0d..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockOrders.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "orders": [ - { - "id": 54000000, - "fund_id": "BTCEUR", - "side": "sell", - "type": "limit", - "status": "active", - "price": 506.46, - "amount": 0.624, - "amount_unfilled": 0.624, - "conditional_type": null, - "conditional_price": null, - "date": "2016-09-27T09:08:15.000Z", - "close_on": null, - "dark": false, - "leverage": 1.0, - "position_id": null - }, - { - "id": 54000001, - "fund_id": "BTCEUR", - "side": "sell", - "type": "limit", - "status": "active", - "price": 504.11, - "amount": 0.399, - "amount_unfilled": 0.399, - "conditional_type": null, - "conditional_price": null, - "date": "2016-09-27T09:07:24.000Z", - "close_on": null, - "dark": false, - "leverage": 1.0, - "position_id": null - } - ], - "meta": { - "total_count": 5, - "first": { - "page": 1, - "href": "https://api.therocktrading.com/v1/funds/BTCEUR/orders?page=1" - }, - "previous": null, - "current": { - "page": 1, - "href": "https://api.therocktrading.com/v1/funds/BTCEUR/orders?page=1" - }, - "next": null, - "last": { - "page": 1, - "href": "https://api.therocktrading.com/v1/funds/BTCEUR/orders?page=1" - } - } -} diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockTicker.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockTicker.json deleted file mode 100644 index 70aec30f98e..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockTicker.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "fund_id": "BTCEUR", - "date": "2015-06-13T19:17:45.847+02:00", - "bid": 220.47, - "ask": 223.0, - "last": 220.44, - "volume": 25726.86, - "volume_traded": 115.64, - "open": 219.32, - "high": 229.99, - "low": 219.32, - "close": 222.22 -} \ No newline at end of file diff --git a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockWithdrawalResponse.json b/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockWithdrawalResponse.json deleted file mode 100644 index f09dbc5c001..00000000000 --- a/xchange-therock/src/test/resources/org/knowm/xchange/therock/dto/TheRockWithdrawalResponse.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "transaction_id": 65088485 -} \ No newline at end of file