/** * Get Market Info * * This is a combined call for {@link #getRate(CoinType, CoinType) getRate()} and * {@link #getLimit(CoinType, CoinType) getLimit()} API calls. */ public ShapeShiftMarketInfo getMarketInfo(String pair) throws ShapeShiftException, IOException { log.info("Market info for pair {}", pair); String apiUrl = getApiUrl(String.format(MARKET_INFO_API, pair)); Request request = new Request.Builder().url(apiUrl).build(); ShapeShiftMarketInfo reply = new ShapeShiftMarketInfo(getMakeApiCall(request)); if (!reply.isError) checkPair(pair, reply.pair); return reply; }
@Test public void testMarketInfo2() throws JSONException, ShapeShiftException { ShapeShiftMarketInfo info = new ShapeShiftMarketInfo(new JSONObject( "{\n" + "pair: \"ppc_btc\",\n" + assertEquals(PPC.value("0.173914"), info.minimum); info = new ShapeShiftMarketInfo(new JSONObject( "{\n" + "pair: \"btc_ppc\",\n" + assertEquals(BTC.value("0.0000198"), info.minimum); info = new ShapeShiftMarketInfo(new JSONObject( "{\n" + "pair: \"btc_nbt\",\n" + assertEquals(BTC.value("0.00008692"), info.minimum); info = new ShapeShiftMarketInfo(new JSONObject( "{\n" + "pair: \"nbt_btc\",\n" +
@Test public void testMarketInfo() throws JSONException, ShapeShiftException { JSONObject json = new JSONObject( "{" + "\"pair\" : \"btc_nbt\"," + "\"rate\" : \"100\"," + "\"minerFee\" : \"0.01\"," + "\"limit\" : \"4\"," + "\"minimum\" : 0.00000104" + "}"); ShapeShiftMarketInfo marketInfo = new ShapeShiftMarketInfo(json); assertNotNull(marketInfo); assertFalse(marketInfo.isError); assertEquals("btc_nbt", marketInfo.pair); assertTrue(marketInfo.isPair("BTC_NBT")); assertTrue(marketInfo.isPair("btc_nbt")); assertTrue(marketInfo.isPair(BTC, NBT)); assertFalse(marketInfo.isPair("doge_ltc")); assertFalse(marketInfo.isPair(DOGE, LTC)); assertNotNull(marketInfo.rate); assertNotNull(marketInfo.limit); assertNotNull(marketInfo.minimum); assertEquals(NBT.value("99.99"), marketInfo.rate.convert(BTC.value("1"))); assertEquals(BTC.value("4"), marketInfo.limit); assertEquals(BTC.value("0.00000104"), marketInfo.minimum); }