Search in sources :

Example 1 with InstrumentStatistics

use of com.axibase.tsd.api.model.financial.InstrumentStatistics in project atsd-api-test by axibase.

the class TestJoinWithTradesWhereClauseCondition method prepareData.

@BeforeClass
public void prepareData() throws Exception {
    List<Trade> trades = new ArrayList<>();
    trades.add(fromISOString("2020-06-15T20:21:49.123457Z").setNumber(1).setExchange(MOEX).setPrice(new BigDecimal("3.5")).setQuantity(4).setSession(Trade.Session.N).setSide(Trade.Side.BUY));
    trades.add(fromISOString("2020-06-15T20:22:01.567899Z").setNumber(2).setExchange(MOEX).setPrice(new BigDecimal("5")).setQuantity(10).setSession(Trade.Session.S).setSide(Trade.Side.SELL));
    insert(trades);
    InstrumentStatistics one = new InstrumentStatistics().setClazz(clazz()).setSymbol(symbol()).setTimestamp(ZonedDateTime.parse("2020-06-15T20:21:49.123456Z")).addValue(2, // numoffers
    "1234").addValue(5, // numbids
    "5060").addValue(10, // bid
    "196.04");
    InstrumentStatistics two = new InstrumentStatistics().setClazz(clazz()).setSymbol(symbol()).setTimestamp(ZonedDateTime.parse("2020-06-15T20:22:00.567899Z")).addValue(2, // numoffers
    "1235").addValue(5, // numbids
    "5060").addValue(10, // bid
    "196.04");
    InstrumentStatisticsSender.send(one, two).waitUntilStatisticsHistoryInsertedAtMost(1, TimeUnit.MINUTES);
}
Also used : Trade(com.axibase.tsd.api.model.financial.Trade) InstrumentStatistics(com.axibase.tsd.api.model.financial.InstrumentStatistics) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with InstrumentStatistics

use of com.axibase.tsd.api.model.financial.InstrumentStatistics in project atsd-api-test by axibase.

the class StatisticsDailyTimeRangeTest method prepareData.

@BeforeClass
public void prepareData() throws Exception {
    List<Trade> trades = new ArrayList<>();
    long quantity = 1;
    for (String[] row : ROWS_STAT_AND_TRADES) {
        trades.add(fromISOString(row[0]).setExchange(MOEX).setQuantity(quantity++));
    }
    insert(trades);
    List<InstrumentStatistics> stats = new ArrayList<>();
    for (String[] row : ROWS_STAT) {
        ZonedDateTime zonedDateTime = ZonedDateTime.parse(row[0]);
        stats.add(new InstrumentStatistics().setClazz(clazz()).setSymbol(symbol()).setTimestamp(zonedDateTime).addValue(0, // rptseq
        row[1]));
    }
    InstrumentStatisticsSender.send(stats).waitUntilStatisticsHistoryInsertedAtMost(1, TimeUnit.MINUTES);
}
Also used : Trade(com.axibase.tsd.api.model.financial.Trade) InstrumentStatistics(com.axibase.tsd.api.model.financial.InstrumentStatistics) ZonedDateTime(java.time.ZonedDateTime) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

InstrumentStatistics (com.axibase.tsd.api.model.financial.InstrumentStatistics)2 Trade (com.axibase.tsd.api.model.financial.Trade)2 BeforeClass (org.testng.annotations.BeforeClass)2 BigDecimal (java.math.BigDecimal)1 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1