use of org.knowm.xchange.dto.Order.OrderStatus in project XChange by knowm.
the class BitmexAdapters method adaptLimitOrder.
public static LimitOrder adaptLimitOrder(BitmexOrder bitmexOrder, String id) {
BitmexOrderDescription orderDescription = bitmexOrder.getOrderDescription();
OrderType type = adaptOrderType(orderDescription.getType());
BigDecimal originalAmount = bitmexOrder.getVolume();
BigDecimal filledAmount = bitmexOrder.getVolumeExecuted();
CurrencyPair pair = BitmexAdapters.adaptSymbolToCurrencyPair(orderDescription.getAssetPair());
Date timestamp = new Date((long) (bitmexOrder.getOpenTimestamp() * 1000L));
OrderStatus status = adaptOrderStatus(bitmexOrder.getStatus());
if (status == OrderStatus.NEW && filledAmount.compareTo(BigDecimal.ZERO) > 0 && filledAmount.compareTo(originalAmount) < 0) {
status = OrderStatus.PARTIALLY_FILLED;
}
return new LimitOrder(type, originalAmount, pair, id, timestamp, orderDescription.getPrice(), orderDescription.getPrice(), filledAmount, bitmexOrder.getFee(), status);
}
use of org.knowm.xchange.dto.Order.OrderStatus in project XChange by knowm.
the class CoinbaseProAdapters method adaptOrderStatuses.
public static OrderStatus[] adaptOrderStatuses(CoinbaseProOrder[] orders) {
OrderStatus[] orderStatuses = new OrderStatus[orders.length];
int i = 0;
for (CoinbaseProOrder coinbaseProOrder : orders) {
orderStatuses[i++] = adaptOrderStatus(coinbaseProOrder);
}
return orderStatuses;
}
use of org.knowm.xchange.dto.Order.OrderStatus in project XChange by knowm.
the class GeminiAdapters method adaptOrder.
public static Order adaptOrder(GeminiOrderStatusResponse geminiOrderStatusResponse) {
Long id = geminiOrderStatusResponse.getId();
CurrencyPair currencyPair = adaptCurrencyPair(geminiOrderStatusResponse.getSymbol());
BigDecimal averageExecutionPrice = geminiOrderStatusResponse.getAvgExecutionPrice();
BigDecimal executedAmount = geminiOrderStatusResponse.getExecutedAmount();
BigDecimal originalAmount = geminiOrderStatusResponse.getOriginalAmount();
OrderType orderType = (geminiOrderStatusResponse.getSide().equals("buy")) ? OrderType.BID : OrderType.ASK;
OrderStatus orderStatus = adaptOrderstatus(geminiOrderStatusResponse);
Date timestamp = new Date(geminiOrderStatusResponse.getTimestampms());
// Calculate Fees in counter currency
BigDecimal fee = null;
if (geminiOrderStatusResponse.getTrades() != null && geminiOrderStatusResponse.getTrades().length > 0) {
for (GeminiOrderStatusResponse.OrderStatusTradeDetails trade : geminiOrderStatusResponse.getTrades()) {
if (fee == null) {
fee = trade.getFeeAmount();
} else {
fee.add(trade.getFeeAmount());
}
}
}
if (geminiOrderStatusResponse.getType().contains("limit")) {
BigDecimal limitPrice = geminiOrderStatusResponse.getPrice();
return new LimitOrder(orderType, originalAmount, currencyPair, id.toString(), timestamp, limitPrice, averageExecutionPrice, executedAmount, fee, orderStatus, geminiOrderStatusResponse.getClientOrderId());
} else if (geminiOrderStatusResponse.getType().contains("market")) {
return new MarketOrder(orderType, originalAmount, currencyPair, id.toString(), timestamp, averageExecutionPrice, executedAmount, fee, orderStatus, geminiOrderStatusResponse.getClientOrderId());
}
throw new NotYetImplementedForExchangeException();
}
use of org.knowm.xchange.dto.Order.OrderStatus in project XChange by knowm.
the class KrakenAdapters method adaptOrder.
public static Order adaptOrder(String orderId, KrakenOrder krakenOrder) {
OrderType orderType = adaptOrderType(krakenOrder.getOrderDescription().getType());
CurrencyPair currencyPair = adaptCurrencyPair(krakenOrder.getOrderDescription().getAssetPair());
OrderStatus orderStatus = adaptOrderStatus(krakenOrder.getStatus());
BigDecimal filledAmount = krakenOrder.getVolumeExecuted();
BigDecimal originalAmount = krakenOrder.getVolume();
BigDecimal fee = krakenOrder.getFee();
if (orderStatus == OrderStatus.NEW && filledAmount.compareTo(BigDecimal.ZERO) > 0 && filledAmount.compareTo(originalAmount) < 0) {
orderStatus = OrderStatus.PARTIALLY_FILLED;
}
// eg: "opentm":1519731205.9987
Double time = krakenOrder.getOpenTimestamp() * 1000;
Date timestamp = new Date(time.longValue());
if (krakenOrder.getOrderDescription().getOrderType().equals(KrakenOrderType.LIMIT))
return new LimitOrder(orderType, krakenOrder.getVolume(), currencyPair, orderId, timestamp, krakenOrder.getOrderDescription().getPrice(), krakenOrder.getPrice(), krakenOrder.getVolumeExecuted(), fee, orderStatus, krakenOrder.getUserRefId());
if (krakenOrder.getOrderDescription().getOrderType().equals(KrakenOrderType.MARKET))
return new MarketOrder(orderType, krakenOrder.getVolume(), currencyPair, orderId, timestamp, krakenOrder.getPrice(), krakenOrder.getVolumeExecuted(), fee, orderStatus, krakenOrder.getUserRefId());
throw new NotYetImplementedForExchangeException();
}
use of org.knowm.xchange.dto.Order.OrderStatus in project XChange by knowm.
the class LatokenAdapters method adaptOrder.
public static LimitOrder adaptOrder(Exchange exchange, LatokenOrder order) {
OrderType type = adaptOrderType(order.getSide());
CurrencyPair currencyPair = adaptCurrencyPair(exchange, order.getSymbol());
OrderStatus orderStatus = adaptOrderStatus(order.getOrderStatus());
return new LimitOrder.Builder(type, currencyPair).originalAmount(order.getAmount()).id(order.getOrderId()).timestamp(order.getTimeCreated()).limitPrice(order.getPrice()).cumulativeAmount(order.getExecutedAmount()).fee(BigDecimal.ZERO).orderStatus(orderStatus).build();
}
Aggregations