Package com.xeiam.xchange.dto.marketdata

Examples of com.xeiam.xchange.dto.marketdata.Ticker$Builder


    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CryptonitTicker cryptonitTicker = mapper.readValue(is, CryptonitTicker.class);

    Ticker ticker = CryptonitAdapters.adaptTicker(cryptonitTicker, CurrencyPair.BTC_USD);

    assertThat(ticker.getLast().toString()).isEqualTo("605.997");
    assertThat(ticker.getLow().toString()).isEqualTo("572.73768613");
    assertThat(ticker.getHigh().toString()).isEqualTo("610.00000000");
    assertThat(ticker.getVolume()).isEqualTo(new BigDecimal("8.28600851"));

    assertThat(ticker.getCurrencyPair().baseSymbol).isEqualTo("BTC");

  }
View Full Code Here


    final JavaType tickersType = mapper.getTypeFactory().constructParametricType(MintPalBaseResponse.class, mapper.getTypeFactory().constructCollectionType(List.class, MintPalTicker.class));
    final MintPalBaseResponse<List<MintPalTicker>> tickers = mapper.readValue(is, tickersType);

    final List<MintPalTicker> tickerList = tickers.getData();
    final MintPalTicker ticker = tickerList.get(0);
    final Ticker adaptedTicker = MintPalAdapters.adaptTicker(ticker);

    assertThat(adaptedTicker.getCurrencyPair()).isEqualTo(new CurrencyPair("365", "BTC"));
    assertThat(adaptedTicker.getLast()).isEqualTo("0.20000000");
    assertThat(adaptedTicker.getHigh()).isEqualTo("0.26500000");
    assertThat(adaptedTicker.getLow()).isEqualTo("0.20000000");
    assertThat(adaptedTicker.getVolume()).isEqualTo("2.265");
    assertThat(adaptedTicker.getBid()).isEqualTo("0.20000000");
    assertThat(adaptedTicker.getAsk()).isEqualTo("0.22900000");
  }
View Full Code Here

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CryptsyGetMarketsReturn cryptsyTrades = mapper.readValue(is, CryptsyGetMarketsReturn.class);

    Ticker adaptedTicker = CryptsyAdapters.adaptTicker(cryptsyTrades, CurrencyPair.WDC_BTC);

    assertEquals(adaptedTicker.getCurrencyPair(), CurrencyPair.WDC_BTC);
    assertEquals(adaptedTicker.getLast(), new BigDecimal("0.00006187"));
    assertEquals(adaptedTicker.getLow(), new BigDecimal("0.00006040"));
    assertEquals(adaptedTicker.getHigh(), new BigDecimal("0.00006335"));
    assertEquals(adaptedTicker.getVolume(), new BigDecimal("61283.49173059"));
  }
View Full Code Here

    Map<Integer, CryptsyPublicMarketData> cryptsyMarketData = CryptsyAdapters.adaptPublicMarketDataMap(mapper.readValue(is, CryptsyPublicMarketDataReturn.class).getReturnValue());

    List<Ticker> adaptedTickerList = CryptsyAdapters.adaptPublicTickers(cryptsyMarketData);
    assertThat(adaptedTickerList).hasSize(1);

    Ticker adaptedTicker = adaptedTickerList.get(0);
    assertEquals(adaptedTicker.getCurrencyPair(), CurrencyPair.DOGE_LTC);
    assertEquals(adaptedTicker.getLast(), new BigDecimal("0.00003495"));
    assertEquals(adaptedTicker.getBid(), new BigDecimal("00.00003485"));
    assertEquals(adaptedTicker.getAsk(), new BigDecimal("0.00003495"));
    assertThat(adaptedTicker.getLow()).isNull();
    assertThat(adaptedTicker.getHigh()).isNull();
    assertEquals(adaptedTicker.getVolume(), new BigDecimal("13154836.13271418"));
  }
View Full Code Here

  }

  @Test
  public void testAdaptTicker() throws IOException {

    Ticker expectedTicker =
        new Ticker.Builder().currencyPair(CurrencyPair.BTC_USD).ask(new BigDecimal("723.09")).bid(new BigDecimal("723.09")).last(new BigDecimal("719.79")).low(
                new BigDecimal("718.2")).high(new BigDecimal("723.11")).build();

    InputStream is = CoinbaseAdapterTest.class.getResourceAsStream("/marketdata/example-price-data.json");
    ObjectMapper mapper = new ObjectMapper();
    CoinbasePrice price = mapper.readValue(is, CoinbasePrice.class);

    CoinbaseMoney spotPrice = new CoinbaseMoney(Currencies.USD, new BigDecimal("719.79"));

    is = CoinbaseAdapterTest.class.getResourceAsStream("/marketdata/example-spot-rate-history-data.json");
    String spotPriceHistoryString;
    Scanner scanner = null;
    try {
      scanner = new Scanner(is);
      spotPriceHistoryString = scanner.useDelimiter("\\A").next();
    } finally {
      scanner.close();
    }

    CoinbaseSpotPriceHistory spotPriceHistory = CoinbaseSpotPriceHistory.fromRawString(spotPriceHistoryString);

    Ticker ticker = CoinbaseAdapters.adaptTicker(CurrencyPair.BTC_USD, price, price, spotPrice, spotPriceHistory);

    assertThat(ticker).isEqualsToByComparingFields(expectedTicker);
  }
View Full Code Here

    Map<Integer, CryptsyPublicMarketData> cryptsyMarketData = CryptsyAdapters.adaptPublicMarketDataMap(mapper.readValue(is, CryptsyPublicMarketDataReturn.class).getReturnValue());

    List<Ticker> adaptedTickerList = CryptsyAdapters.adaptPublicTickers(cryptsyMarketData);
    assertThat(adaptedTickerList).hasSize(1);

    Ticker adaptedTicker = adaptedTickerList.get(0);
    assertEquals(adaptedTicker.getCurrencyPair(), CurrencyPair.FTC_USD);
    assertThat(adaptedTicker.getLast()).isNull();
    assertThat(adaptedTicker.getBid()).isNull();
    assertEquals(adaptedTicker.getAsk(), new BigDecimal("0.98000000"));
    assertThat(adaptedTicker.getLow()).isNull();
    assertThat(adaptedTicker.getHigh()).isNull();
    assertEquals(adaptedTicker.getVolume(), new BigDecimal("0E-8"));
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.marketdata.Ticker$Builder

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.