use of org.knowm.xchange.mercadobitcoin.dto.trade.MercadoBitcoinUserOrdersEntry in project XChange by knowm.
the class MercadoBitcoinAdapters method toUserTrades.
public static UserTrades toUserTrades(CurrencyPair pair, MercadoBitcoinBaseTradeApiResult<MercadoBitcoinUserOrders> orders) {
List<UserTrade> result = new LinkedList<>();
for (Map.Entry<String, MercadoBitcoinUserOrdersEntry> e : orders.getTheReturn().entrySet()) {
String orderId = e.getKey();
MercadoBitcoinUserOrdersEntry order = e.getValue();
OrderType type = toOrderType(order.getType());
for (Map.Entry<String, OperationEntry> f : order.getOperations().entrySet()) {
String txId = f.getKey();
OperationEntry op = f.getValue();
result.add(new UserTrade.Builder().currencyPair(pair).id(txId).orderId(orderId).price(op.getPrice()).timestamp(fromUnixTime(op.getCreated())).originalAmount(op.getVolume()).type(type).build());
}
}
// TODO verify sortType
return new UserTrades(result, Trades.TradeSortType.SortByID);
}
use of org.knowm.xchange.mercadobitcoin.dto.trade.MercadoBitcoinUserOrdersEntry in project XChange by knowm.
the class MercadoBitcoinAdapters method processOrderEntry.
private static LimitOrder processOrderEntry(Map.Entry<String, MercadoBitcoinUserOrdersEntry> entry, CurrencyPair currencyPair) {
String id = entry.getKey();
MercadoBitcoinUserOrdersEntry userOrdersEntry = entry.getValue();
String type = userOrdersEntry.getType();
OrderType orderType = toOrderType(type);
BigDecimal price = userOrdersEntry.getPrice();
BigDecimal volume = userOrdersEntry.getVolume();
long time = userOrdersEntry.getCreated() * 1000L;
return new LimitOrder(orderType, volume, currencyPair, id, new Date(time), price);
}
use of org.knowm.xchange.mercadobitcoin.dto.trade.MercadoBitcoinUserOrdersEntry in project XChange by knowm.
the class MercadoBitcoinAdapters method adaptOrders.
public static List<LimitOrder> adaptOrders(CurrencyPair currencyPair, MercadoBitcoinBaseTradeApiResult<MercadoBitcoinUserOrders> input) {
List<LimitOrder> limitOrders = new ArrayList<>();
MercadoBitcoinUserOrders orders = input.getTheReturn();
for (Map.Entry<String, MercadoBitcoinUserOrdersEntry> entry : orders.entrySet()) {
limitOrders.add(processOrderEntry(entry, currencyPair));
}
return limitOrders;
}
use of org.knowm.xchange.mercadobitcoin.dto.trade.MercadoBitcoinUserOrdersEntry in project XChange by knowm.
the class MercadoBitcoinTradeDemo method printRawOpenOrders.
private static void printRawOpenOrders(MercadoBitcoinTradeServiceRaw tradeService) throws IOException, InterruptedException {
MercadoBitcoinBaseTradeApiResult<MercadoBitcoinUserOrders> openOrdersResult = tradeService.getMercadoBitcoinUserOrders("btc_brl", null, "active", null, null, null, null);
MercadoBitcoinUserOrders openOrders = openOrdersResult.getTheReturn();
System.out.println("Open Orders for BTC: " + openOrders.size());
for (Map.Entry<String, MercadoBitcoinUserOrdersEntry> order : openOrders.entrySet()) {
System.out.println(order.toString());
}
openOrdersResult = tradeService.getMercadoBitcoinUserOrders("ltc_brl", null, "active", null, null, null, null);
openOrders = openOrdersResult.getTheReturn();
System.out.println("Open Orders for LTC: " + openOrders.size());
for (Map.Entry<String, MercadoBitcoinUserOrdersEntry> order : openOrders.entrySet()) {
System.out.println(order.toString());
}
}
Aggregations