use of org.knowm.xchange.bitstamp.dto.trade.BitstampOrder 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);
}
use of org.knowm.xchange.bitstamp.dto.trade.BitstampOrder in project XChange by knowm.
the class BitstampTradeService method placeMarketOrder.
@Override
public String placeMarketOrder(MarketOrder order) throws IOException, BitstampException {
BitstampAuthenticatedV2.Side side = order.getType().equals(BID) ? BitstampAuthenticatedV2.Side.buy : BitstampAuthenticatedV2.Side.sell;
BitstampOrder bitstampOrder = placeBitstampMarketOrder(order.getCurrencyPair(), side, order.getOriginalAmount());
if (bitstampOrder.getErrorMessage() != null) {
throw new ExchangeException(bitstampOrder.getErrorMessage());
}
return Long.toString(bitstampOrder.getId());
}
use of org.knowm.xchange.bitstamp.dto.trade.BitstampOrder in project XChange by knowm.
the class BitstampTradeDemo method raw.
private static void raw(BitstampTradeServiceRaw tradeService) throws IOException {
printRawOpenOrders(tradeService);
// place a limit buy order
BitstampOrder order = tradeService.placeBitstampOrder(CurrencyPair.BTC_USD, Side.sell, new BigDecimal(".001"), new BigDecimal("1000.00"));
System.out.println("BitstampOrder return value: " + order);
printRawOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelBitstampOrder(order.getId());
System.out.println("Canceling returned " + cancelResult);
printRawOpenOrders(tradeService);
}
use of org.knowm.xchange.bitstamp.dto.trade.BitstampOrder in project XChange by knowm.
the class BitstampTradeService method placeLimitOrder.
@Override
public String placeLimitOrder(LimitOrder order) throws IOException, BitstampException {
BitstampAuthenticatedV2.Side side = order.getType().equals(BID) ? BitstampAuthenticatedV2.Side.buy : BitstampAuthenticatedV2.Side.sell;
BitstampOrder bitstampOrder = placeBitstampOrder(order.getCurrencyPair(), side, order.getOriginalAmount(), order.getLimitPrice());
if (bitstampOrder.getErrorMessage() != null) {
throw new ExchangeException(bitstampOrder.getErrorMessage());
}
return Long.toString(bitstampOrder.getId());
}
use of org.knowm.xchange.bitstamp.dto.trade.BitstampOrder in project XChange by knowm.
the class BitstampTradeDemo method printRawOpenOrders.
private static void printRawOpenOrders(BitstampTradeServiceRaw tradeService) throws IOException {
BitstampOrder[] openOrders = tradeService.getBitstampOpenOrders(CurrencyPair.BTC_USD);
System.out.println("Open Orders: " + openOrders.length);
for (BitstampOrder order : openOrders) {
System.out.println(order.toString());
}
}
Aggregations