use of suite.math.numeric.Statistic in project suite by stupidsing.
the class BackAllocatorUtil method byRiskOfReturn.
public default BackAllocator byRiskOfReturn() {
Statistic stat = new Statistic();
int nDays = 32;
return (akds, indices) -> {
Map<String, float[]> returnsByKey = akds.dsByKey.mapValue(DataSource::returns).toMap();
OnDateTime ba0 = allocate(akds, indices);
return index -> //
Read.from2(//
ba0.onDateTime(index)).map2((symbol, potential) -> {
float[] returns = Arrays.copyOfRange(returnsByKey.get(symbol), index - nDays, index);
return potential / stat.variance(returns);
}).toList();
};
}
Aggregations