diff --git a/pom.xml b/pom.xml index bc8ff25e72a..633f6ea6d69 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,6 @@ - xchange-bankera xchange-bibox xchange-binance xchange-bitbay @@ -182,7 +181,6 @@ xchange-enigma - xchange-stream-bankera xchange-stream-binance xchange-stream-bitfinex xchange-stream-bitflyer diff --git a/xchange-bankera/api-specification.txt b/xchange-bankera/api-specification.txt deleted file mode 100644 index e1450540ecc..00000000000 --- a/xchange-bankera/api-specification.txt +++ /dev/null @@ -1,8 +0,0 @@ -Bankera api spec - -url: https://exchange.bankera.com -doc: https://exchange.bankera.com/api-documentation.html - -You need an extra parameters: -exSpec.setExchangeSpecificParametersItem("clientId", "clientId"); -exSpec.setExchangeSpecificParametersItem("clientSecret", "clientSecret"); \ No newline at end of file diff --git a/xchange-bankera/pom.xml b/xchange-bankera/pom.xml deleted file mode 100644 index cc7911e43f6..00000000000 --- a/xchange-bankera/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - - - org.knowm.xchange - xchange-parent - 5.1.2-SNAPSHOT - - - xchange-bankera - - XChange Bankera - XChange implementation for the Bankera 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-bankera/src/main/java/org/knowm/xchange/bankera/Bankera.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/Bankera.java deleted file mode 100644 index ac8f2cf8ef5..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/Bankera.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.knowm.xchange.bankera; - -import jakarta.ws.rs.FormParam; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; -import java.io.IOException; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.BankeraToken; -import org.knowm.xchange.bankera.dto.marketdata.BankeraMarketInfo; -import org.knowm.xchange.bankera.dto.marketdata.BankeraOrderBook; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTickerResponse; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTradesResponse; - -@Path("/") -@Produces(MediaType.APPLICATION_JSON) -public interface Bankera { - - @POST - @Path("/oauth/token") - BankeraToken getToken( - @FormParam("grant_type") String grantType, - @FormParam("client_id") String clientId, - @FormParam("client_secret") String clientSecret) - throws BankeraException; - - @GET - @Path("/tickers/{market}") - BankeraTickerResponse getMarketTicker(@PathParam("market") String market) - throws BankeraException, IOException; - - @GET - @Path("/orderbooks/{market}") - BankeraOrderBook getOrderbook(@PathParam("market") String market) - throws BankeraException, IOException; - - @GET - @Path("/trades/{market}") - BankeraTradesResponse getRecentTrades(@PathParam("market") String market) - throws BankeraException, IOException; - - @GET - @Path("/general/info") - BankeraMarketInfo getMarketInfo() throws BankeraException, IOException; -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAdapters.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAdapters.java deleted file mode 100644 index c6de13e9581..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAdapters.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.knowm.xchange.bankera; - -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.account.BankeraUserInfo; -import org.knowm.xchange.bankera.dto.account.BankeraWallet; -import org.knowm.xchange.bankera.dto.marketdata.BankeraOrderBook; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTickerResponse; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTrade; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTradesResponse; -import org.knowm.xchange.bankera.dto.trade.BankeraOpenOrders; -import org.knowm.xchange.bankera.dto.trade.BankeraOrder; -import org.knowm.xchange.bankera.dto.trade.BankeraUserTrades; -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.Ticker; -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.UserTrade; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.exceptions.ExchangeSecurityException; - -public final class BankeraAdapters { - - private static final String ORDER_SIDE_BUY = "buy"; - - private BankeraAdapters() {} - - public static AccountInfo adaptAccountInfo(BankeraUserInfo userInfo) { - return new AccountInfo( - String.valueOf(userInfo.getUser().getId()), adaptWallet(userInfo.getUser().getWallets())); - } - - public static Wallet adaptWallet(List wallets) { - List balances = - wallets.stream() - .map( - w -> - new Balance.Builder() - .total(new BigDecimal(w.getTotal())) - .available(new BigDecimal(w.getBalance())) - .frozen(new BigDecimal(w.getReserved())) - .currency(new Currency(w.getCurrency())) - .build()) - .collect(Collectors.toList()); - return Wallet.Builder.from(balances).build(); - } - - public static ExchangeException adaptError(BankeraException exception) { - return exception.getHttpStatusCode() == 403 - ? new ExchangeSecurityException() - : new ExchangeException(exception.getError(), exception); - } - - /** - * Adapts Bankera BankeraTickerResponse to a Ticker - * - * @param ticker Specific ticker - * @param currencyPair BankeraCurrency pair (e.g. ETH/BTC) - * @return Ticker - */ - public static Ticker adaptTicker(BankeraTickerResponse ticker, CurrencyPair currencyPair) { - - BigDecimal high = new BigDecimal(ticker.getTicker().getHigh()); - BigDecimal low = new BigDecimal(ticker.getTicker().getLow()); - BigDecimal bid = new BigDecimal(ticker.getTicker().getBid()); - BigDecimal ask = new BigDecimal(ticker.getTicker().getAsk()); - BigDecimal last = new BigDecimal(ticker.getTicker().getLast()); - BigDecimal volume = new BigDecimal(ticker.getTicker().getVolume()); - Date timestamp = new Date(ticker.getTicker().getTimestamp()); - - return new Ticker.Builder() - .currencyPair(currencyPair) - .high(high) - .low(low) - .bid(bid) - .ask(ask) - .last(last) - .volume(volume) - .timestamp(timestamp) - .build(); - } - - public static OrderBook adaptOrderBook(BankeraOrderBook orderbook, CurrencyPair currencyPair) { - - List bids = createOrders(currencyPair, OrderType.BID, orderbook.getBids()); - List asks = createOrders(currencyPair, OrderType.ASK, orderbook.getAsks()); - - return new OrderBook(null, asks, bids); - } - - public static Trades adaptTrades( - BankeraTradesResponse tradesResponse, CurrencyPair currencyPair) { - - List bankeraTrades = tradesResponse.getTrades(); - List tradesList = new ArrayList<>(); - - bankeraTrades.forEach( - bankeraTrade -> { - BigDecimal amount = new BigDecimal(bankeraTrade.getAmount()); - BigDecimal price = new BigDecimal(bankeraTrade.getPrice()); - Date date = new Date(Long.parseLong(bankeraTrade.getTime())); - OrderType type = - bankeraTrade.getSide().equalsIgnoreCase(ORDER_SIDE_BUY) - ? OrderType.BID - : OrderType.ASK; - tradesList.add( - new Trade.Builder() - .type(type) - .originalAmount(amount) - .currencyPair(currencyPair) - .price(price) - .timestamp(date) - .build()); - }); - return new Trades(tradesList, 0L, Trades.TradeSortType.SortByTimestamp); - } - - private static List createOrders( - CurrencyPair currencyPair, - OrderType orderType, - List ordersList) { - - List limitOrders = new ArrayList<>(); - if (ordersList == null) return limitOrders; - - ordersList.forEach( - order -> { - limitOrders.add( - new LimitOrder( - orderType, - new BigDecimal(order.getAmount()), - currencyPair, - String.valueOf(order.getId()), - null, - new BigDecimal(order.getPrice()))); - }); - - return limitOrders; - } - - public static List adaptOpenOrders(BankeraOpenOrders openOrders) { - - List orderList = new ArrayList<>(); - - openOrders - .getOpenOrders() - .forEach( - bankeraOrder -> { - String[] currencies = bankeraOrder.getMarket().split("-"); - CurrencyPair pair = new CurrencyPair(currencies[0], currencies[1]); - orderList.add( - new LimitOrder( - bankeraOrder.getSide().equalsIgnoreCase("buy") - ? OrderType.BID - : OrderType.ASK, - new BigDecimal(bankeraOrder.getAmount()), - new BigDecimal(bankeraOrder.getRemainingAmount()), - pair, - String.valueOf(bankeraOrder.getId()), - new Date(Long.valueOf(bankeraOrder.getCreatedAt())), - new BigDecimal(bankeraOrder.getPrice()))); - }); - - return orderList; - } - - public static List adaptUserTrades(BankeraUserTrades userTrades) { - List tradeList = new ArrayList<>(); - - userTrades - .getTrades() - .forEach( - trade -> { - String[] currencies = trade.getMarket().split("-"); - CurrencyPair pair = new CurrencyPair(currencies[0], currencies[1]); - Currency feeCurrency = new Currency(currencies[1]); - tradeList.add( - UserTrade.builder() - .type(trade.getSide().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK) - .originalAmount(new BigDecimal(trade.getAmount())) - .currencyPair(pair) - .price(new BigDecimal(trade.getPrice())) - .timestamp(new Date(Long.parseLong(trade.getCompletedAt()))) - .id(String.valueOf(trade.getId())) - .orderId(String.valueOf(trade.getOrderId())) - .feeAmount(new BigDecimal(trade.getFeeAmount())) - .feeCurrency(feeCurrency) - .build()); - }); - - return tradeList; - } - - public static Order adaptOrder(BankeraOrder bankeraOrder) { - String[] currencies = bankeraOrder.getMarket().split("-"); - CurrencyPair pair = new CurrencyPair(currencies[0], currencies[1]); - DecimalFormat format = new DecimalFormat(); - format.setParseBigDecimal(true); - return new LimitOrder( - bankeraOrder.getSide().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK, - new BigDecimal(bankeraOrder.getAmount()), - pair, - String.valueOf(bankeraOrder.getId()), - new Date(Long.parseLong(bankeraOrder.getCreatedAt())), - new BigDecimal(bankeraOrder.getPrice()), - new BigDecimal(bankeraOrder.getPrice()), - new BigDecimal(bankeraOrder.getExecutedAmount()), - bankeraOrder.getTotalFee(), - adaptOrderStatus(bankeraOrder.getStatus())); - } - - private static Order.OrderStatus adaptOrderStatus(String status) { - switch (status.toLowerCase()) { - case "open": - return Order.OrderStatus.NEW; - case "completed": - return Order.OrderStatus.FILLED; - case "cancelled": - return Order.OrderStatus.CANCELED; - case "rejected": - return Order.OrderStatus.REJECTED; - case "pending cancel": - return Order.OrderStatus.PENDING_CANCEL; - default: - return Order.OrderStatus.UNKNOWN; - } - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAuthenticated.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAuthenticated.java deleted file mode 100644 index 670f76bb452..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraAuthenticated.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.knowm.xchange.bankera; - -import jakarta.ws.rs.Consumes; -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.List; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.BaseBankeraRequest; -import org.knowm.xchange.bankera.dto.CreateOrderRequest; -import org.knowm.xchange.bankera.dto.account.BankeraUserInfo; -import org.knowm.xchange.bankera.dto.trade.BankeraOpenOrders; -import org.knowm.xchange.bankera.dto.trade.BankeraOrder; -import org.knowm.xchange.bankera.dto.trade.BankeraUserTrades; - -@Path("/") -@Produces(MediaType.APPLICATION_JSON) -public interface BankeraAuthenticated extends Bankera { - @GET - @Path("users/info") - BankeraUserInfo getUserInfo(@HeaderParam("Authorization") String authorization) - throws BankeraException, IOException; - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("orders/new") - BankeraOrder placeOrder( - @HeaderParam("Authorization") String authorization, CreateOrderRequest request) - throws BankeraException, IOException; - - @GET - @Path("orders/open") - BankeraOpenOrders getOpenOrders( - @HeaderParam("Authorization") String authorization, - @QueryParam("market") String market, - @QueryParam("limit") Integer limit, - @QueryParam("offset") Integer offset) - throws BankeraException, IOException; - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Path("orders/cancel/{orderId}") - BankeraOrder cancelOrder( - @HeaderParam("Authorization") String authorization, - @PathParam("orderId") Long orderId, - BaseBankeraRequest request) - throws BankeraException, IOException; - - @POST - @Path("orders/cancel/all") - List cancelAllOrders(@HeaderParam("Authorization") String authorization) - throws BankeraException, IOException; - - @GET - @Path("trades/history") - BankeraUserTrades getUserTrades( - @HeaderParam("Authorization") String authorization, @QueryParam("market") String market) - throws BankeraException, IOException; - - @GET - @Path("orders/details") - BankeraOrder getUserOrder( - @HeaderParam("Authorization") String authorization, @QueryParam("orderId") String orderId) - throws BankeraException, IOException; -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraExchange.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraExchange.java deleted file mode 100644 index db68f176674..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/BankeraExchange.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.knowm.xchange.bankera; - -import org.knowm.xchange.BaseExchange; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.BankeraToken; -import org.knowm.xchange.bankera.service.BankeraAccountService; -import org.knowm.xchange.bankera.service.BankeraBaseService; -import org.knowm.xchange.bankera.service.BankeraMarketDataService; -import org.knowm.xchange.bankera.service.BankeraTradeService; -import org.knowm.xchange.utils.nonce.TimestampIncrementingNonceFactory; -import si.mazi.rescu.SynchronizedValueFactory; - -public class BankeraExchange extends BaseExchange implements Exchange { - - private SynchronizedValueFactory nonceFactory = new TimestampIncrementingNonceFactory(); - protected BankeraToken token; - - @Override - protected void initServices() { - this.accountService = new BankeraAccountService(this); - this.marketDataService = new BankeraMarketDataService(this); - this.tradeService = new BankeraTradeService(this); - } - - @Override - public ExchangeSpecification getDefaultExchangeSpecification() { - - ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass()); - exchangeSpecification.setSslUri("https://api-exchange.bankera.com"); - exchangeSpecification.setHost("api-exchange.bankera.com"); - exchangeSpecification.setPort(443); - exchangeSpecification.setExchangeName("Bankera"); - exchangeSpecification.setExchangeDescription("The Bankera exchange."); - - return exchangeSpecification; - } - - @Override - public SynchronizedValueFactory getNonceFactory() { - return nonceFactory; - } - - public BankeraToken getToken() { - if (token == null || token.getExpirationTime() < System.currentTimeMillis() + 30000L) { - try { - token = ((BankeraBaseService) accountService).createToken(); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - return token; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraException.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraException.java deleted file mode 100644 index 574e637df0f..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.bankera.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import si.mazi.rescu.HttpStatusExceptionSupport; - -public class BankeraException extends HttpStatusExceptionSupport { - - private final String error; - - public BankeraException( - @JsonProperty("status") Integer status, @JsonProperty("error") String error) { - super(error); - this.error = error; - } - - public String getError() { - return error; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraToken.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraToken.java deleted file mode 100644 index c4636d0ab4c..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BankeraToken.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.knowm.xchange.bankera.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraToken { - private String accessToken; - private String tokenType; - private int expiresIn; - private Long expirationTime; - private String scope; - private String userId; - private String userName; - private String environmentCode; - private String loginIp; - private String jti; - - public BankeraToken( - @JsonProperty("access_token") final String accessToken, - @JsonProperty("token_type") final String tokenType, - @JsonProperty("expires_in") final int expiresIn, - @JsonProperty("scope") final String scope, - @JsonProperty("user_id") final String userId, - @JsonProperty("user_name") final String userName, - @JsonProperty("environment_code") final String environmentCode, - @JsonProperty("login_ip") final String loginIp, - @JsonProperty("jti") final String jti) { - this.accessToken = accessToken; - this.tokenType = tokenType; - this.expiresIn = expiresIn; - this.scope = scope; - this.userId = userId; - this.userName = userName; - this.environmentCode = environmentCode; - this.loginIp = loginIp; - this.jti = jti; - this.expirationTime = System.currentTimeMillis() + (this.expiresIn * 1000L); - } - - public String getAccessToken() { - return accessToken; - } - - public String getTokenType() { - return tokenType; - } - - public int getExpiresIn() { - return expiresIn; - } - - public Long getExpirationTime() { - return expirationTime; - } - - public String getScope() { - return scope; - } - - public String getUserId() { - return userId; - } - - public String getUserName() { - return userName; - } - - public String getEnvironmentCode() { - return environmentCode; - } - - public String getLoginIp() { - return loginIp; - } - - public String getJti() { - return jti; - } - - @Override - public String toString() { - return "BankeraToken{" - + "accessToken='" - + accessToken - + '\'' - + ", tokenType='" - + tokenType - + '\'' - + ", expiresIn=" - + expiresIn - + ", scope='" - + scope - + '\'' - + ", userId='" - + userId - + '\'' - + ", userName='" - + userName - + '\'' - + ", environmentCode='" - + environmentCode - + '\'' - + ", loginIp='" - + loginIp - + '\'' - + ", jti='" - + jti - + '\'' - + '}'; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BaseBankeraRequest.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BaseBankeraRequest.java deleted file mode 100644 index b6b57769624..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/BaseBankeraRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.knowm.xchange.bankera.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class BaseBankeraRequest { - - @JsonProperty("nonce") - private final Long nonce; - - public BaseBankeraRequest(Long nonce) { - this.nonce = nonce; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/CreateOrderRequest.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/CreateOrderRequest.java deleted file mode 100644 index a8fcb35bd2e..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/CreateOrderRequest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.knowm.xchange.bankera.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import org.apache.commons.lang3.StringUtils; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class CreateOrderRequest { - - private static final String LIMIT_ORDER_TYPE = "limit"; - private static final String MARKET_ORDER_TYPE = "market"; - - @JsonProperty("market") - private final String market; - - @JsonProperty("side") - private final String side; - - @JsonProperty("type") - private final String type; - - @JsonProperty("price") - private final String price; - - @JsonProperty("amount") - private final String amount; - - @JsonProperty("client_order_id") - private final String clientOrderId; - - @JsonProperty("nonce") - private final Long nonce; - - public CreateOrderRequest( - String market, String side, BigDecimal amount, String clientOrderId, Long nonce) { - this.market = market; - this.side = side; - this.amount = amount.toPlainString(); - this.type = MARKET_ORDER_TYPE; - this.price = StringUtils.EMPTY; - this.clientOrderId = clientOrderId; - this.nonce = nonce; - } - - public CreateOrderRequest( - String market, - String side, - BigDecimal amount, - BigDecimal price, - String clientOrderId, - Long nonce) { - this.market = market; - this.side = side; - this.amount = amount.toPlainString(); - this.type = LIMIT_ORDER_TYPE; - this.price = price.toPlainString(); - this.clientOrderId = clientOrderId; - this.nonce = nonce; - } - - public enum Side { - BUY("buy"), - SELL("sell"); - - private String side; - - Side(String side) { - this.side = side; - } - - public String getSide() { - return this.side; - } - - public static Side getEnum(String side) { - for (Side currentEnum : Side.values()) { - if (currentEnum.getSide().equalsIgnoreCase(side)) { - return currentEnum; - } - } - throw new UnsupportedOperationException("Unknown order side: " + side); - } - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUser.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUser.java deleted file mode 100644 index c39d553dba0..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUser.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.knowm.xchange.bankera.dto.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class BankeraUser { - private int id; - private List wallets; - - public BankeraUser( - @JsonProperty("id") int id, @JsonProperty("wallets") List wallets) { - this.id = id; - this.wallets = wallets; - } - - public int getId() { - return id; - } - - public List getWallets() { - return wallets; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfo.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfo.java deleted file mode 100644 index b689c5b6fe1..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.knowm.xchange.bankera.dto.account; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraUserInfo { - private BankeraUser user; - - public BankeraUserInfo(@JsonProperty("user") BankeraUser user) { - this.user = user; - } - - public BankeraUser getUser() { - return user; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraWallet.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraWallet.java deleted file mode 100644 index 12f9113d35c..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/account/BankeraWallet.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.knowm.xchange.bankera.dto.account; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraWallet { - private int id; - private String balance; - private String reserved; - private String total; - private String currency; - - public BankeraWallet( - @JsonProperty("id") int id, - @JsonProperty("balance") String balance, - @JsonProperty("reserved") String reserved, - @JsonProperty("total") String total, - @JsonProperty("currency") String currency) { - this.id = id; - this.balance = balance; - this.reserved = reserved; - this.total = total; - this.currency = currency; - } - - public int getId() { - return id; - } - - public String getBalance() { - return balance; - } - - public String getReserved() { - return reserved; - } - - public String getTotal() { - return total; - } - - public String getCurrency() { - return currency; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarket.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarket.java deleted file mode 100644 index 8c1c8138fa5..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarket.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class BankeraMarket { - private int id; - private String slug; - private String name; - - public BankeraMarket( - @JsonProperty("id") int id, - @JsonProperty("slug") String slug, - @JsonProperty("name") String name) { - this.id = id; - this.slug = slug; - this.name = name; - } - - public int getId() { - return id; - } - - public String getSlug() { - return slug; - } - - public String getName() { - return name; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarketInfo.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarketInfo.java deleted file mode 100644 index 1bf81f6dc6c..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraMarketInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class BankeraMarketInfo { - - private List markets; - - public BankeraMarketInfo(@JsonProperty("markets") List markets) { - this.markets = markets; - } - - public List getMarkets() { - return markets; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraOrderBook.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraOrderBook.java deleted file mode 100644 index 5211d0527e8..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraOrderBook.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class BankeraOrderBook { - - private final List bids; - private final List asks; - - public BankeraOrderBook( - @JsonProperty("bids") List bids, - @JsonProperty("asks") List asks) { - this.asks = asks; - this.bids = bids; - } - - public List getBids() { - return bids; - } - - public List getAsks() { - return asks; - } - - public static final class OrderBookOrder { - private final Integer id; - private final String price; - private final String amount; - - public OrderBookOrder( - @JsonProperty("id") Integer id, - @JsonProperty("price") String price, - @JsonProperty("amount") String amount) { - - this.id = id; - this.price = price; - this.amount = amount; - } - - public Integer getId() { - return id; - } - - public String getPrice() { - return price; - } - - public String getAmount() { - return amount; - } - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTicker.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTicker.java deleted file mode 100644 index cfd6b1f5420..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTicker.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class BankeraTicker { - - private final Integer id; - private final String high; - private final String low; - private final String bid; - private final String ask; - private final String last; - private final String volume; - private final long timestamp; - - /** - * Constructor - * - * @param id - * @param high - * @param low - * @param bid - * @param ask - * @param last - * @param volume - * @param timestamp - */ - public BankeraTicker( - @JsonProperty("id") Integer id, - @JsonProperty("high") String high, - @JsonProperty("low") String low, - @JsonProperty("bid") String bid, - @JsonProperty("ask") String ask, - @JsonProperty("last") String last, - @JsonProperty("volume") String volume, - @JsonProperty("timestamp") long timestamp) { - - this.id = id; - this.high = high; - this.low = low; - this.bid = bid; - this.ask = ask; - this.last = last; - this.volume = volume; - this.timestamp = timestamp; - } - - public Integer getId() { - return id; - } - - public String getHigh() { - return high; - } - - public String getLow() { - return low; - } - - public String getBid() { - return bid; - } - - public String getAsk() { - return ask; - } - - public String getLast() { - return last; - } - - public String getVolume() { - return volume; - } - - public long getTimestamp() { - return timestamp; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTickerResponse.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTickerResponse.java deleted file mode 100644 index 2703b5b98df..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTickerResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class BankeraTickerResponse { - - private final BankeraTicker ticker; - - public BankeraTickerResponse(@JsonProperty("ticker") BankeraTicker ticker) { - this.ticker = ticker; - } - - @JsonProperty("ticker") - public BankeraTicker getTicker() { - return ticker; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTrade.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTrade.java deleted file mode 100644 index 9e6ead11913..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTrade.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraTrade { - - private final String market; - private final String amount; - private final String price; - private final String side; - private final String time; - - public BankeraTrade( - @JsonProperty("market") String market, - @JsonProperty("amount") String amount, - @JsonProperty("price") String price, - @JsonProperty("side") String side, - @JsonProperty("time") String time) { - this.market = market; - this.amount = amount; - this.price = price; - this.side = side; - this.time = time; - } - - public String getMarket() { - return market; - } - - public String getAmount() { - return amount; - } - - public String getPrice() { - return price; - } - - public String getSide() { - return side; - } - - public String getTime() { - return time; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTradesResponse.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTradesResponse.java deleted file mode 100644 index a43c97ef0f3..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/marketdata/BankeraTradesResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.bankera.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class BankeraTradesResponse { - - private final List trades; - - public BankeraTradesResponse(@JsonProperty("deals") List trades) { - this.trades = trades; - } - - public List getTrades() { - return trades; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOpenOrders.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOpenOrders.java deleted file mode 100644 index a82e09272a2..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOpenOrders.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.knowm.xchange.bankera.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class BankeraOpenOrders { - - private final List openOrders; - - public BankeraOpenOrders(@JsonProperty("orders") List openOrders) { - - this.openOrders = openOrders; - } - - public List getOpenOrders() { - return openOrders; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOrder.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOrder.java deleted file mode 100644 index 00500d1453c..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraOrder.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.knowm.xchange.bankera.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.List; -import java.util.function.Function; - -public class BankeraOrder { - - private final long id; - private final String market; - private final String price; - private final String side; - private final String type; - private final String status; - private final String amount; - private final String remainingAmount; - private final String executedAmount; - private final String clientOrderId; - private final String createdAt; - private final String updatedAt; - private final String cancelledAt; - private final List transactions; - - /** - * @param id id of order - * @param market order market name - * @param price order price - * @param side order side (buy/sell) - * @param type order type (limit/market) - * @param status order status - * @param amount order amount - * @param clientOrderId custom or generated client order id - */ - public BankeraOrder( - @JsonProperty("id") long id, - @JsonProperty("market") String market, - @JsonProperty("price") String price, - @JsonProperty("side") String side, - @JsonProperty("type") String type, - @JsonProperty("status") String status, - @JsonProperty("amount") String amount, - @JsonProperty("executed_amount") String executedAmount, - @JsonProperty("remaining_amount") String remainingAmount, - @JsonProperty("client_order_id") String clientOrderId, - @JsonProperty("created_at") String createdAt, - @JsonProperty("updated_at") String updatedAt, - @JsonProperty("cancelled_at") String cancelledAt, - @JsonProperty("transactions") List transactions) { - - this.id = id; - this.market = market; - this.price = price; - this.side = side; - this.type = type; - this.status = status; - this.amount = amount; - this.clientOrderId = clientOrderId; - this.executedAmount = executedAmount; - this.remainingAmount = remainingAmount; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.cancelledAt = cancelledAt; - this.transactions = transactions; - } - - public long getId() { - return id; - } - - public String getMarket() { - return market; - } - - public String getPrice() { - return price; - } - - public String getSide() { - return side; - } - - public String getType() { - return type; - } - - public String getStatus() { - return status; - } - - public String getAmount() { - return amount; - } - - public String getClientOrderId() { - return clientOrderId; - } - - public String getRemainingAmount() { - return remainingAmount; - } - - public String getExecutedAmount() { - return executedAmount; - } - - public String getCreatedAt() { - return createdAt; - } - - public String getUpdatedAt() { - return updatedAt; - } - - public String getCancelledAt() { - return cancelledAt; - } - - public List getTransactions() { - return transactions; - } - - public BigDecimal getTotalFee() { - Function totalMapper = tx -> new BigDecimal(tx.getFee()); - return transactions.size() > 0 - ? transactions.stream().map(totalMapper).reduce(BigDecimal.ZERO, BigDecimal::add) - : BigDecimal.ZERO; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraTransaction.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraTransaction.java deleted file mode 100644 index fa8f74485cb..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraTransaction.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.knowm.xchange.bankera.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraTransaction { - - private final long id; - private final long orderId; - private final String market; - private final String amount; - private final String fee; - private final String price; - private final String total; - private final String status; - private final String type; - private final String platform; - private final String completedAt; - - public BankeraTransaction( - @JsonProperty("id") long id, - @JsonProperty("orderId") long orderId, - @JsonProperty("market") String market, - @JsonProperty("amount") String amount, - @JsonProperty("fee") String fee, - @JsonProperty("price") String price, - @JsonProperty("total") String total, - @JsonProperty("status") String status, - @JsonProperty("type") String type, - @JsonProperty("platform") String platform, - @JsonProperty("completed_at") String completedAt) { - this.id = id; - this.orderId = orderId; - this.market = market; - this.amount = amount; - this.fee = fee; - this.price = price; - this.total = total; - this.status = status; - this.type = type; - this.platform = platform; - this.completedAt = completedAt; - } - - public long getId() { - return id; - } - - public long getOrderId() { - return orderId; - } - - public String getMarket() { - return market; - } - - public String getAmount() { - return amount; - } - - public String getFee() { - return fee; - } - - public String getPrice() { - return price; - } - - public String getTotal() { - return total; - } - - public String getStatus() { - return status; - } - - public String getType() { - return type; - } - - public String getPlatform() { - return platform; - } - - public String getCompletedAt() { - return completedAt; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrade.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrade.java deleted file mode 100644 index 39a233ead23..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrade.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.knowm.xchange.bankera.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraUserTrade { - - private final long id; - private final long orderId; - private final String market; - private final String amount; - private final String price; - private final String feeAmount; - private final String total; - private final String status; - private final String side; - private final String completedAt; - - public BankeraUserTrade( - @JsonProperty("id") long id, - @JsonProperty("order_id") long orderId, - @JsonProperty("market") String market, - @JsonProperty("price") String price, - @JsonProperty("amount") String amount, - @JsonProperty("fee_amount") String feeAmount, - @JsonProperty("total") String total, - @JsonProperty("status") String status, - @JsonProperty("side") String side, - @JsonProperty("completed_at") String completedAt) { - this.id = id; - this.orderId = orderId; - this.market = market; - this.amount = amount; - this.feeAmount = feeAmount; - this.total = total; - this.status = status; - this.side = side; - this.completedAt = completedAt; - this.price = price; - } - - public long getId() { - return id; - } - - public long getOrderId() { - return orderId; - } - - public String getMarket() { - return market; - } - - public String getAmount() { - return amount; - } - - public String getFeeAmount() { - return feeAmount; - } - - public String getTotal() { - return total; - } - - public String getStatus() { - return status; - } - - public String getSide() { - return side; - } - - public String getCompletedAt() { - return completedAt; - } - - public String getPrice() { - return price; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrades.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrades.java deleted file mode 100644 index e7f37f4cbc5..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/dto/trade/BankeraUserTrades.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.knowm.xchange.bankera.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class BankeraUserTrades { - - private final List trades; - - public BankeraUserTrades(@JsonProperty("trades") List trades) { - - this.trades = trades; - } - - public List getTrades() { - return trades; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountService.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountService.java deleted file mode 100644 index 39e7b23546d..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.service.account.AccountService; - -public class BankeraAccountService extends BankeraAccountServiceRaw implements AccountService { - - public BankeraAccountService(Exchange exchange) { - super(exchange); - } - - @Override - public AccountInfo getAccountInfo() throws IOException { - return BankeraAdapters.adaptAccountInfo(getUserInfo()); - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountServiceRaw.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountServiceRaw.java deleted file mode 100644 index 785e9cd450a..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraAccountServiceRaw.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.bankera.BankeraExchange; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.account.BankeraUserInfo; - -public class BankeraAccountServiceRaw extends BankeraBaseService { - - public BankeraAccountServiceRaw(Exchange exchange) { - super(exchange); - } - - public BankeraUserInfo getUserInfo() throws IOException { - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - return bankeraAuthenticated.getUserInfo(auth); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraBaseService.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraBaseService.java deleted file mode 100644 index 038361a4aa3..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraBaseService.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.Bankera; -import org.knowm.xchange.bankera.BankeraAuthenticated; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.BankeraToken; -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.service.BaseExchangeService; -import org.knowm.xchange.service.BaseService; - -public class BankeraBaseService extends BaseExchangeService implements BaseService { - - protected final Bankera bankera; - protected final BankeraAuthenticated bankeraAuthenticated; - - public BankeraBaseService(Exchange exchange) { - super(exchange); - bankera = - ExchangeRestProxyBuilder.forInterface(Bankera.class, exchange.getExchangeSpecification()) - .build(); - bankeraAuthenticated = - ExchangeRestProxyBuilder.forInterface( - BankeraAuthenticated.class, exchange.getExchangeSpecification()) - .build(); - } - - public BankeraToken createToken() throws BankeraException { - String clientId = (String) exchange.getExchangeSpecification().getParameter("clientId"); - String clientSecret = (String) exchange.getExchangeSpecification().getParameter("clientSecret"); - return bankera.getToken("client_credentials", clientId, clientSecret); - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataService.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataService.java deleted file mode 100644 index 0b2bd0a3473..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataService.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -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; - -public class BankeraMarketDataService extends BankeraMarketDataServiceRaw - implements MarketDataService { - - public BankeraMarketDataService(Exchange exchange) { - - super(exchange); - } - - @Override - public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException { - - return BankeraAdapters.adaptTicker(getBankeraTicker(currencyPair), currencyPair); - } - - @Override - public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException { - - return BankeraAdapters.adaptOrderBook(getOrderbook(currencyPair), currencyPair); - } - - @Override - public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException { - - return BankeraAdapters.adaptTrades(getRecentTrades(currencyPair), currencyPair); - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataServiceRaw.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataServiceRaw.java deleted file mode 100644 index 1fe6c892719..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraMarketDataServiceRaw.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.marketdata.BankeraMarketInfo; -import org.knowm.xchange.bankera.dto.marketdata.BankeraOrderBook; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTickerResponse; -import org.knowm.xchange.bankera.dto.marketdata.BankeraTradesResponse; -import org.knowm.xchange.currency.CurrencyPair; - -public class BankeraMarketDataServiceRaw extends BankeraBaseService { - - public BankeraMarketDataServiceRaw(Exchange exchange) { - super(exchange); - } - - public BankeraTickerResponse getBankeraTicker(CurrencyPair currencyPair) throws IOException { - - try { - return bankera.getMarketTicker(getMarketNameFromPair(currencyPair)); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraOrderBook getOrderbook(CurrencyPair currencyPair) throws IOException { - - try { - return bankera.getOrderbook(getMarketNameFromPair(currencyPair)); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraMarketInfo getMarketInfo() throws IOException { - - try { - return bankera.getMarketInfo(); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraTradesResponse getRecentTrades(CurrencyPair currencyPair) throws IOException { - - try { - return bankera.getRecentTrades(getMarketNameFromPair(currencyPair)); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - private static String getMarketNameFromPair(CurrencyPair pair) { - - return pair == null - ? null - : new StringBuilder() - .append(pair.base.getCurrencyCode()) - .append("-") - .append(pair.counter.getCurrencyCode()) - .toString(); - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeService.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeService.java deleted file mode 100644 index f0c325bd985..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeService.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.bankera.dto.trade.BankeraOrder; -import org.knowm.xchange.bankera.dto.trade.BankeraUserTrades; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.marketdata.Trades; -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.NotYetImplementedForExchangeException; -import org.knowm.xchange.service.trade.TradeService; -import org.knowm.xchange.service.trade.params.CancelOrderParams; -import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParams; -import org.knowm.xchange.service.trade.params.orders.*; - -public class BankeraTradeService extends BankeraTradeServiceRaw implements TradeService { - - public BankeraTradeService(Exchange exchange) { - - super(exchange); - } - - @Override - public OpenOrders getOpenOrders() throws IOException { - return getOpenOrders(null); - } - - @Override - public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException { - return new OpenOrders(BankeraAdapters.adaptOpenOrders(getBankeraOpenOrders(params))); - } - - @Override - public String placeMarketOrder(MarketOrder marketOrder) throws IOException { - BankeraOrder order = placeBankeraMarketOrder(marketOrder); - return Long.toString(order.getId()); - } - - @Override - public String placeLimitOrder(LimitOrder limitOrder) throws IOException { - BankeraOrder order = placeBankeraLimitOrder(limitOrder); - return Long.toString(order.getId()); - } - - @Override - public boolean cancelOrder(String orderId) throws IOException { - BankeraOrder order = cancelBankeraOrder(orderId); - return order != null; - } - - @Override - public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { - throw new NotYetImplementedForExchangeException(); - } - - @Override - public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { - - CurrencyPair currencyPair = null; - if (params instanceof TradeHistoryParamCurrencyPair) { - TradeHistoryParamCurrencyPair tradeHistoryParamCurrencyPair = - (TradeHistoryParamCurrencyPair) params; - currencyPair = tradeHistoryParamCurrencyPair.getCurrencyPair(); - } - - BankeraUserTrades trades = getUserTrades(currencyPair); - return new UserTrades( - BankeraAdapters.adaptUserTrades(trades), Trades.TradeSortType.SortByTimestamp); - } - - @Override - public TradeHistoryParams createTradeHistoryParams() { - return new DefaultTradeHistoryParamCurrencyPair(); - } - - @Override - public OpenOrdersParams createOpenOrdersParams() { - return new BankeraOpenOrderParams(); - } - - public static class BankeraOpenOrderParams - implements OpenOrdersParams, - OpenOrdersParamLimit, - OpenOrdersParamCurrencyPair, - OpenOrdersParamOffset { - - private Integer limit = 100; - private Integer offset = 0; - private CurrencyPair currencyPair; - - public BankeraOpenOrderParams() {} - - @Override - public boolean accept(LimitOrder order) { - return OpenOrdersParamCurrencyPair.super.accept(order); - } - - @Override - public Integer getLimit() { - return limit; - } - - @Override - public void setLimit(Integer limit) { - this.limit = limit; - } - - @Override - public Integer getOffset() { - return offset; - } - - @Override - public void setOffset(Integer offset) { - this.offset = offset; - } - - @Override - public CurrencyPair getCurrencyPair() { - return currencyPair; - } - - @Override - public void setCurrencyPair(CurrencyPair pair) { - this.currencyPair = pair; - } - } - - @Override - public Collection getOrder(OrderQueryParams... orderQueryParams) throws IOException { - List orders = new ArrayList<>(orderQueryParams.length); - - for (OrderQueryParams orderQueryParam : orderQueryParams) { - BankeraOrder order = getUserOrder(orderQueryParam.getOrderId()); - orders.add(BankeraAdapters.adaptOrder(order)); - } - - return orders; - } -} diff --git a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeServiceRaw.java b/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeServiceRaw.java deleted file mode 100644 index e3e027eb4e9..00000000000 --- a/xchange-bankera/src/main/java/org/knowm/xchange/bankera/service/BankeraTradeServiceRaw.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.io.IOException; -import java.util.List; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.bankera.BankeraExchange; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.BaseBankeraRequest; -import org.knowm.xchange.bankera.dto.CreateOrderRequest; -import org.knowm.xchange.bankera.dto.trade.BankeraOpenOrders; -import org.knowm.xchange.bankera.dto.trade.BankeraOrder; -import org.knowm.xchange.bankera.dto.trade.BankeraUserTrades; -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.service.trade.params.orders.OpenOrdersParamCurrencyPair; -import org.knowm.xchange.service.trade.params.orders.OpenOrdersParamLimit; -import org.knowm.xchange.service.trade.params.orders.OpenOrdersParamOffset; -import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams; - -public class BankeraTradeServiceRaw extends BankeraBaseService { - - public BankeraTradeServiceRaw(Exchange exchange) { - - super(exchange); - } - - public BankeraOpenOrders getBankeraOpenOrders(OpenOrdersParams params) throws IOException { - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - String market = null; - Integer limit = 100; - Integer offset = 0; - if (params instanceof OpenOrdersParamCurrencyPair) { - CurrencyPair currencyPair = ((OpenOrdersParamCurrencyPair) params).getCurrencyPair(); - market = getMarketNameFromPair(currencyPair); - } - if (params instanceof OpenOrdersParamLimit) { - limit = ((OpenOrdersParamLimit) params).getLimit(); - } - if (params instanceof OpenOrdersParamOffset) { - offset = ((OpenOrdersParamOffset) params).getOffset(); - } - return bankeraAuthenticated.getOpenOrders(auth, market, limit, offset); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraOrder placeBankeraLimitOrder(LimitOrder limitOrder) throws IOException { - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - String market = getMarketNameFromPair(limitOrder.getCurrencyPair()); - - return bankeraAuthenticated.placeOrder( - auth, - new CreateOrderRequest( - market, - (limitOrder.getType() == Order.OrderType.BID - ? CreateOrderRequest.Side.BUY.getSide() - : CreateOrderRequest.Side.SELL.getSide()), - limitOrder.getOriginalAmount(), - limitOrder.getLimitPrice(), - limitOrder.getId(), - exchange.getNonceFactory().createValue())); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraOrder placeBankeraMarketOrder(MarketOrder marketOrder) throws IOException { - - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - String market = getMarketNameFromPair(marketOrder.getCurrencyPair()); - - return bankeraAuthenticated.placeOrder( - auth, - new CreateOrderRequest( - market, - (marketOrder.getType() == Order.OrderType.BID - ? CreateOrderRequest.Side.BUY.getSide() - : CreateOrderRequest.Side.SELL.getSide()), - marketOrder.getOriginalAmount(), - marketOrder.getId(), - exchange.getNonceFactory().createValue())); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraOrder cancelBankeraOrder(String orderId) throws IOException { - - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - return bankeraAuthenticated.cancelOrder( - auth, - Long.valueOf(orderId), - new BaseBankeraRequest(exchange.getNonceFactory().createValue())); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public List cancelAllBankeraOrders() throws IOException { - - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - return bankeraAuthenticated.cancelAllOrders(auth); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraUserTrades getUserTrades(CurrencyPair currencyPair) throws IOException { - - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - String market = getMarketNameFromPair(currencyPair); - return bankeraAuthenticated.getUserTrades(auth, market); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - public BankeraOrder getUserOrder(String orderId) throws IOException { - - try { - BankeraExchange bankeraExchange = (BankeraExchange) exchange; - String auth = "Bearer " + bankeraExchange.getToken().getAccessToken(); - return bankeraAuthenticated.getUserOrder(auth, orderId); - } catch (BankeraException e) { - throw BankeraAdapters.adaptError(e); - } - } - - private static String getMarketNameFromPair(CurrencyPair pair) { - - return pair == null - ? null - : new StringBuilder() - .append(pair.base.getCurrencyCode()) - .append("-") - .append(pair.counter.getCurrencyCode()) - .toString(); - } -} diff --git a/xchange-bankera/src/main/resources/bankera.json b/xchange-bankera/src/main/resources/bankera.json deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/xchange-bankera/src/main/resources/bankera.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/ExchangeUtils.java b/xchange-bankera/src/test/java/org/knowm/xchange/bankera/ExchangeUtils.java deleted file mode 100644 index 7d11f7a95ed..00000000000 --- a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/ExchangeUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.knowm.xchange.bankera; - -import java.io.InputStream; -import java.util.Properties; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExchangeUtils { - private static final Logger logger = LoggerFactory.getLogger(ExchangeUtils.class); - - public static Exchange createExchangeFromProperties() { - - ExchangeSpecification exSpec = new ExchangeSpecification(BankeraExchange.class); - - InputStream is = - ExchangeUtils.class.getResourceAsStream( - "/org/knowm/xchange/bankera/configuration.properties"); - Properties props = new Properties(); - - try { - props.load(is); - logger.debug(props.toString()); - - if (props.getProperty("client-id") != null) { - exSpec.setExchangeSpecificParametersItem("clientId", props.getProperty("client-id")); - } - if (props.getProperty("client-secret") != null) { - exSpec.setExchangeSpecificParametersItem( - "clientSecret", props.getProperty("client-secret")); - } - } catch (Exception e) { - logger.warn("Error while loading integration test properties", e); - return null; - } - - return ExchangeFactory.INSTANCE.createExchange(exSpec); - } -} diff --git a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfoTest.java b/xchange-bankera/src/test/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfoTest.java deleted file mode 100644 index 1df347b7103..00000000000 --- a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/dto/account/BankeraUserInfoTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.knowm.xchange.bankera.dto.account; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; - -public class BankeraUserInfoTest { - @Test - public void jsonMapperTest() throws IOException { - InputStream is = - getClass().getResourceAsStream("/org/knowm/xchange/bankera/dto/account/user_info.json"); - ObjectMapper mapper = new ObjectMapper(); - final BankeraUserInfo userInfo = mapper.readValue(is, BankeraUserInfo.class); - assertThat(userInfo).isNotNull(); - assertThat(userInfo.getUser()).isNotNull(); - BankeraUser user = userInfo.getUser(); - assertThat(user.getId()).isEqualTo(7); - assertThat(user.getWallets()).isNotEmpty().hasSize(5); - - List wallets = user.getWallets(); - - wallets.stream() - .forEach( - w -> { - assertThat(w.getBalance()).isEqualTo("10.000000000000000000000000000000"); - assertThat(w.getTotal()).isEqualTo("30.000000000000000000000000000000"); - assertThat(w.getReserved()).isEqualTo("20.000000000000000000000000000000"); - assertThat(w.getCurrency()).isNotNull(); - assertThat(Arrays.asList("BTC", "ETH", "BNK", "DASH", "XEM")) - .contains(w.getCurrency()); - }); - } -} diff --git a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/AccountInfoFetchIntegration.java b/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/AccountInfoFetchIntegration.java deleted file mode 100644 index 690e604ac45..00000000000 --- a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/AccountInfoFetchIntegration.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.ExchangeUtils; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.service.account.AccountService; - -public class AccountInfoFetchIntegration { - - private Exchange exchange; - - @Before - public void setUp() { - - exchange = ExchangeUtils.createExchangeFromProperties(); - } - - @Test - public void fetchAccountInfoTest() throws Exception { - AccountService service = exchange.getAccountService(); - assertNotNull(service); - // verify account info exists - AccountInfo info = service.getAccountInfo(); - assertNotNull(info); - } -} diff --git a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/MarketDataServiceIntegration.java b/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/MarketDataServiceIntegration.java deleted file mode 100644 index 55be94b138d..00000000000 --- a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/MarketDataServiceIntegration.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import static org.junit.Assert.assertNotNull; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.ExchangeUtils; -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.exceptions.ExchangeException; -import org.knowm.xchange.service.marketdata.MarketDataService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MarketDataServiceIntegration { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private static MarketDataService marketDataService; - - @BeforeClass - public static void init() { - - Exchange exchange = ExchangeUtils.createExchangeFromProperties(); - marketDataService = exchange.getMarketDataService(); - } - - @Test - public void getTickerTest() throws Exception { - - Ticker ticker = marketDataService.getTicker(CurrencyPair.ETH_BTC); - assertNotNull(ticker); - logger.info("Response: {}", ticker); - } - - @Test(expected = ExchangeException.class) - public void getTickerInvalidMarketTest() throws Exception { - marketDataService.getTicker(CurrencyPair.ADA_BNB); - } - - @Test - public void getOrderBookTest() throws Exception { - - OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BNK_USDT); - assertNotNull(orderBook); - logger.info("Response: {}", orderBook); - } - - @Test - public void getTradesTest() throws Exception { - - Trades trades = marketDataService.getTrades(CurrencyPair.ETH_BTC); - assertNotNull(trades); - logger.info("Response: {}", trades); - } -} diff --git a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/TradeServiceIntegration.java b/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/TradeServiceIntegration.java deleted file mode 100644 index 82d9e20d9a5..00000000000 --- a/xchange-bankera/src/test/java/org/knowm/xchange/bankera/service/TradeServiceIntegration.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.knowm.xchange.bankera.service; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Date; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.bankera.ExchangeUtils; -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.NotYetImplementedForExchangeException; -import org.knowm.xchange.service.trade.TradeService; -import org.knowm.xchange.service.trade.params.DefaultCancelOrderParamId; -import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TradeServiceIntegration { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private static String orderId; - private static TradeService tradeService; - - @BeforeClass - public static void init() { - Exchange exchange = ExchangeUtils.createExchangeFromProperties(); - tradeService = exchange.getTradeService(); - } - - @Test - public void testAcreateLimitOrderTest() throws Exception { - - LimitOrder limitOrder = - new LimitOrder( - Order.OrderType.BID, - BigDecimal.valueOf(0.01), - CurrencyPair.ETH_BTC, - "", - new Date(), - BigDecimal.valueOf(0.000001)); - String createdOrderId = tradeService.placeLimitOrder(limitOrder); - Assert.assertNotNull(createdOrderId); - orderId = createdOrderId; - logger.info("Response: {}", orderId); - } - - @Test - public void testBcreateMarketOrderTest() throws Exception { - - MarketOrder marketOrder = - new MarketOrder( - Order.OrderType.ASK, BigDecimal.valueOf(0.01), CurrencyPair.ETH_BTC, "", new Date()); - - Assert.assertNotNull(tradeService.placeMarketOrder(marketOrder)); - } - - @Test - public void testCgetOpenOrdersByMarketTest() throws Exception { - - DefaultOpenOrdersParamCurrencyPair currencyPair = new DefaultOpenOrdersParamCurrencyPair(); - currencyPair.setCurrencyPair(CurrencyPair.ETH_BTC); - OpenOrders openOrders = tradeService.getOpenOrders(currencyPair); - logger.info("Response: {}", openOrders); - } - - @Test - public void testDgetAllOpenOrdersTest() throws Exception { - - OpenOrders openOrders = tradeService.getOpenOrders(); - logger.info("Response: {}", openOrders); - } - - @Test - public void testFcancelOrderTest() throws Exception { - - Assert.assertTrue(tradeService.cancelOrder(this.orderId)); - } - - @Test(expected = NotYetImplementedForExchangeException.class) - public void testGcancelAllOrdersTest() throws Exception { - - Assert.assertTrue(tradeService.cancelOrder(new DefaultCancelOrderParamId())); - } - - @Test - public void testEgetUserOrder() throws Exception { - - Collection orders = tradeService.getOrder(this.orderId); - logger.info("Response: {}", orders); - } - - @Test - public void testHgetUserTrades() throws Exception { - - DefaultTradeHistoryParamCurrencyPair currencyPair = new DefaultTradeHistoryParamCurrencyPair(); - currencyPair.setCurrencyPair(CurrencyPair.ETH_BTC); - UserTrades trades = tradeService.getTradeHistory(currencyPair); - logger.info("Response: {}", trades.getUserTrades()); - } -} diff --git a/xchange-bankera/src/test/resources/logback.xml b/xchange-bankera/src/test/resources/logback.xml deleted file mode 100644 index 5809b573500..00000000000 --- a/xchange-bankera/src/test/resources/logback.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - %d{HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{36} - %msg %xEx%n - - - - - - - - - - - - - - diff --git a/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/configuration.properties b/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/configuration.properties deleted file mode 100644 index 4fe558a00c9..00000000000 --- a/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/configuration.properties +++ /dev/null @@ -1,3 +0,0 @@ -#uncomment and fill those fields to test authenticated api in integration tests -#client-id= -#client-secret= \ No newline at end of file diff --git a/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/dto/account/user_info.json b/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/dto/account/user_info.json deleted file mode 100644 index e4c9689ab24..00000000000 --- a/xchange-bankera/src/test/resources/org/knowm/xchange/bankera/dto/account/user_info.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "user":{ - "id":7, - "verification":{"status":"Unsubmitted","last_declined_reason":null}, - "personal_profile":{ - "first_name":"John", - "last_name":"Doe", - "country":{ - "id":5, - "name":"AMERICAN SAMOA", - "iso2":"AS", - "iso3":"ASM" - }, - "phone":"12345647", - "birth_date":"2018-11-09 00:00:00", - "address":"Street 1", - "city":"Vilnius", - "zip_code":"11111", - "is_user_agree_for_news":false - }, - "business_profile":null, - "fee_set":{ - "fees":[ - {"buy_percent":"0.200000000000000000000000000000","sell_percent":"0.200000000000000000000000000000","market_id":1}, - {"buy_percent":"0.200000000000000000000000000000","sell_percent":"0.200000000000000000000000000000","market_id":2}, - {"buy_percent":"0.200000000000000000000000000000","sell_percent":"0.200000000000000000000000000000","market_id":3}, - {"buy_percent":"0.200000000000000000000000000000","sell_percent":"0.200000000000000000000000000000","market_id":4}, - {"buy_percent":"0.200000000000000000000000000000","sell_percent":"0.200000000000000000000000000000","market_id":5} - ] - }, - "wallets":[ - { - "id":16, - "currency":"DASH", - "balance":"10.000000000000000000000000000000", - "reserved":"20.000000000000000000000000000000", - "total":"30.000000000000000000000000000000" - }, - { - "id":18, - "currency":"XEM", - "balance":"10.000000000000000000000000000000", - "reserved":"20.000000000000000000000000000000", - "total":"30.000000000000000000000000000000" - }, - { - "id":20, - "currency":"BTC", - "balance":"10.000000000000000000000000000000", - "reserved":"20.000000000000000000000000000000", - "total":"30.000000000000000000000000000000" - }, - { - "id":22, - "currency":"ETH", - "balance":"10.000000000000000000000000000000", - "reserved":"20.000000000000000000000000000000", - "total":"30.000000000000000000000000000000" - }, - { - "id":24, - "currency":"BNK", - "balance":"10.000000000000000000000000000000", - "reserved":"20.000000000000000000000000000000", - "total":"30.000000000000000000000000000000" - } - ] - } -} \ No newline at end of file diff --git a/xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java b/xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java index ea54d40fbb8..2cbe5ade84c 100644 --- a/xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java +++ b/xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java @@ -364,7 +364,7 @@ public class CurrencyPair extends Instrument implements Comparable public static final CurrencyPair ETC_7D = new CurrencyPair(Currency.ETC, Currency.getInstance("7D")); - // Bankera Exchange pairs + // Bankera pairs public static final CurrencyPair BNK_BTC = new CurrencyPair(Currency.BNK, Currency.BTC); public static final CurrencyPair BNK_ETH = new CurrencyPair(Currency.BNK, Currency.ETH); public static final CurrencyPair BNK_USDT = new CurrencyPair(Currency.BNK, Currency.USDT); diff --git a/xchange-examples/pom.xml b/xchange-examples/pom.xml index 54d9e0345c4..a2213ffe8c0 100755 --- a/xchange-examples/pom.xml +++ b/xchange-examples/pom.xml @@ -342,11 +342,6 @@ xchange-dvchain ${project.version} - - ${project.groupId} - xchange-bankera - ${project.version} - org.knowm.xchange xchange-enigma diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraAccountServiceDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraAccountServiceDemo.java deleted file mode 100644 index 1d58e5bb7b1..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraAccountServiceDemo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.examples.bankera; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.dto.account.AccountInfo; -import org.knowm.xchange.service.account.AccountService; - -public class BankeraAccountServiceDemo { - public static void main(String[] args) throws IOException { - Exchange exchange = BankeraDemoUtils.createExchange(); - AccountService accountService = exchange.getAccountService(); - - // Get the account information - AccountInfo accountInfo = accountService.getAccountInfo(); - System.out.println("AccountInfo as String: " + accountInfo.toString()); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraDemoUtils.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraDemoUtils.java deleted file mode 100644 index f7abd15a013..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraDemoUtils.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.knowm.xchange.examples.bankera; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.bankera.BankeraExchange; - -public class BankeraDemoUtils { - public static Exchange createExchange() { - - ExchangeSpecification exSpec = new ExchangeSpecification(BankeraExchange.class); - - exSpec.setExchangeSpecificParametersItem("clientId", ""); - exSpec.setExchangeSpecificParametersItem("clientSecret", ""); - - return ExchangeFactory.INSTANCE.createExchange(exSpec); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraMarketDataServiceDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraMarketDataServiceDemo.java deleted file mode 100644 index f6de7644bc9..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraMarketDataServiceDemo.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.knowm.xchange.examples.bankera; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.Ticker; -import org.knowm.xchange.service.marketdata.MarketDataService; - -public class BankeraMarketDataServiceDemo { - public static void main(String[] args) throws IOException { - Exchange exchange = BankeraDemoUtils.createExchange(); - MarketDataService marketDataService = exchange.getMarketDataService(); - - // Get the market data ticker - Ticker ticker = marketDataService.getTicker(CurrencyPair.ETH_BTC); - System.out.println("Ticker as String: " + ticker.toString()); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraTradeServiceDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraTradeServiceDemo.java deleted file mode 100644 index b50cecde8e2..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/bankera/BankeraTradeServiceDemo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.examples.bankera; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.service.trade.TradeService; - -public class BankeraTradeServiceDemo { - public static void main(String[] args) throws IOException { - Exchange exchange = BankeraDemoUtils.createExchange(); - TradeService tradeService = exchange.getTradeService(); - - // Get the open orders - OpenOrders openOrders = tradeService.getOpenOrders(); - System.out.println("OpenOrders as String: " + openOrders.toString()); - } -} diff --git a/xchange-stream-bankera/pom.xml b/xchange-stream-bankera/pom.xml deleted file mode 100644 index ca312e01464..00000000000 --- a/xchange-stream-bankera/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - 4.0.0 - - - org.knowm.xchange - xchange-parent - 5.1.2-SNAPSHOT - - - XChange Bankera Stream - xchange-stream-bankera - - - - org.knowm.xchange - xchange-stream-core - ${project.parent.version} - - - org.knowm.xchange - xchange-stream-service-netty - ${project.parent.version} - - - org.knowm.xchange - xchange-bankera - ${project.parent.version} - - - \ No newline at end of file diff --git a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingExchange.java b/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingExchange.java deleted file mode 100644 index 3dfa3052408..00000000000 --- a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingExchange.java +++ /dev/null @@ -1,78 +0,0 @@ -package info.bitrich.xchangestream.bankera; - -import info.bitrich.xchangestream.core.ProductSubscription; -import info.bitrich.xchangestream.core.StreamingExchange; -import info.bitrich.xchangestream.core.StreamingMarketDataService; -import info.bitrich.xchangestream.service.netty.ConnectionStateModel.State; -import io.reactivex.Completable; -import io.reactivex.Observable; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.bankera.BankeraExchange; -import org.knowm.xchange.bankera.service.BankeraMarketDataService; - -public class BankeraStreamingExchange extends BankeraExchange implements StreamingExchange { - - private static final String WS_URI = "wss://api-exchange.bankera.com/ws"; - private final BankeraStreamingService streamingService; - private BankeraStreamingMarketDataService streamingMarketDataService; - - public BankeraStreamingExchange() { - this.streamingService = new BankeraStreamingService(WS_URI); - } - - @Override - protected void initServices() { - super.initServices(); - streamingMarketDataService = - new BankeraStreamingMarketDataService( - streamingService, (BankeraMarketDataService) marketDataService); - } - - @Override - public Completable connect(ProductSubscription... args) { - return streamingService.connect(); - } - - @Override - public Completable disconnect() { - return streamingService.disconnect(); - } - - @Override - public boolean isAlive() { - return streamingService.isSocketOpen(); - } - - @Override - public Observable reconnectFailure() { - return streamingService.subscribeReconnectFailure(); - } - - @Override - public Observable connectionSuccess() { - return streamingService.subscribeConnectionSuccess(); - } - - @Override - public Observable connectionStateObservable() { - return streamingService.subscribeConnectionState(); - } - - @Override - public ExchangeSpecification getDefaultExchangeSpecification() { - ExchangeSpecification spec = super.getDefaultExchangeSpecification(); - spec.setShouldLoadRemoteMetaData(false); - - return spec; - } - - @Override - public StreamingMarketDataService getStreamingMarketDataService() { - return streamingMarketDataService; - } - - @Override - public void useCompressedMessages(boolean compressedMessages) { - streamingService.useCompressedMessages(compressedMessages); - } -} diff --git a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingMarketDataService.java b/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingMarketDataService.java deleted file mode 100644 index 77c88da4eda..00000000000 --- a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingMarketDataService.java +++ /dev/null @@ -1,104 +0,0 @@ -package info.bitrich.xchangestream.bankera; - -import info.bitrich.xchangestream.core.StreamingMarketDataService; -import io.reactivex.Observable; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; -import org.knowm.xchange.bankera.BankeraAdapters; -import org.knowm.xchange.bankera.dto.BankeraException; -import org.knowm.xchange.bankera.dto.marketdata.BankeraMarket; -import org.knowm.xchange.bankera.dto.marketdata.BankeraMarketInfo; -import org.knowm.xchange.bankera.dto.marketdata.BankeraOrderBook; -import org.knowm.xchange.bankera.service.BankeraMarketDataService; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Ticker; -import org.knowm.xchange.dto.marketdata.Trade; -import org.knowm.xchange.exceptions.NotAvailableFromExchangeException; - -public class BankeraStreamingMarketDataService implements StreamingMarketDataService { - - private final BankeraStreamingService service; - private final BankeraMarketDataService marketDataService; - - public BankeraStreamingMarketDataService( - BankeraStreamingService service, BankeraMarketDataService marketDataService) { - this.service = service; - this.marketDataService = marketDataService; - } - - @Override - public Observable getOrderBook(CurrencyPair currencyPair, Object... args) { - BankeraMarket market = getMarketInfo(currencyPair); - return service - .subscribeChannel("market-orderbook", market.getId()) - .map( - o -> { - List listBids = new ArrayList<>(); - List listAsks = new ArrayList<>(); - o.get("data") - .get("bids") - .forEach( - b -> - listBids.add( - new BankeraOrderBook.OrderBookOrder( - 0, b.get("price").asText(), b.get("amount").asText()))); - o.get("data") - .get("asks") - .forEach( - b -> - listAsks.add( - new BankeraOrderBook.OrderBookOrder( - 0, b.get("price").asText(), b.get("amount").asText()))); - return BankeraAdapters.adaptOrderBook( - new BankeraOrderBook(listBids, listAsks), currencyPair); - }); - } - - @Override - public Observable getTicker(CurrencyPair currencyPair, Object... args) { - throw new NotAvailableFromExchangeException(); - } - - @Override - public Observable getTrades(CurrencyPair currencyPair, Object... args) { - BankeraMarket market = getMarketInfo(currencyPair); - return service - .subscribeChannel("market-trade", market.getId()) - .map( - t -> - new Trade.Builder() - .currencyPair(currencyPair) - .id("-1") - .price(new BigDecimal(t.get("data").get("price").asText())) - .originalAmount(new BigDecimal(t.get("data").get("amount").asText())) - .timestamp(new Date(t.get("data").get("time").asLong())) - .type( - t.get("data").get("side").asText().equals("SELL") - ? Order.OrderType.ASK - : Order.OrderType.BID) - .build()); - } - - private BankeraMarket getMarketInfo(CurrencyPair currencyPair) { - try { - BankeraMarketInfo info = this.marketDataService.getMarketInfo(); - Optional market = - info.getMarkets().stream() - .filter(m -> m.getName().equals(currencyPair.toString().replace("/", "-"))) - .findFirst(); - - if (market.isPresent()) { - return market.get(); - } - throw new BankeraException(404, "Unable to find market."); - } catch (IOException e) { - throw new BankeraException(404, "Unable to find market."); - } - } -} diff --git a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingService.java b/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingService.java deleted file mode 100644 index 44f8fe64558..00000000000 --- a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/BankeraStreamingService.java +++ /dev/null @@ -1,37 +0,0 @@ -package info.bitrich.xchangestream.bankera; - -import com.fasterxml.jackson.databind.JsonNode; -import info.bitrich.xchangestream.bankera.dto.BankeraWebSocketSubscriptionMessage; -import info.bitrich.xchangestream.service.netty.JsonNettyStreamingService; -import io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler; -import java.io.IOException; - -public class BankeraStreamingService extends JsonNettyStreamingService { - - public BankeraStreamingService(String uri) { - super(uri, Integer.MAX_VALUE); - } - - @Override - protected String getChannelNameFromMessage(JsonNode message) throws IOException { - return message.get("type").asText(); - } - - @Override - public String getSubscribeMessage(String channelName, Object... args) throws IOException { - if (args.length != 1) throw new IOException("SubscribeMessage: Insufficient arguments"); - BankeraWebSocketSubscriptionMessage subscribeMessage = - new BankeraWebSocketSubscriptionMessage(String.valueOf(args[0])); - return objectMapper.writeValueAsString(subscribeMessage); - } - - @Override - public String getUnsubscribeMessage(String channelName, Object... args) throws IOException { - return null; - } - - @Override - protected WebSocketClientExtensionHandler getWebSocketClientExtensionHandler() { - return null; - } -} diff --git a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/dto/BankeraWebSocketSubscriptionMessage.java b/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/dto/BankeraWebSocketSubscriptionMessage.java deleted file mode 100644 index 3ad9d635e9e..00000000000 --- a/xchange-stream-bankera/src/main/java/info/bitrich/xchangestream/bankera/dto/BankeraWebSocketSubscriptionMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -package info.bitrich.xchangestream.bankera.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class BankeraWebSocketSubscriptionMessage { - - @JsonProperty("e") - private String event; - - @JsonProperty("marketId") - private String marketId; - - @JsonProperty("chartInterval") - private String chartInterval; - - public BankeraWebSocketSubscriptionMessage(String marketId) { - this.event = "market"; - this.marketId = marketId; - this.chartInterval = "1m"; - } - - public BankeraWebSocketSubscriptionMessage(String marketId, String chartInterval) { - this.event = "market"; - this.marketId = marketId; - this.chartInterval = chartInterval; - } - - public String getEvent() { - return event; - } - - public String getMarketId() { - return marketId; - } - - public String getChartInterval() { - return chartInterval; - } -} diff --git a/xchange-stream-bankera/src/test/java/info/bitrich/xchangestream/bankera/BankeraManualExample.java b/xchange-stream-bankera/src/test/java/info/bitrich/xchangestream/bankera/BankeraManualExample.java deleted file mode 100644 index e98b7605eb1..00000000000 --- a/xchange-stream-bankera/src/test/java/info/bitrich/xchangestream/bankera/BankeraManualExample.java +++ /dev/null @@ -1,39 +0,0 @@ -package info.bitrich.xchangestream.bankera; - -import info.bitrich.xchangestream.core.StreamingExchange; -import info.bitrich.xchangestream.core.StreamingExchangeFactory; -import org.knowm.xchange.currency.CurrencyPair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BankeraManualExample { - private static final Logger LOGGER = LoggerFactory.getLogger(BankeraManualExample.class); - - public static void main(String[] args) { - StreamingExchange exchange = - StreamingExchangeFactory.INSTANCE.createExchange(BankeraStreamingExchange.class); - - exchange.connect().blockingAwait(); - exchange - .getStreamingMarketDataService() - .getOrderBook(CurrencyPair.ETH_BTC) - .subscribe( - orderBook -> LOGGER.debug("ORDERBOOK: {}", orderBook.toString()), - throwable -> LOGGER.error("ERROR in getting order book: ", throwable)); - - exchange - .getStreamingMarketDataService() - .getTrades(CurrencyPair.ETH_BTC) - .subscribe( - trade -> LOGGER.debug("TRADES: {}", trade.toString()), - throwable -> LOGGER.error("ERROR in getting trade ", throwable)); - - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - exchange.disconnect().subscribe(() -> LOGGER.info("Disconnected")); - } -} diff --git a/xchange-stream-bankera/src/test/resources/logback.xml b/xchange-stream-bankera/src/test/resources/logback.xml deleted file mode 100644 index 5809b573500..00000000000 --- a/xchange-stream-bankera/src/test/resources/logback.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - %d{HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{36} - %msg %xEx%n - - - - - - - - - - - - - -