use of suite.trade.data.Configuration in project suite by stupidsing.
the class BackAllocatorUtil method filterByIndexReturn.
public default BackAllocator filterByIndexReturn(Configuration cfg, String indexSymbol) {
DataSource indexDataSource = cfg.dataSource(indexSymbol);
return (akds, indices) -> {
OnDateTime onDateTime = allocate(akds, indices);
return index -> {
Time date = Time.ofEpochSec(akds.ts[index - 1]).date();
long t0 = date.addDays(-7).epochSec();
long tx = date.epochSec();
DataSource ids = indexDataSource.range(t0, tx);
double indexPrice0 = ids.get(-1).t1;
double indexPricex = ids.get(-2).t1;
double indexReturn = Quant.return_(indexPrice0, indexPricex);
return //
-.03f < indexReturn ? //
onDateTime.onDateTime(index) : List.of();
};
};
}
Aggregations