Search in sources :

Example 1 with BitstampV2

use of org.knowm.xchange.bitstamp.BitstampV2 in project XChange by knowm.

the class BitstampTradeService method getOpenOrders.

@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws ExchangeException, IOException {
    BitstampOrder[] openOrders = getBitstampOpenOrders();
    List<LimitOrder> limitOrders = new ArrayList<>(openOrders.length);
    for (BitstampOrder bitstampOrder : openOrders) {
        OrderType orderType = bitstampOrder.getType() == 0 ? OrderType.BID : OrderType.ASK;
        String id = Long.toString(bitstampOrder.getId());
        BigDecimal price = bitstampOrder.getPrice();
        limitOrders.add(new LimitOrder(orderType, bitstampOrder.getAmount(), new BitstampV2.Pair(bitstampOrder.getCurrencyPair()).pair, id, bitstampOrder.getDatetime(), price, // avgPrice
        null, // cumAmount
        null, // fee
        null, Order.OrderStatus.NEW));
    }
    return new OpenOrders(limitOrders);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) BitstampV2(org.knowm.xchange.bitstamp.BitstampV2) BitstampOrder(org.knowm.xchange.bitstamp.dto.trade.BitstampOrder) ArrayList(java.util.ArrayList) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 BitstampV2 (org.knowm.xchange.bitstamp.BitstampV2)1 BitstampOrder (org.knowm.xchange.bitstamp.dto.trade.BitstampOrder)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)1