use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class IdexTradeService method placeLimitOrder.
/**
* returns OrderHash so you can fetch it and cancel it... but there is a OrderNumber that you can
* intercept if you need to.
*/
@Override
public String placeLimitOrder(LimitOrder placeOrder) {
OrderType type = placeOrder.getType();
Currency baseCurrency = placeOrder.getCurrencyPair().base;
Currency counterCurrency = placeOrder.getCurrencyPair().counter;
BigDecimal originalAmount = placeOrder.getOriginalAmount();
BigDecimal limitPrice = placeOrder.getLimitPrice();
OrderReq orderReq = createNormalizedLimitOrderReq(baseCurrency, counterCurrency, type, limitPrice, originalAmount, null, null, null);
try {
orderApi.order(orderReq).getOrderHash();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class BittrexAdapters method adaptOrder.
public static LimitOrder adaptOrder(BittrexOrder order, OrderStatus status) {
OrderType type = order.getDirection().equalsIgnoreCase(BittrexConstants.SELL) ? OrderType.ASK : OrderType.BID;
CurrencyPair pair = BittrexUtils.toCurrencyPair(order.getMarketSymbol());
return new LimitOrder.Builder(type, pair).originalAmount(order.getQuantity()).id(order.getId()).timestamp(order.getUpdatedAt() != null ? order.getUpdatedAt() : order.getCreatedAt()).limitPrice(order.getLimit()).remainingAmount(order.getQuantity().subtract(order.getFillQuantity())).fee(order.getCommission()).orderStatus(status).build();
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class HitbtcAdapters method adaptTrades.
public static Trades adaptTrades(List<? extends HitbtcTrade> allHitbtcTrades, CurrencyPair currencyPair) {
List<Trade> trades = new ArrayList<>(allHitbtcTrades.size());
long lastTradeId = 0;
for (int i = 0; i < allHitbtcTrades.size(); i++) {
HitbtcTrade hitbtcTrade = allHitbtcTrades.get(i);
Date timestamp = hitbtcTrade.getTimestamp();
BigDecimal price = hitbtcTrade.getPrice();
BigDecimal amount = hitbtcTrade.getQuantity();
String tid = hitbtcTrade.getId();
long longTradeId = tid == null ? 0 : Long.parseLong(tid);
if (longTradeId > lastTradeId) {
lastTradeId = longTradeId;
}
OrderType orderType = adaptSide(hitbtcTrade.getSide());
Trade trade = new Trade.Builder().type(orderType).originalAmount(amount).currencyPair(currencyPair).price(price).timestamp(timestamp).id(tid).build();
trades.add(trade);
}
return new Trades(trades, lastTradeId, Trades.TradeSortType.SortByTimestamp);
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class HitbtcAdapters method adaptTradeHistory.
public static UserTrades adaptTradeHistory(List<HitbtcOwnTrade> tradeHistoryRaw) {
List<UserTrade> trades = new ArrayList<>(tradeHistoryRaw.size());
for (HitbtcOwnTrade hitbtcOwnTrade : tradeHistoryRaw) {
OrderType type = adaptOrderType(hitbtcOwnTrade.getSide().getValue());
CurrencyPair pair = adaptSymbol(hitbtcOwnTrade.symbol);
BigDecimal originalAmount = hitbtcOwnTrade.getQuantity();
Date timestamp = hitbtcOwnTrade.getTimestamp();
String id = Long.toString(hitbtcOwnTrade.getId());
String orderId = String.valueOf(hitbtcOwnTrade.getOrderId());
String clientOrderId = hitbtcOwnTrade.getClientOrderId();
UserTrade trade = new HitbtcUserTrade(type, originalAmount, pair, hitbtcOwnTrade.getPrice(), timestamp, id, orderId, hitbtcOwnTrade.getFee(), pair.counter, clientOrderId);
trades.add(trade);
}
return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class RippleTradeServiceRaw method getExpectedCounterTransferFee.
/**
* @return transfer fee for the counter leg of the order in the counter currency
*/
public BigDecimal getExpectedCounterTransferFee(final RippleLimitOrder order) throws IOException {
final ITransferFeeSource transferFeeSource = (ITransferFeeSource) exchange.getAccountService();
final String counterparty = order.getCounterCounterparty();
final String currency = order.getCurrencyPair().counter.getCurrencyCode();
final BigDecimal quantity = order.getOriginalAmount().multiply(order.getLimitPrice());
final OrderType type;
if (order.getType() == OrderType.BID) {
type = OrderType.ASK;
} else {
type = OrderType.BID;
}
return getExpectedTransferFee(transferFeeSource, counterparty, currency, quantity, type);
}
Aggregations