コード例 #1
0
  @Override
  public String placeLimitOrder(LimitOrder limitOrder) throws IOException, BitstampException {

    Assert.isTrue(
        limitOrder.getCurrencyPair().equals(CurrencyPair.BTC_USD),
        "Currency Pair must be USD/BTC!!!");

    BitstampOrder bitstampOrder;
    if (limitOrder.getType() == BID) {
      bitstampOrder = buyBitStampOrder(limitOrder.getTradableAmount(), limitOrder.getLimitPrice());
    } else {
      bitstampOrder = sellBitstampOrder(limitOrder.getTradableAmount(), limitOrder.getLimitPrice());
    }
    if (bitstampOrder.getErrorMessage() != null) {
      throw new ExchangeException(bitstampOrder.getErrorMessage());
    }

    return Integer.toString(bitstampOrder.getId());
  }
コード例 #2
0
  @Override
  public OpenOrders getOpenOrders() throws IOException, BitstampException {

    BitstampOrder[] openOrders = getBitstampOpenOrders();

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>();
    for (BitstampOrder bitstampOrder : openOrders) {
      OrderType orderType = bitstampOrder.getType() == 0 ? OrderType.BID : OrderType.ASK;
      String id = Integer.toString(bitstampOrder.getId());
      BigDecimal price = bitstampOrder.getPrice();
      limitOrders.add(
          new LimitOrder(
              orderType,
              bitstampOrder.getAmount(),
              CurrencyPair.BTC_USD,
              id,
              bitstampOrder.getTime(),
              price));
    }
    return new OpenOrders(limitOrders);
  }