@Override public String placeLimitOrder(LimitOrder limitOrder) throws IOException { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("side", limitOrder.getType().toString()); parameters.put("orderType", "LMT"); parameters.put("symbol", limitOrder.getCurrencyPair().toString()); parameters.put("priceLimit", limitOrder.getLimitPrice().toString()); parameters.put("amount", "0"); parameters.put("quantity", limitOrder.getOriginalAmount().toString()); CoinsuperResponse<CoinsuperOrder> coinsuperCreateOrder = createOrder(parameters); if (coinsuperCreateOrder.getCode() == 1000) { return coinsuperCreateOrder.getData().getResult().getOrderNo(); } else { return "false"; } }
@Override public int hashCode() { int hash = 7; hash = 83 * hash + (this.type != null ? this.type.hashCode() : 0); hash = 83 * hash + (this.originalAmount != null ? this.originalAmount.hashCode() : 0); hash = 83 * hash + (this.currencyPair != null ? this.currencyPair.hashCode() : 0); hash = 83 * hash + (this.id != null ? this.id.hashCode() : 0); hash = 83 * hash + (this.timestamp != null ? this.timestamp.hashCode() : 0); return hash; }
String pair = BitfinexUtils.toPairString(limitOrder.getCurrencyPair()); String type = (limitOrder.getType().equals(OrderType.BID) || limitOrder.getType().equals(OrderType.EXIT_ASK)) ? "buy" : "sell"; String pair = BitfinexUtils.toPairString(marketOrder.getCurrencyPair()); String type = (marketOrder.getType().equals(OrderType.BID) || marketOrder.getType().equals(OrderType.EXIT_ASK)) ? "buy" : "sell";
String type = limitOrder.getType().equals(Order.OrderType.BID) ? "buy" : "sell"; String orderType = GeminiOrderType.toString();
@Override public String placeStopOrder(StopOrder so) throws IOException { TimeInForce tif = null; Set<IOrderFlags> orderFlags = so.getOrderFlags(); Iterator<IOrderFlags> orderFlagsIterator = orderFlags.iterator(); while (orderFlagsIterator.hasNext()) { IOrderFlags orderFlag = orderFlagsIterator.next(); if (orderFlag instanceof TimeInForce) { tif = (TimeInForce) orderFlag; } } // Time-in-force should not be provided for market orders but is required for // limit orders, so we only default it for limit orders. If the caller // specifies one for a market order, we don't remove it, since Binance might allow // it at some point. if (so.getLimitPrice() != null && tif == null) { tif = TimeInForce.GTC; } OrderType orderType; if (so.getType().equals(Order.OrderType.BID)) { orderType = so.getLimitPrice() == null ? OrderType.TAKE_PROFIT : OrderType.TAKE_PROFIT_LIMIT; } else { orderType = so.getLimitPrice() == null ? OrderType.STOP_LOSS : OrderType.STOP_LOSS_LIMIT; } return placeOrder(orderType, so, so.getLimitPrice(), so.getStopPrice(), tif); }
public BitfinexOrderStatusResponse placeBitfinexMarketOrder( MarketOrder marketOrder, BitfinexOrderType bitfinexOrderType) throws IOException { String pair = BitfinexUtils.toPairString(marketOrder.getCurrencyPair()); String type = (marketOrder.getType().equals(OrderType.BID) || marketOrder.getType().equals(OrderType.EXIT_ASK)) ? "buy" : "sell"; String orderType = bitfinexOrderType.toString(); BitfinexOrderStatusResponse newOrder = bitfinex.newOrder( apiKey, payloadCreator, signatureCreator, new BitfinexNewOrderRequest( String.valueOf(exchange.getNonceFactory().createValue()), pair, marketOrder.getOriginalAmount(), BigDecimal.ONE, "bitfinex", type, orderType, null)); return newOrder; }
/** * @deprecated Endpoint still valid, but Bittrex have disabled market orders. See * https://twitter.com/bittrexexchange/status/526590250487783425. */ @Deprecated public String placeBittrexMarketOrder(MarketOrder marketOrder) throws IOException { return (OrderType.BID.equals(marketOrder.getType()) ? bittrexAuthenticated.buymarket( apiKey, signatureCreator, exchange.getNonceFactory(), BittrexUtils.toPairString(marketOrder.getCurrencyPair()), marketOrder.getOriginalAmount().toPlainString()) : bittrexAuthenticated.sellmarket( apiKey, signatureCreator, exchange.getNonceFactory(), BittrexUtils.toPairString(marketOrder.getCurrencyPair()), marketOrder.getOriginalAmount().toPlainString())) .getResult() .getUuid(); }
@Override public String placeLimitOrder(LimitOrder limitOrder) throws IOException { CoinmateTradeResponse response; if (limitOrder.getType().equals(Order.OrderType.ASK)) { response = sellCoinmateLimit( limitOrder.getOriginalAmount(), limitOrder.getLimitPrice(), CoinmateUtils.getPair(limitOrder.getCurrencyPair())); } else if (limitOrder.getType().equals(Order.OrderType.BID)) { response = buyCoinmateLimit( limitOrder.getOriginalAmount(), limitOrder.getLimitPrice(), CoinmateUtils.getPair(limitOrder.getCurrencyPair())); } else { throw new CoinmateException("Unknown order type"); } return Long.toString(response.getData()); }
@Override public String placeMarketOrder(MarketOrder marketOrder) throws IOException { CoinmateTradeResponse response; if (marketOrder.getType().equals(Order.OrderType.ASK)) { response = sellCoinmateInstant( marketOrder.getOriginalAmount(), CoinmateUtils.getPair(marketOrder.getCurrencyPair())); } else if (marketOrder.getType().equals(Order.OrderType.BID)) { response = buyCoinmateInstant( marketOrder.getOriginalAmount(), CoinmateUtils.getPair(marketOrder.getCurrencyPair())); } else { throw new CoinmateException("Unknown order type"); } return Long.toString(response.getData()); }
@Override public String placeMarketOrder(MarketOrder marketOrder) throws IOException { String marketOrderType = null; String price = null; String amount = null; long orderId = -1L; String symbol = OkCoinAdapters.adaptSymbol(marketOrder.getCurrencyPair()); if (marketOrder.getType().equals(OrderType.BID)) { marketOrderType = "buy_market"; price = marketOrder.getOriginalAmount().toPlainString(); orderId = placeMarketOrderBuy(symbol, marketOrderType, price).getOrderId(); } else { marketOrderType = "sell_market"; amount = marketOrder.getOriginalAmount().toPlainString(); orderId = placeMarketOrderSell(symbol, marketOrderType, amount).getOrderId(); } return String.valueOf(orderId); }
public String placeBittrexLimitOrder(LimitOrder limitOrder) throws IOException { return (OrderType.BID.equals(limitOrder.getType()) ? bittrexAuthenticated.buylimit( apiKey, signatureCreator, exchange.getNonceFactory(), BittrexUtils.toPairString(limitOrder.getCurrencyPair()), limitOrder.getOriginalAmount().toPlainString(), limitOrder.getLimitPrice().toPlainString()) : bittrexAuthenticated.selllimit( apiKey, signatureCreator, exchange.getNonceFactory(), BittrexUtils.toPairString(limitOrder.getCurrencyPair()), limitOrder.getOriginalAmount().toPlainString(), limitOrder.getLimitPrice().toPlainString())) .getResult() .getUuid(); }
@Override public String placeLimitOrder(LimitOrder order) throws IOException, BitstampException { BitstampAuthenticatedV2.Side side = order.getType().equals(BID) ? BitstampAuthenticatedV2.Side.buy : BitstampAuthenticatedV2.Side.sell; BitstampOrder bitstampOrder = placeBitstampOrder( order.getCurrencyPair(), side, order.getOriginalAmount(), order.getLimitPrice()); if (bitstampOrder.getErrorMessage() != null) { throw new ExchangeException(bitstampOrder.getErrorMessage()); } return Long.toString(bitstampOrder.getId()); }
@Override public String placeMarketOrder(MarketOrder order) throws IOException, BitstampException { BitstampAuthenticatedV2.Side side = order.getType().equals(BID) ? BitstampAuthenticatedV2.Side.buy : BitstampAuthenticatedV2.Side.sell; BitstampOrder bitstampOrder = placeBitstampMarketOrder(order.getCurrencyPair(), side, order.getOriginalAmount()); if (bitstampOrder.getErrorMessage() != null) { throw new ExchangeException(bitstampOrder.getErrorMessage()); } return Long.toString(bitstampOrder.getId()); }
@Override public String placeMarketOrder(MarketOrder marketOrder) throws ExchangeException, IOException { final CoinbaseTransfer transfer = marketOrder.getType().equals(OrderType.BID) ? super.buy(marketOrder.getOriginalAmount()) : super.sell(marketOrder.getOriginalAmount()); return transfer.getId(); }
@Override public int hashCode() { int hash = 7; hash = 83 * hash + (this.type != null ? this.type.hashCode() : 0); hash = 83 * hash + (this.originalAmount != null ? this.originalAmount.hashCode() : 0); hash = 83 * hash + (this.currencyPair != null ? this.currencyPair.hashCode() : 0); hash = 83 * hash + (this.id != null ? this.id.hashCode() : 0); hash = 83 * hash + (this.timestamp != null ? this.timestamp.hashCode() : 0); return hash; }
protected Fill createFill(org.knowm.xchange.dto.trade.UserTrade exchangeTrade, SpecificOrder order) { Fill fill = null; if (exchangeTrade.getOriginalAmount().compareTo(BigDecimal.ZERO) != 0) { long volume = exchangeTrade.getType().equals(OrderType.ASK) ? DiscreteAmount.roundedCountForBasis(exchangeTrade.getOriginalAmount(), order.getMarket().getVolumeBasis()) * -1 : DiscreteAmount.roundedCountForBasis(exchangeTrade.getOriginalAmount(), order.getMarket().getVolumeBasis()); fill = fillFactory.create(order, context.getTime(), context.getTime(), order.getMarket(), DiscreteAmount.roundedCountForBasis(exchangeTrade.getPrice(), order.getMarket().getPriceBasis()), volume, exchangeTrade.getId()); // this.priceCount = DiscreteAmount.roundedCountForBasis(fillPrice, market.getPriceBasis()); } return fill; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((currency == null) ? 0 : currency.hashCode()); result = prime * result + dayPeriod; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode()); result = prime * result + ((originalAmount == null) ? 0 : originalAmount.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; }