package org.knowm.xchange.bittrex.service;

import static org.knowm.xchange.service.trade.params.TradeHistoryParamsZero.PARAMS_ZERO;

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.bittrex.BittrexAdapters;
import org.knowm.xchange.bittrex.dto.account.BittrexOrder;
import org.knowm.xchange.bittrex.dto.trade.BittrexUserTrade;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order;
import org.knowm.xchange.dto.marketdata.Trades.TradeSortType;
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.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.CancelOrderByIdParams;
import org.knowm.xchange.service.trade.params.CancelOrderParams;
import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;

public class BittrexTradeService extends BittrexTradeServiceRaw implements TradeService {

  /**
   * Constructor
   *
   * @param exchange
   */
  public BittrexTradeService(Exchange exchange) {

    super(exchange);
  }

  @Override
  public String placeMarketOrder(MarketOrder marketOrder) throws IOException {

    String id = placeBittrexMarketOrder(marketOrder);

    return id;
  }

  @Override
  public String placeLimitOrder(LimitOrder limitOrder) throws IOException {

    String id = placeBittrexLimitOrder(limitOrder);

    return id;
  }

  @Override
  public OpenOrders getOpenOrders() throws IOException {
    return getOpenOrders(createOpenOrdersParams());
  }

  @Override
  public OpenOrders getOpenOrders(
      OpenOrdersParams params) throws IOException {
    return new OpenOrders(BittrexAdapters.adaptOpenOrders(getBittrexOpenOrders(params)));
  }

  @Override
  public boolean cancelOrder(String orderId) throws IOException {

    return cancelBittrexLimitOrder(orderId);
  }

  @Override
  public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
    if (orderParams instanceof CancelOrderByIdParams) {
      return cancelOrder(((CancelOrderByIdParams) orderParams).getOrderId());
    } else {
      return false;
    }
  }

  @Override
  public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    CurrencyPair currencyPair = null;
    if (params instanceof TradeHistoryParamCurrencyPair) {
      TradeHistoryParamCurrencyPair tradeHistoryParamCurrencyPair = (TradeHistoryParamCurrencyPair) params;
      currencyPair = tradeHistoryParamCurrencyPair.getCurrencyPair();
    }

    List<BittrexUserTrade> bittrexTradeHistory = getBittrexTradeHistory(currencyPair);
    return new UserTrades(BittrexAdapters.adaptUserTrades(bittrexTradeHistory), TradeSortType.SortByTimestamp);
  }

  @Override
  public TradeHistoryParams createTradeHistoryParams() {
    return PARAMS_ZERO;
  }

  @Override
  public OpenOrdersParams createOpenOrdersParams() {
    return null;
  }

  @Override
  public Collection<Order> getOrder(
      String... orderIds) throws IOException {
    List<Order> orders = new ArrayList<>();

    for (String orderId : orderIds) {

      BittrexOrder order = getBittrexOrder(orderId);
      if (order != null) {
        LimitOrder limitOrder = BittrexAdapters.adaptOrder(order);
        orders.add(limitOrder);
      }

    }
    return orders;
  }

}

@@ -41,98 +41,8 @@
 e;%0A%0A
-import static org.knowm.xchange.service.trade.params.TradeHistoryParamsZero.PARAMS_ZERO;%0A%0A
 impo
@@ -865,32 +865,116 @@
 celOrderParams;%0A
+import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair;%0A
 import org.knowm
@@ -1092,32 +1092,121 @@
 eHistoryParams;%0A
+import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;%0A
 import org.knowm
@@ -3199,19 +3199,50 @@
 urn 
-PARAMS_ZERO
+new DefaultTradeHistoryParamCurrencyPair()
 ;%0A  
@@ -3321,19 +3321,55 @@
 return n
-ull
+ew DefaultOpenOrdersParamCurrencyPair()
 ;%0A  %7D%0A%0A 

Change default params