Search in sources :

Example 6 with CandleData

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);
}
Also used : CandleData(bisq.desktop.main.market.trades.charts.CandleData) TradeStatistics2(bisq.core.trade.statistics.TradeStatistics2) FiatCurrency(bisq.core.locale.FiatCurrency) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

CandleData (bisq.desktop.main.market.trades.charts.CandleData)6 XYChart (javafx.scene.chart.XYChart)4 TradeStatistics2 (bisq.core.trade.statistics.TradeStatistics2)3 Date (java.util.Date)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 MathUtils (bisq.common.util.MathUtils)1 CryptoCurrency (bisq.core.locale.CryptoCurrency)1 CurrencyUtil (bisq.core.locale.CurrencyUtil)1 FiatCurrency (bisq.core.locale.FiatCurrency)1 GlobalSettings (bisq.core.locale.GlobalSettings)1 TradeCurrency (bisq.core.locale.TradeCurrency)1 Altcoin (bisq.core.monetary.Altcoin)1 PriceFeedService (bisq.core.provider.price.PriceFeedService)1 TradeStatisticsManager (bisq.core.trade.statistics.TradeStatisticsManager)1 Preferences (bisq.core.user.Preferences)1 Navigation (bisq.desktop.Navigation)1 ActivatableViewModel (bisq.desktop.common.model.ActivatableViewModel)1 MainView (bisq.desktop.main.MainView)1