use of org.knowm.xchange.dto.Order.OrderType 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.dto.Order.OrderType in project XChange by knowm.
the class CoingiAdapters method adaptTrade.
/**
* Adapts a Transaction to a Trade Object
*
* @param tx The Coingi transaction
* @param currencyPair (e.g. BTC/USD)
* @param timeScale polled order books provide a timestamp in seconds, stream in ms
* @return The XChange Trade
*/
public static Trade adaptTrade(CoingiUserTransaction tx, CurrencyPair currencyPair, int timeScale) {
OrderType orderType = tx.getType() == 0 ? OrderType.BID : OrderType.ASK;
final String tradeId = tx.getId();
Date date = DateUtils.fromMillisUtc(tx.getTimestamp() * // polled order books provide a timestamp in seconds, stream in ms
timeScale);
return new Trade.Builder().type(orderType).originalAmount(tx.getBaseAmount()).currencyPair(currencyPair).price(tx.getPrice()).timestamp(date).id(tradeId).build();
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class CoingiAdapters method adaptTrade.
public static Trade adaptTrade(org.knowm.xchange.coingi.dto.marketdata.CoingiTransaction tx, CurrencyPair currencyPair, int timeScale) {
OrderType orderType = tx.getType() == 0 ? OrderType.BID : OrderType.ASK;
final String tradeId = tx.getId();
Date date = new Date(tx.getTimestamp());
return new Trade.Builder().type(orderType).originalAmount(tx.getAmount()).currencyPair(currencyPair).price(tx.getPrice()).timestamp(date).id(tradeId).build();
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class CoingiAdapters method adaptTradeHistory.
public static UserTrades adaptTradeHistory(CoingiOrdersList ordersList) {
List<UserTrade> trades = new ArrayList<>();
for (CoingiOrder o : ordersList.getList()) {
final OrderType orderType = o.getType() == 0 ? OrderType.BID : OrderType.ASK;
final CurrencyPair pair = new CurrencyPair(o.getCurrencyPair().get("base").toUpperCase(), o.getCurrencyPair().get("counter").toUpperCase());
UserTrade trade = new UserTrade.Builder().type(orderType).originalAmount(o.getOriginalBaseAmount()).currencyPair(pair).price(o.getPrice()).timestamp(new Date(o.getTimestamp())).id(o.getId()).orderId(o.getId()).feeAmount(BigDecimal.ZERO).build();
trades.add(trade);
}
return new UserTrades(trades, TradeSortType.SortByID);
}
use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.
the class KrakenLimitOrderDemo method raw.
private static void raw(Exchange krakenExchange) throws IOException {
KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
OrderType orderType = (OrderType.ASK);
BigDecimal tradeableAmount = new BigDecimal("0.01");
BigDecimal price = new BigDecimal("65.25");
LimitOrder limitOrder = new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_LTC, "", null, price);
KrakenOrderResponse orderResponse = tradeService.placeKrakenLimitOrder(limitOrder);
System.out.println("Limit Order response: " + orderResponse);
}
Aggregations