Package com.xeiam.xchange.bitfinex.v1.dto.marketdata

Examples of com.xeiam.xchange.bitfinex.v1.dto.marketdata.BitfinexLevel


  }

  public BitfinexOfferStatusResponse getBitfinexOfferStatusResponse(String offerId) throws IOException {

    try {
      BitfinexOfferStatusResponse offerStatus = bitfinex.offerStatus(apiKey, payloadCreator, signatureCreator, new BitfinexOfferStatusRequest(String.valueOf(nextNonce()), Integer.valueOf(offerId)));
      return offerStatus;
    } catch (BitfinexException e) {
      throw new ExchangeException(e.getMessage());
    }
  }
View Full Code Here


  private static void raw(Exchange bfx) throws IOException {

    BitfinexTradeServiceRaw tradeService = (BitfinexTradeServiceRaw) bfx.getPollingTradeService();

    BitfinexOfferStatusResponse fixedRateResponse =
        tradeService.placeBitfinexFixedRateLoanOrder(new FixedRateLoanOrder(OrderType.BID, "USD", new BigDecimal("0.01"), 2, "", null, new BigDecimal("0.01")), BitfinexOrderType.LIMIT);
    System.out.println("Fixed rate order response: " + fixedRateResponse);

    BitfinexOfferStatusResponse floatingRateResponse =
        tradeService.placeBitfinexFloatingRateLoanOrder(new FloatingRateLoanOrder(OrderType.BID, "USD", new BigDecimal("0.01"), 2, "", null, BigDecimal.ZERO), BitfinexOrderType.MARKET);
    System.out.println("Floating rate order response: " + floatingRateResponse);

    BitfinexCreditResponse[] activeCredits = tradeService.getBitfinexActiveCredits();
    System.out.println("Active credits: " + Arrays.toString(activeCredits));

    BitfinexOfferStatusResponse[] openOffers = tradeService.getBitfinexOpenOffers();
    System.out.println("Open offers response: " + Arrays.toString(openOffers));

    for (BitfinexOfferStatusResponse offer : openOffers) {
      BitfinexOfferStatusResponse cancelResponse = tradeService.cancelBitfinexOffer(Integer.toString(offer.getId()));
      System.out.println("Cancel offer response: " + cancelResponse);
    }
  }
View Full Code Here

  }

  public BitfinexOrderStatusResponse getBitfinexOrderStatus(String orderId) throws IOException {

    try {
      BitfinexOrderStatusResponse orderStatus = bitfinex.orderStatus(apiKey, payloadCreator, signatureCreator, new BitfinexOrderStatusRequest(String.valueOf(nextNonce()), Integer.valueOf(orderId)));
      return orderStatus;
    } catch (BitfinexException e) {
      throw new ExchangeException(e.getMessage());
    }
View Full Code Here

  @Ignore
  @Test
  public void testPlaceOrder() throws IOException {

    InputStream resourceAsStream = BitfinexTradeDataJSONTest.class.getResourceAsStream("/v1/trade/example-place-order-data.json");
    BitfinexOrderStatusResponse response = new ObjectMapper().readValue(resourceAsStream, BitfinexOrderStatusResponse.class);

    assertEquals(4003264, response.getId());
    assertEquals("btcusd", response.getSymbol());
    assertEquals("bitfinex", response.getExchange());
    assertEquals(new BigDecimal("900.0"), response.getPrice());
    assertEquals(new BigDecimal("0.0"), response.getAvgExecutionPrice());
    assertEquals("sell", response.getSide());
    assertEquals("exchange limit", response.getType());
    assertEquals(new BigDecimal("1387061558.610016778"), response.getTimestamp());
    assertTrue(response.isLive());
    assertFalse(response.isCancelled());
    assertFalse(response.getWasForced());
    assertEquals(new BigDecimal("0.01"), response.getOriginalAmount());
    assertEquals(new BigDecimal("0.01"), response.getRemainingAmount());
    assertEquals(new BigDecimal("0.0"), response.getExecutedAmount());
  }
View Full Code Here

  @Test
  public void testCancelOrder() throws IOException {

    InputStream resourceAsStream = BitfinexTradeDataJSONTest.class.getResourceAsStream("/v1/trade/example-cancel-order-data.json");
    BitfinexOrderStatusResponse response = new ObjectMapper().readValue(resourceAsStream, BitfinexOrderStatusResponse.class);

    assertEquals(4003242, response.getId());
    assertEquals("btcusd", response.getSymbol());
    assertNull(response.getExchange());
    assertEquals(new BigDecimal("900.0"), response.getPrice());
    assertEquals(new BigDecimal("0.0"), response.getAvgExecutionPrice());
    assertEquals("sell", response.getSide());
    assertEquals("exchange limit", response.getType());
    assertEquals(new BigDecimal("1387061342.0"), response.getTimestamp());
    assertFalse(response.isLive());
    assertTrue(response.isCancelled());
    assertFalse(response.getWasForced());
    assertEquals(new BigDecimal("0.01"), response.getOriginalAmount());
    assertEquals(new BigDecimal("0.01"), response.getRemainingAmount());
    assertEquals(new BigDecimal("0.0"), response.getExecutedAmount());
  }
View Full Code Here

  @Test
  public void testOpenOrders() throws IOException {

    InputStream resourceAsStream = BitfinexTradeDataJSONTest.class.getResourceAsStream("/v1/trade/example-open-orders-data.json");
    BitfinexOrderStatusResponse response = new ObjectMapper().readValue(resourceAsStream, BitfinexOrderStatusResponse.class);

    assertEquals(4003242, response.getId());
    assertEquals("btcusd", response.getSymbol());
    assertNull(response.getExchange());
    assertEquals(new BigDecimal("900.0"), response.getPrice());
    assertEquals(new BigDecimal("0.0"), response.getAvgExecutionPrice());
    assertEquals("sell", response.getSide());
    assertEquals("exchange limit", response.getType());
    assertEquals(new BigDecimal("1387061342.0"), response.getTimestamp());
    assertTrue(response.isLive());
    assertFalse(response.isCancelled());
    assertFalse(response.getWasForced());
    assertEquals(new BigDecimal("0.08"), response.getOriginalAmount());
    assertEquals(new BigDecimal("0.06"), response.getRemainingAmount());
    assertEquals(new BigDecimal("0.02"), response.getExecutedAmount());
  }
View Full Code Here

    String pair = BitfinexUtils.toPairString(marketOrder.getCurrencyPair());
    String type = marketOrder.getType().equals(Order.OrderType.BID) ? "buy" : "sell";
    String orderType = bitfinexOrderType.toString();

    try {
      BitfinexOrderStatusResponse newOrder =
          bitfinex.newOrder(apiKey, payloadCreator, signatureCreator, new BitfinexNewOrderRequest(String.valueOf(nextNonce()), pair, marketOrder.getTradableAmount(), BigDecimal.ONE, "bitfinex", type,
              orderType));
      return newOrder;
    } catch (BitfinexException e) {
      throw new ExchangeException(e.getMessage());
View Full Code Here

    else {
      request = new BitfinexNewOrderRequest(String.valueOf(nextNonce()), pair, limitOrder.getTradableAmount(), limitOrder.getLimitPrice(), "bitfinex", type, orderType);
    }

    try {
      BitfinexOrderStatusResponse newOrder = bitfinex.newOrder(apiKey, payloadCreator, signatureCreator, request);
      return newOrder;
    } catch (BitfinexException e) {
      throw new ExchangeException(e.getMessage());
    }
  }
View Full Code Here

  }

  public BitfinexOrderStatusResponse getBitfinexOrderStatus(String orderId) throws IOException {

    try {
      BitfinexOrderStatusResponse orderStatus = bitfinex.orderStatus(apiKey, payloadCreator, signatureCreator, new BitfinexOrderStatusRequest(String.valueOf(nextNonce()), Integer.valueOf(orderId)));
      return orderStatus;
    } catch (BitfinexException e) {
      throw new ExchangeException(e.getMessage());
    }
View Full Code Here

  }

  @Override
  public String placeMarketOrder(MarketOrder marketOrder) throws IOException {

    BitfinexOrderStatusResponse newOrder = placeBitfinexMarketOrder(marketOrder, BitfinexOrderType.MARKET);

    return String.valueOf(newOrder.getId());
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.bitfinex.v1.dto.marketdata.BitfinexLevel

Copyright © 2018 www.massapicom. 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.