private void effectiveSpreadRequestSample() { final List<EffectiveSpread> effectiveSpreads = iexTradingClient.executeRequest(new EffectiveSpreadRequestBuilder() .withSymbol("AAPL") .build()); System.out.println(effectiveSpreads); }
@Override public RestRequest<List<EffectiveSpread>> build() { return RestRequestBuilder.<List<EffectiveSpread>>builder() .withPath("/stock/{symbol}/effective-spread") .addPathParam("symbol", getSymbol()).get() .withResponse(new GenericType<List<EffectiveSpread>>() {}) .build(); }
@Test public void effectiveSpreadAcceptanceTest() { final List<EffectiveSpread> effectiveSpreads = iexTradingClient.executeRequest(new EffectiveSpreadRequestBuilder() .withSymbol("AAPL") .build()); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<List<EffectiveSpread>> request = new EffectiveSpreadRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/effective-spread"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<EffectiveSpread>>() {}); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
@Test public void effectiveSpreadServiceTest() { stubFor(get(urlEqualTo("/stock/aapl/effective-spread")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/EffectiveSpreadResponse.json"))); final List<EffectiveSpread> effectiveSpreadList = iexTradingClient.executeRequest(new EffectiveSpreadRequestBuilder() .withSymbol("aapl") .build()); final EffectiveSpread effectiveSpread = effectiveSpreadList.get(0); assertThat(effectiveSpread.getVolume()).isEqualTo(BigDecimal.valueOf(12678354)); assertThat(effectiveSpread.getVenue()).isEqualTo("XBOS"); assertThat(effectiveSpread.getVenueName()).isEqualTo("NASDAQ BX"); assertThat(effectiveSpread.getEffectiveSpread()).isEqualTo(BigDecimal.valueOf(0.015299340000000002)); assertThat(effectiveSpread.getEffectiveQuoted()).isEqualTo(BigDecimal.valueOf(0.9280835)); assertThat(effectiveSpread.getPriceImprovement()).isEqualTo(BigDecimal.valueOf(0.0009107087)); }