use of bisq.desktop.main.market.trades.charts.CandleData in project bisq-desktop by bisq-network.
the class TradesChartsViewModelTest method testGetCandleData.
@SuppressWarnings("ConstantConditions")
@Test
public void testGetCandleData() {
model.selectedTradeCurrencyProperty.setValue(new FiatCurrency("EUR"));
long low = Fiat.parseFiat("EUR", "500").value;
long open = Fiat.parseFiat("EUR", "520").value;
long close = Fiat.parseFiat("EUR", "580").value;
long high = Fiat.parseFiat("EUR", "600").value;
long average = Fiat.parseFiat("EUR", "550").value;
long amount = Coin.parseCoin("4").value;
long volume = Fiat.parseFiat("EUR", "2200").value;
boolean isBullish = true;
Set<TradeStatistics2> set = new HashSet<>();
final Date now = new Date();
set.add(new TradeStatistics2(offer, Price.parse("EUR", "520"), Coin.parseCoin("1"), new Date(now.getTime()), null));
set.add(new TradeStatistics2(offer, Price.parse("EUR", "500"), Coin.parseCoin("1"), new Date(now.getTime() + 100), null));
set.add(new TradeStatistics2(offer, Price.parse("EUR", "600"), Coin.parseCoin("1"), new Date(now.getTime() + 200), null));
set.add(new TradeStatistics2(offer, Price.parse("EUR", "580"), Coin.parseCoin("1"), new Date(now.getTime() + 300), null));
CandleData candleData = model.getCandleData(model.roundToTick(now, TradesChartsViewModel.TickUnit.DAY).getTime(), set);
assertEquals(open, candleData.open);
assertEquals(close, candleData.close);
assertEquals(high, candleData.high);
assertEquals(low, candleData.low);
assertEquals(average, candleData.average);
assertEquals(amount, candleData.accumulatedAmount);
assertEquals(volume, candleData.accumulatedVolume);
assertEquals(isBullish, candleData.isBullish);
}
Aggregations