Search in sources :

Example 1 with NotYetImplementedForExchangeException

use of org.knowm.xchange.exceptions.NotYetImplementedForExchangeException in project XChange by knowm.

the class CoingiAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams p) throws IOException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException {
    try {
        if (p instanceof DefaultWithdrawFundsParams) {
            DefaultWithdrawFundsParams params = (DefaultWithdrawFundsParams) p;
            CoingiWithdrawalRequest request = new CoingiWithdrawalRequest().setAddress(params.address).setAmount(params.amount).setCurrency(params.currency.getCurrencyCode().toUpperCase());
            return withdraw(request).toString();
        }
        throw new NotYetImplementedForExchangeException();
    } catch (CoingiException e) {
        throw CoingiErrorAdapter.adapt(e);
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiWithdrawalRequest(org.knowm.xchange.coingi.dto.account.CoingiWithdrawalRequest) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)

Example 2 with NotYetImplementedForExchangeException

use of org.knowm.xchange.exceptions.NotYetImplementedForExchangeException in project XChange by knowm.

the class BitfinexTradeService method placeStopOrder.

@Override
public String placeStopOrder(StopOrder stopOrder) throws IOException {
    if (stopOrder.getLimitPrice() != null) {
        throw new NotYetImplementedForExchangeException("Limit stops are not supported by the Bitfinex v1 API.");
    }
    LimitOrder limitOrder = new LimitOrder(stopOrder.getType(), stopOrder.getOriginalAmount(), stopOrder.getCurrencyPair(), stopOrder.getId(), stopOrder.getTimestamp(), stopOrder.getStopPrice());
    limitOrder.setOrderFlags(stopOrder.getOrderFlags());
    limitOrder.setLeverage(stopOrder.getLeverage());
    limitOrder.addOrderFlag(BitfinexOrderFlags.STOP);
    return placeLimitOrder(limitOrder);
}
Also used : NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder)

Example 3 with NotYetImplementedForExchangeException

use of org.knowm.xchange.exceptions.NotYetImplementedForExchangeException in project XChange by knowm.

the class BithumbTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
    try {
        if (!(orderParams instanceof CancelOrderByIdParams && orderParams instanceof CancelOrderByCurrencyPair)) {
            throw new NotYetImplementedForExchangeException("Only CancelOrderByPairAndIdParams || (CancelOrderByIdParams && CancelOrderByCurrencyPair) supported");
        }
        String orderId = ((CancelOrderByIdParams) orderParams).getOrderId();
        CurrencyPair pair = ((CancelOrderByCurrencyPair) orderParams).getCurrencyPair();
        return cancelBithumbOrder(orderId, pair);
    } catch (BithumbException e) {
        throw BithumbErrorAdapter.adapt(e);
    }
}
Also used : BithumbException(org.knowm.xchange.bithumb.BithumbException) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Example 4 with NotYetImplementedForExchangeException

use of org.knowm.xchange.exceptions.NotYetImplementedForExchangeException in project XChange by knowm.

the class TradeDemo method generic.

private static void generic(TradeService tradeService) throws NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
    printOpenOrders(tradeService);
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder(Order.OrderType.BID, BigDecimal.ONE, new CurrencyPair(Currency.GHs, Currency.BTC), "", null, new BigDecimal("0.00015600"));
    System.out.println("Trying to place: " + limitOrder);
    String orderId = "0";
    try {
        orderId = tradeService.placeLimitOrder(limitOrder);
        System.out.println("New Limit Order ID: " + orderId);
    } catch (ExchangeException e) {
        System.out.println(e);
    }
    printOpenOrders(tradeService);
    // Cancel the added order
    boolean cancelResult = tradeService.cancelOrder(orderId);
    System.out.println("Canceling order id=" + orderId + " returned " + cancelResult);
    printOpenOrders(tradeService);
}
Also used : NotAvailableFromExchangeException(org.knowm.xchange.exceptions.NotAvailableFromExchangeException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 5 with NotYetImplementedForExchangeException

use of org.knowm.xchange.exceptions.NotYetImplementedForExchangeException in project XChange by knowm.

the class GeminiStreamingMarketDataService method getOrderBook.

@Override
public Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... args) {
    int maxDepth = (int) MoreObjects.firstNonNull(args.length > 0 ? args[0] : null, 1);
    Observable<GeminiOrderbook> subscribedOrderbookSnapshot = service.subscribeChannel(currencyPair, maxDepth, maxDepth).filter(s -> filterEventsByReason(s, "change", "initial") || filterEventsByReason(s, "change", "place") || filterEventsByReason(s, "change", "cancel") || filterEventsByReason(s, "change", "trade")).filter(// filter out updates that arrive before initial book
    s -> orderbooks.get(currencyPair) != null || filterEventsByReason(s, "change", "initial")).map((JsonNode s) -> {
        if (filterEventsByReason(s, "change", "initial")) {
            GeminiWebSocketTransaction transaction = mapper.treeToValue(s, GeminiWebSocketTransaction.class);
            GeminiOrderbook orderbook = transaction.toGeminiOrderbook(currencyPair);
            orderbooks.put(currencyPair, orderbook);
            return orderbook;
        }
        if (filterEventsByReason(s, "change", "place") || filterEventsByReason(s, "change", "cancel") || filterEventsByReason(s, "change", "trade")) {
            GeminiWebSocketTransaction transaction = mapper.treeToValue(s, GeminiWebSocketTransaction.class);
            GeminiLimitOrder[] levels = transaction.toGeminiLimitOrdersUpdate();
            GeminiOrderbook orderbook = orderbooks.get(currencyPair);
            orderbook.updateLevels(levels);
            return orderbook;
        }
        throw new NotYetImplementedForExchangeException(" Unknown message type, even after filtering: " + s.toString());
    });
    return subscribedOrderbookSnapshot.map(geminiOrderbook -> GeminiAdaptersX.toOrderbook(geminiOrderbook, maxDepth, new Date()));
}
Also used : StreamingMarketDataService(info.bitrich.xchangestream.core.StreamingMarketDataService) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) GeminiOrderbook(info.bitrich.xchangestream.gemini.dto.GeminiOrderbook) Ticker(org.knowm.xchange.dto.marketdata.Ticker) GeminiTrade(org.knowm.xchange.gemini.v1.dto.marketdata.GeminiTrade) Date(java.util.Date) GeminiAdapters.adaptTrades(org.knowm.xchange.gemini.v1.GeminiAdapters.adaptTrades) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MoreObjects(com.google.common.base.MoreObjects) HashMap(java.util.HashMap) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) GeminiLimitOrder(info.bitrich.xchangestream.gemini.dto.GeminiLimitOrder) StreamingObjectMapperHelper(info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper) GeminiWebSocketTransaction(info.bitrich.xchangestream.gemini.dto.GeminiWebSocketTransaction) PublishSubject(io.reactivex.subjects.PublishSubject) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) Observable(io.reactivex.Observable) Trade(org.knowm.xchange.dto.marketdata.Trade) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) GeminiOrderbook(info.bitrich.xchangestream.gemini.dto.GeminiOrderbook) GeminiWebSocketTransaction(info.bitrich.xchangestream.gemini.dto.GeminiWebSocketTransaction) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) JsonNode(com.fasterxml.jackson.databind.JsonNode) GeminiLimitOrder(info.bitrich.xchangestream.gemini.dto.GeminiLimitOrder) Date(java.util.Date)

Aggregations

NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)9 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)6 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)5 Date (java.util.Date)4 BigDecimal (java.math.BigDecimal)3 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)3 OrderStatus (org.knowm.xchange.dto.Order.OrderStatus)2 OrderType (org.knowm.xchange.dto.Order.OrderType)2 Ticker (org.knowm.xchange.dto.marketdata.Ticker)2 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)2 CurrencyUtil (bisq.core.locale.CurrencyUtil)1 TradeCurrency (bisq.core.locale.TradeCurrency)1 PriceProvider (bisq.price.PriceProvider)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MoreObjects (com.google.common.base.MoreObjects)1 StreamingMarketDataService (info.bitrich.xchangestream.core.StreamingMarketDataService)1 GeminiLimitOrder (info.bitrich.xchangestream.gemini.dto.GeminiLimitOrder)1 GeminiOrderbook (info.bitrich.xchangestream.gemini.dto.GeminiOrderbook)1 GeminiWebSocketTransaction (info.bitrich.xchangestream.gemini.dto.GeminiWebSocketTransaction)1