HistoricalDataUtils { public static BarData buildBarData( Ticker ticker, int barlength, BarData.LengthUnit lengthUnit, BitmexChartData data ) { ZoneId localZone = ZoneId.systemDefault(); ZonedDateTime localZonedTime = data.getTimestamp().withZoneSameInstant(localZone); LocalDateTime localTime = localZonedTime.toLocalDateTime(); BarData bar = new BarData(ticker, localTime, new BigDecimal(data.getOpen()), new BigDecimal(data.getHigh()), new BigDecimal(data.getLow()), new BigDecimal(data.getClose()), new BigDecimal(data.getVolume()), barlength, lengthUnit); return bar; }  static BitmexRestClient.ChartDataBinSize getBinSize( int length, BarData.LengthUnit lengthUnit ); static BarData buildBarData( Ticker ticker, int barlength, BarData.LengthUnit lengthUnit, BitmexChartData data );  }
@Test public void testBuildBarData() { int barLength = 1; BarData.LengthUnit lengthUnit = BarData.LengthUnit.MINUTE; Ticker ticker = new GenericTicker("ABC"); BigDecimal open = new BigDecimal(123.23); BigDecimal high = new BigDecimal(234.45); BigDecimal low = new BigDecimal(100.23); BigDecimal close = new BigDecimal(145.54); BigDecimal volume = new BigDecimal(2231); ZonedDateTime timestamp = ZonedDateTime.of(2018, 6, 13, 14, 50, 0, 0, ZoneId.of("UTC")); BitmexChartData chartData = new BitmexChartData(); chartData.setTimestamp(timestamp); chartData.setOpen(open.doubleValue()); chartData.setHigh(high.doubleValue()); chartData.setLow(low.doubleValue()); chartData.setClose(close.doubleValue()); chartData.setVolume(volume.doubleValue()); BarData expectedData = new BarData(ticker, LocalDateTime.of(2018, 6, 13, 7, 50, 0), open, high, low, close, volume, barLength, lengthUnit); assertEquals(expectedData, HistoricalDataUtils.buildBarData(ticker, barLength, lengthUnit, chartData)); }