Examples of CurrencyPair


Examples of com.xeiam.xchange.currency.CurrencyPair

      OrderType type = t.getSide().equals("buy") ? OrderType.BID : OrderType.ASK;

      String base = t.getSymbol().substring(0, 3);
      String counter = t.getSymbol().substring(3, 6);

      UserTrade trade = new UserTrade(type, t.getExecQuantity().divide(LOT_MULTIPLIER), new CurrencyPair(base, counter), t.getExecPrice(), new Date(t.getTimestamp()), t.getClientOrderId(),
          Long.toString(t.getOriginalOrderId()), t.getFee(), counter);

      trades.add(trade);
    }
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

   *
   * @throws java.lang.IllegalArgumentException if the result were to be less than lot size for given currency pair
   */
  protected static BigInteger getLots(Order order) {

    CurrencyPair pair = order.getCurrencyPair();
    String currency = pair.baseSymbol;
    BigDecimal lotMulti;
    if (Currencies.BTC.equals(currency))
      lotMulti = new BigDecimal("100");
    else if (Currencies.LTC.equals(currency))
      lotMulti = new BigDecimal("10");
    else if (CurrencyPair.EUR_USD.equals(pair))
      lotMulti = BigDecimal.ONE;
    else if (CurrencyPair.DOGE_BTC.equals(pair))
      lotMulti = new BigDecimal(".001");
    else if (new CurrencyPair("XMR", Currencies.BTC).equals(pair))
      lotMulti = new BigDecimal("100");
    else if (new CurrencyPair("BCN", Currencies.BTC).equals(pair))
      lotMulti = new BigDecimal(".01");
    else if (new CurrencyPair("XDN", Currencies.BTC).equals(pair))
      lotMulti = new BigDecimal(".01");
    else
      throw new IllegalArgumentException("Unknown currency pair " + pair);

    BigDecimal lots = order.getTradableAmount().multiply(lotMulti);
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

    long timestamp = 0;
    int limit = 50;

    if (arguments.length >= 1) {
      if (arguments[0] instanceof CurrencyPair) {
        final CurrencyPair pair = (CurrencyPair) arguments[0];
        symbol = pair.baseSymbol + pair.counterSymbol;
      }
      else {
        symbol = (String) arguments[0];
      }
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

    InputStream is = KrakenAdaptersTest.class.getResourceAsStream("/marketdata/example-ticker-data.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    KrakenTickerResult krakenTicker = mapper.readValue(is, KrakenTickerResult.class);
    CurrencyPair currencyPair = CurrencyPair.BTC_EUR;
    String krakenCurencyPair = "XXBTZEUR";
    Ticker ticker = KrakenAdapters.adaptTicker(krakenTicker.getResult().get(krakenCurencyPair), currencyPair);

    // Verify that the example data was unmarshalled correctly
    assertThat(ticker.getAsk()).isEqualTo(new BigDecimal("562.26651"));
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

    // place a limit order
    OrderType orderType = orderTypeString.equalsIgnoreCase("bid") ? OrderType.BID : OrderType.ASK;
    String tradableIdentifier = Currencies.BTC;

    return new LimitOrder(orderType, amount, new CurrencyPair(tradableIdentifier, currency), id, null, price);

  }
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

  public static Collection<CurrencyPair> adaptCurrencyPairs(List<List<String>> tradingPairs) {

    Set<CurrencyPair> currencyPairs = new HashSet<CurrencyPair>();
    for (List<String> tradingPair : tradingPairs) {
      if (tradingPair.size() == 2) {
        CurrencyPair currencyPair = new CurrencyPair(tradingPair.get(1), tradingPair.get(0));
        currencyPairs.add(currencyPair);
      }
    }
    return currencyPairs;
  }
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>();

    for (CexIOOrder cexIOOrder : cexIOOrderList) {
      Order.OrderType orderType = cexIOOrder.getType() == CexIOOrder.Type.buy ? Order.OrderType.BID : Order.OrderType.ASK;
      String id = Long.toString(cexIOOrder.getId());
      limitOrders.add(new LimitOrder(orderType, cexIOOrder.getPending(), new CurrencyPair(cexIOOrder.getTradableIdentifier(), cexIOOrder.getTransactionCurrency()), id, DateUtils
          .fromMillisUtc(cexIOOrder.getTime()), cexIOOrder.getPrice()));
    }

    return new OpenOrders(limitOrders);
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

  public static CurrencyPair adaptCurrencyPair(String bitfinexSymbol) {

    String tradableIdentifier = bitfinexSymbol.substring(0, 3).toUpperCase();
    String transactionCurrency = bitfinexSymbol.substring(3).toUpperCase();
    return new CurrencyPair(tradableIdentifier, transactionCurrency);
  }
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>(activeOrders.length);

    for (BitfinexOrderStatusResponse order : activeOrders) {
      OrderType orderType = order.getSide().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK;
      CurrencyPair currencyPair = adaptCurrencyPair(order.getSymbol());
      Date timestamp = convertBigDecimalTimestampToDate(order.getTimestamp());
      limitOrders.add(new LimitOrder(orderType, order.getRemainingAmount(), currencyPair, String.valueOf(order.getId()), timestamp, order.getPrice()));
    }

    return new OpenOrders(limitOrders);
View Full Code Here

Examples of com.xeiam.xchange.currency.CurrencyPair

  }

  public static UserTrades adaptTradeHistory(BitfinexTradeResponse[] trades, String symbol) {

    List<UserTrade> pastTrades = new ArrayList<UserTrade>(trades.length);
    CurrencyPair currencyPair = adaptCurrencyPair(symbol);

    for (BitfinexTradeResponse trade : trades) {
      OrderType orderType = trade.getType().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK;
      Date timestamp = convertBigDecimalTimestampToDate(trade.getTimestamp());
      pastTrades.add(new UserTrade(orderType, trade.getAmount(), currencyPair, trade.getPrice(), timestamp, trade.getTradeId(), trade.getOrderId(), trade.getFeeAmount(), trade.getFeeCurrency()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.