Search in sources :

Example 6 with OrderType

use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.

the class KrakenLimitOrderDemo method generic.

private static void generic(Exchange krakenExchange) throws IOException {
    TradeService tradeService = 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);
    String orderID = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order ID: " + orderID);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) TradeService(org.knowm.xchange.service.trade.TradeService) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal)

Example 7 with OrderType

use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.

the class LgoAdapters method adaptUserTrade.

private static UserTrade adaptUserTrade(LgoUserTrade lgoUserTrade) {
    OrderType type = adaptUserTradeType(lgoUserTrade);
    CurrencyPair currencyPair = adaptProductId(lgoUserTrade.getProductId());
    Date creationDate = lgoUserTrade.getCreationDate();
    return new UserTrade.Builder().type(type).originalAmount(lgoUserTrade.getQuantity()).currencyPair(currencyPair).price(lgoUserTrade.getPrice()).timestamp(creationDate).id(lgoUserTrade.getId()).orderId(lgoUserTrade.getOrderId()).feeAmount(lgoUserTrade.getFees()).feeCurrency(currencyPair.counter).build();
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 8 with OrderType

use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.

the class BitbayAdapters method createUserTrade.

private static UserTrade createUserTrade(BitbayOrder bitbayOrder) {
    CurrencyPair currencyPair = new CurrencyPair(bitbayOrder.getCurrency(), bitbayOrder.getPaymentCurrency());
    OrderType type = "ask".equals(bitbayOrder.getType()) ? OrderType.ASK : OrderType.BID;
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date;
    try {
        date = formatter.parse(bitbayOrder.getDate());
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
    return new UserTrade.Builder().type(type).originalAmount(bitbayOrder.getAmount()).currencyPair(currencyPair).price(bitbayOrder.getCurrentPrice().divide(bitbayOrder.getStartAmount())).timestamp(date).id(String.valueOf(bitbayOrder.getId())).orderId(String.valueOf(bitbayOrder.getId())).build();
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 9 with OrderType

use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.

the class CCEXAdapters method adaptOpenOrder.

public static LimitOrder adaptOpenOrder(CCEXOpenorder cCEXOpenOrder) {
    OrderType type = cCEXOpenOrder.getOrderType().equalsIgnoreCase("LIMIT_SELL") ? OrderType.ASK : OrderType.BID;
    String[] currencies = cCEXOpenOrder.getExchange().split("-");
    CurrencyPair pair = new CurrencyPair(currencies[1], currencies[0]);
    return new LimitOrder(type, cCEXOpenOrder.getQuantityRemaining(), pair, cCEXOpenOrder.getOrderUuid(), null, cCEXOpenOrder.getLimit());
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 10 with OrderType

use of org.knowm.xchange.dto.Order.OrderType in project XChange by knowm.

the class CCEXAdapters method adaptCCEXPublicTrade.

public static Trade adaptCCEXPublicTrade(CCEXTrade cCEXTrade, CurrencyPair currencyPair) {
    OrderType type = cCEXTrade.getOrderType().equalsIgnoreCase("BUY") ? OrderType.BID : OrderType.ASK;
    Date timestamp = stringToDate(cCEXTrade.getTimestamp());
    return new Trade.Builder().type(type).originalAmount(cCEXTrade.getQuantity()).currencyPair(currencyPair).price(cCEXTrade.getPrice()).timestamp(timestamp).id(cCEXTrade.getId()).build();
}
Also used : CCEXTrade(org.knowm.xchange.ccex.dto.marketdata.CCEXTrade) UserTrade(org.knowm.xchange.dto.trade.UserTrade) Trade(org.knowm.xchange.dto.marketdata.Trade) OrderType(org.knowm.xchange.dto.Order.OrderType) Date(java.util.Date)

Aggregations

OrderType (org.knowm.xchange.dto.Order.OrderType)104 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)68 Date (java.util.Date)65 BigDecimal (java.math.BigDecimal)64 UserTrade (org.knowm.xchange.dto.trade.UserTrade)38 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)36 ArrayList (java.util.ArrayList)35 Trade (org.knowm.xchange.dto.marketdata.Trade)25 UserTrades (org.knowm.xchange.dto.trade.UserTrades)19 Order (org.knowm.xchange.dto.Order)15 Currency (org.knowm.xchange.currency.Currency)12 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)12 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)11 Test (org.junit.Test)10 Trades (org.knowm.xchange.dto.marketdata.Trades)10 OrderStatus (org.knowm.xchange.dto.Order.OrderStatus)9 List (java.util.List)6 BitfinexOrderType (org.knowm.xchange.bitfinex.v1.BitfinexOrderType)5 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)5 StopOrder (org.knowm.xchange.dto.trade.StopOrder)5