use of suite.primitive.streamlet.LngStreamlet in project suite by stupidsing.
the class PairTest method test.
private void test(TimeRange period, String symbol0, String symbol1) {
DataSource ds0 = cfg.dataSource(symbol0, period);
DataSource ds1 = cfg.dataSource(symbol1, period);
LngStreamlet ts0 = Longs_.of(ds0.ts);
LngStreamlet ts1 = Longs_.of(ds1.ts);
long[] tradeTimes = Longs_.concat(ts0, ts1).distinct().sort().toArray();
float[] prices0 = ds0.alignBeforePrices(tradeTimes).prices;
float[] prices1 = ds1.alignBeforePrices(tradeTimes).prices;
int length = prices0.length;
LinearRegression lr = statistic.linearRegression(//
Ints_.range(//
length).map(i -> FltObjPair.of(prices1[i], new float[] { prices0[i], 1f })));
System.out.println(symbol0 + " -> " + symbol1 + lr);
assertTrue(.4d < lr.r2);
}
Aggregations