Package com.xeiam.xchange.btcchina.dto.trade.response

Examples of com.xeiam.xchange.btcchina.dto.trade.response.BTCChinaIntegerResponse


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

    final BigDecimal amount = marketOrder.getTradableAmount();
    final String market = BTCChinaAdapters.adaptMarket(marketOrder.getCurrencyPair()).toUpperCase();
    final BTCChinaIntegerResponse response;

    if (marketOrder.getType() == OrderType.BID) {
      response = buy(null, amount, market);
    }
    else {
      response = sell(null, amount, market);
    }

    return response.getResult().toString();
  }
View Full Code Here


  public String placeLimitOrder(LimitOrder limitOrder) throws IOException {

    final BigDecimal price = limitOrder.getLimitPrice();
    final BigDecimal amount = limitOrder.getTradableAmount();
    final String market = BTCChinaAdapters.adaptMarket(limitOrder.getCurrencyPair()).toUpperCase();
    final BTCChinaIntegerResponse response;

    if (limitOrder.getType() == OrderType.BID) {
      response = buy(price, amount, market);
    }
    else {
      response = sell(price, amount, market);
    }

    return response.getResult().toString();
  }
View Full Code Here

   * @deprecated use {@link #buy(BigDecimal, BigDecimal, String)} or {@link #sell(BigDecimal, BigDecimal, String)} instead.
   */
  @Deprecated
  public BTCChinaIntegerResponse placeBTCChinaLimitOrder(BigDecimal price, BigDecimal amount, OrderType orderType) throws IOException {

    BTCChinaIntegerResponse response = null;

    if (orderType == OrderType.BID) {

      response = btcChina.buyOrder2(signatureCreator, BTCChinaUtils.getNonce(), new BTCChinaBuyOrderRequest(price, amount));
    }
View Full Code Here

   * @throws IOException
   */
  public BTCChinaIntegerResponse buy(BigDecimal price, BigDecimal amount, String market) throws IOException {

    BTCChinaBuyOrderRequest request = new BTCChinaBuyOrderRequest(price, amount, market);
    final BTCChinaIntegerResponse response;
    try {
      response = btcChina.buyOrder2(signatureCreator, BTCChinaUtils.getNonce(), request);
    } catch (HttpStatusIOException e) {
      if (e.getHttpStatusCode() == 401) {
        log.error("{}, request: {}, response: {}", e.getMessage(), request, e.getHttpBody());
View Full Code Here

   * @throws IOException
   */
  public BTCChinaIntegerResponse sell(BigDecimal price, BigDecimal amount, String market) throws IOException {

    BTCChinaSellOrderRequest request = new BTCChinaSellOrderRequest(price, amount, market);
    final BTCChinaIntegerResponse response;
    try {
      response = btcChina.sellOrder2(signatureCreator, BTCChinaUtils.getNonce(), request);
    } catch (HttpStatusIOException e) {
      if (e.getHttpStatusCode() == 401) {
        log.error("{}, request: {}, response: {}", e.getMessage(), request, e.getHttpBody());
View Full Code Here

  }

  public BTCChinaIntegerResponse buyIcebergOrder(BigDecimal price, BigDecimal amount, BigDecimal disclosedAmount, BigDecimal variance, String market) throws IOException {

    BTCChinaBuyIcebergOrderRequest request = new BTCChinaBuyIcebergOrderRequest(price, amount, disclosedAmount, variance, market);
    BTCChinaIntegerResponse response = btcChina.buyIcebergOrder(signatureCreator, tonce, request);
    return checkResult(response);
  }
View Full Code Here

  }

  public BTCChinaIntegerResponse sellIcebergOrder(BigDecimal price, BigDecimal amount, BigDecimal disclosedAmount, BigDecimal variance, String market) throws IOException {

    BTCChinaSellIcebergOrderRequest request = new BTCChinaSellIcebergOrderRequest(price, amount, disclosedAmount, variance, market);
    BTCChinaIntegerResponse response = btcChina.sellIcebergOrder(signatureCreator, tonce, request);
    return checkResult(response);
  }
View Full Code Here

   * @see BTCChinaBuyStopOrderRequest
   */
  public BTCChinaIntegerResponse buyStopOrder(BigDecimal stopPrice, BigDecimal price, BigDecimal amount, BigDecimal trailingAmount, BigDecimal trailingPercentage, String market) throws IOException {

    BTCChinaBuyStopOrderRequest request = new BTCChinaBuyStopOrderRequest(stopPrice, price, amount, trailingAmount, trailingPercentage, market);
    BTCChinaIntegerResponse response = btcChina.buyStopOrder(signatureCreator, tonce, request);
    return checkResult(response);
  }
View Full Code Here

   * @see BTCChinaSellStopOrderRequest
   */
  public BTCChinaIntegerResponse sellStopOrder(BigDecimal stopPrice, BigDecimal price, BigDecimal amount, BigDecimal trailingAmount, BigDecimal trailingPercentage, String market) throws IOException {

    BTCChinaSellStopOrderRequest request = new BTCChinaSellStopOrderRequest(stopPrice, price, amount, trailingAmount, trailingPercentage, market);
    BTCChinaIntegerResponse response = btcChina.sellStopOrder(signatureCreator, tonce, request);
    return checkResult(response);
  }
View Full Code Here

    printOpenOrdersRaw();

    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((OrderType.BID), BigDecimal.ONE, CurrencyPair.BTC_CNY, "", null, new BigDecimal("0.01"));
    BTCChinaIntegerResponse limitOrderReturnValue = ((BTCChinaTradeServiceRaw) tradeService).buy(new BigDecimal("0.01"), BigDecimal.ONE, "BTCCNY");
    System.out.println("Limit Order return value: " + limitOrderReturnValue);

    Thread.sleep(1500);
    BTCChinaResponse<BTCChinaOrders> openOrders = printOpenOrdersRaw();

    long result = -1;
    for (int i = 0; i < openOrders.getResult().getOrders().size(); i++) {
      BTCChinaOrder order = openOrders.getResult().getOrders().get(i);
      int orderId = order.getId();
      if (order.getType().equals(limitOrder.getType().toString()) && order.getPrice().compareTo(limitOrder.getLimitPrice()) == 0 && orderId > result) {
        result = orderId;
      }
    }

    // Cancel the added order
    BTCChinaBooleanResponse cancelResult = ((BTCChinaTradeServiceRaw) tradeService).cancelBTCChinaOrder(limitOrderReturnValue.getResult().intValue());
    System.out.println("Canceling returned " + cancelResult);

    printOpenOrders();
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.btcchina.dto.trade.response.BTCChinaIntegerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.