BitmexHistoricalDataProvider implements IHistoricalDataProvider { @Override public List<BarData> requestHistoricalData(Ticker ticker, int duration, BarData.LengthUnit durationLengthUnit, int barSize, BarData.LengthUnit barSizeUnit, ShowProperty whatToShow, boolean useRTH) { if (whatToShow != ShowProperty.TRADES) { throw new SumZeroException("Only historical trades are supported"); } List<BitmexChartData> bitmexData = client.getChartData(ticker, duration, HistoricalDataUtils.getBinSize(barSize, barSizeUnit), "", true); return convertToBarData(ticker, barSize, barSizeUnit, bitmexData); }  @Override boolean isConnected(); @Override void connect(); @Override void init(Properties props); @Override List<BarData> requestHistoricalData(Ticker ticker, int duration, BarData.LengthUnit durationLengthUnit, int barSize, BarData.LengthUnit barSizeUnit, ShowProperty whatToShow, boolean useRTH); @Override List<BarData> requestHistoricalData(Ticker ticker, Date endDateTime, int duration, BarData.LengthUnit durationLengthUnit, int barSize, BarData.LengthUnit barSizeUnit, ShowProperty whatToShow, boolean useRTH);  }
@Test public void testRequestHistoricalData_NotTrades() { try { testProvider.requestHistoricalData(new GenericTicker("ABC"), 1, BarData.LengthUnit.DAY, 1, BarData.LengthUnit.MINUTE, IHistoricalDataProvider.ShowProperty.ASK, true); fail(); } catch (SumZeroException ex) { } }
@Test public void testRequestHistoricalData() { Ticker ticker = new GenericTicker("ABC"); int duration = 100; int barSize = 1; BarData.LengthUnit lengthUnit = BarData.LengthUnit.MINUTE; testProvider.client = mockClient; List<BitmexChartData> dataList = new ArrayList<>(); BitmexChartData data = new BitmexChartData(); data.setOpen(0); dataList.add(data); List<BarData> barDataList = new ArrayList<>(); BarData barData = new BarData(LocalDateTime.MIN, BigDecimal.ONE, BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE); barDataList.add(barData); when(mockClient.getChartData(ticker, duration, BitmexRestClient.ChartDataBinSize.ONE_MINUTE, "", true)).thenReturn(dataList); doReturn(barDataList).when(testProvider).convertToBarData(ticker, barSize, lengthUnit, dataList); assertEquals( barDataList, testProvider.requestHistoricalData(ticker, duration, lengthUnit, barSize, lengthUnit, IHistoricalDataProvider.ShowProperty.TRADES, true)); }
@Test public void testRequestHistoricalData_OverloadedMethod() { try { testProvider.requestHistoricalData(new GenericTicker("ABC"), new Date(), 2, BarData.LengthUnit.MONTH, 10, BarData.LengthUnit.MINUTE, IHistoricalDataProvider.ShowProperty.TRADES, true); fail(); } catch( SumZeroException ex ) { } }