private void chartRequestSample() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .build()); System.out.println(chartList); }
@Test public void shouldSuccessfullyCreateRequestWithDate() { final String symbol = "IBM"; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withDate(LocalDate.of(2017, 5, 5)) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart/date/{date}"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly( entry("date", "20170505"), entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
.withBodyFile("rest/stock/ChartDateResponse.json"))); final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withDate(LocalDate.of(2018, 1, 29)) .withSymbol("aapl") .build());
@Test public void chartWithLastAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .withChartLast(4) .build()); }
@Test public void chartWithIntervalAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .withChartInterval(4) .build()); }
@Test public void chartWithChangeFromCloseAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .withChangeFromClose() .build()); }
@Test public void chartWithResetAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .withChartReset() .build()); }
@Test public void chartWithSimplifyAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .withChartSimplify() .build()); }
@Test public void oneMonthChartRequestAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("AAPL") .build()); }
@Test public void oneDayChartRequestAcceptanceTest() { final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_DAY) .withSymbol("AAPL") .build()); }
@Test public void shouldSuccessfullyCreateRequestWithChartReset() { final String symbol = "IBM"; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChartReset() .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).containsExactly(entry("chartReset", "true")); }
@Test public void shouldSuccessfullyCreateRequestWithChartInterval() { final String symbol = "IBM"; final Integer chartInterval = 5; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChartInterval(chartInterval) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).containsExactly(entry("chartInterval", String.valueOf(chartInterval))); }
@Test public void shouldSuccessfullyCreateRequestWithChartSimplify() { final String symbol = "IBM"; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChartSimplify() .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).containsExactly(entry("chartSimplify", "true")); }
@Test public void shouldSuccessfullyCreateRequestWithChangeFromClose() { final String symbol = "IBM"; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChangeFromClose() .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).containsExactly(entry("changeFromClose", "true")); }
@Test public void shouldSuccessfullyCreateRequestWithChartLast() { final String symbol = "IBM"; final Integer chartLast = 5; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChartLast(chartLast) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).containsExactly(entry("chartLast", String.valueOf(chartLast))); }
@Test public void shouldSuccessfullyCreateRequestWithRange() { final String symbol = "IBM"; final ChartRange chartRange = ChartRange.ONE_DAY; final RestRequest<List<Chart>> request = new ChartRequestBuilder() .withSymbol(symbol) .withChartRange(chartRange) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/chart/{range}"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Chart>>() { }); assertThat(request.getPathParams()).contains( entry("range", chartRange.getCode()), entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
@Test public void oneMonthChartServiceTest() { stubFor(get(urlEqualTo("/stock/aapl/chart/1m")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/ChartOneMonthResponse.json"))); final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.ONE_MONTH) .withSymbol("aapl") .build()); final Chart point = chartList.get(0); assertThat(point.getDate()).isEqualTo("2018-02-01"); assertThat(point.getOpen()).isEqualTo(BigDecimal.valueOf(167.165)); assertThat(point.getHigh()).isEqualTo(BigDecimal.valueOf(168.62)); assertThat(point.getLow()).isEqualTo(BigDecimal.valueOf(166.76)); assertThat(point.getClose()).isEqualTo(BigDecimal.valueOf(167.78)); assertThat(point.getVolume()).isEqualTo(BigDecimal.valueOf(47230787)); assertThat(point.getUnadjustedVolume()).isEqualTo(BigDecimal.valueOf(47230787)); assertThat(point.getChange()).isEqualTo(BigDecimal.valueOf(0.35)); assertThat(point.getChangePercent()).isEqualTo(BigDecimal.valueOf(0.209)); assertThat(point.getVwap()).isEqualTo(BigDecimal.valueOf(167.6021)); assertThat(point.getLabel()).isEqualTo("Feb 1"); assertThat(point.getChangeOverTime()).isEqualTo(BigDecimal.ZERO); }
@Test public void threeMonthChartServiceTest() { stubFor(get(urlEqualTo("/stock/aapl/chart/3m")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/ChartThreeMonthResponse.json"))); final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.THREE_MONTHS) .withSymbol("aapl") .build()); final Chart point = chartList.get(0); assertThat(point.getDate()).isEqualTo("2017-12-01"); assertThat(point.getOpen()).isEqualTo(BigDecimal.valueOf(169.95)); assertThat(point.getHigh()).isEqualTo(BigDecimal.valueOf(171.67)); assertThat(point.getLow()).isEqualTo(BigDecimal.valueOf(168.5)); assertThat(point.getClose()).isEqualTo(BigDecimal.valueOf(171.05)); assertThat(point.getVolume()).isEqualTo(BigDecimal.valueOf(39759288)); assertThat(point.getUnadjustedVolume()).isEqualTo(BigDecimal.valueOf(39759288)); assertThat(point.getChange()).isEqualTo(BigDecimal.valueOf(-0.8)); assertThat(point.getChangePercent()).isEqualTo(BigDecimal.valueOf(-0.466)); assertThat(point.getVwap()).isEqualTo(BigDecimal.valueOf(170.4191)); assertThat(point.getLabel()).isEqualTo("Dec 1, 17"); assertThat(point.getChangeOverTime()).isEqualTo(BigDecimal.ZERO); }
@Test public void sixMonthChartServiceTest() { stubFor(get(urlEqualTo("/stock/aapl/chart/6m")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/ChartSixMonthResponse.json"))); final List<Chart> chartList = iexTradingClient.executeRequest(new ChartRequestBuilder() .withChartRange(ChartRange.SIX_MONTHS) .withSymbol("aapl") .build()); final Chart point = chartList.get(0); assertThat(point.getDate()).isEqualTo("2017-09-01"); assertThat(point.getOpen()).isEqualTo(BigDecimal.valueOf(164.8)); assertThat(point.getHigh()).isEqualTo(BigDecimal.valueOf(164.94)); assertThat(point.getLow()).isEqualTo(BigDecimal.valueOf(163.63)); assertThat(point.getClose()).isEqualTo(BigDecimal.valueOf(164.05)); assertThat(point.getVolume()).isEqualTo(BigDecimal.valueOf(16591051)); assertThat(point.getUnadjustedVolume()).isEqualTo(BigDecimal.valueOf(16591051)); assertThat(point.getChange()).isEqualTo(BigDecimal.valueOf(0.05)); assertThat(point.getChangePercent()).isEqualTo(BigDecimal.valueOf(0.03)); assertThat(point.getVwap()).isEqualTo(BigDecimal.valueOf(164.1212)); assertThat(point.getLabel()).isEqualTo("Sep 1, 17"); assertThat(point.getChangeOverTime()).isEqualTo(BigDecimal.ZERO); }