use of org.ojalgo.type.CalendarDate in project ojAlgo by optimatika.
the class SeriesForecaster method invoke.
@Override
public Map<String, Access1D<?>> invoke(final CalendarDate... key) {
final CalendarDate tmpLastKey = this.getLastKey();
final CalendarDateUnit tmpResolution = this.getResolution();
final CalendarDateDuration[] tmpHorizon = new CalendarDateDuration[key.length];
for (int h = 0; h < tmpHorizon.length; h++) {
final double tmpMeassure = tmpResolution.count(tmpLastKey.millis, key[h].millis);
tmpHorizon[h] = new CalendarDateDuration(tmpMeassure, tmpResolution);
}
return this.invoke(tmpHorizon);
}
use of org.ojalgo.type.CalendarDate in project ojAlgo-finance by optimatika.
the class FinanceUtils method makeDatePriceSeries.
public static CalendarDateSeries<BigDecimal> makeDatePriceSeries(final double[] prices, final Date startDate, final CalendarDateUnit resolution) {
final CalendarDateSeries<BigDecimal> retVal = new CalendarDateSeries<>(resolution);
FinanceUtils.copyValues(retVal, new CalendarDate(startDate), prices);
return retVal;
}
use of org.ojalgo.type.CalendarDate in project ojAlgo-finance by optimatika.
the class SourceCache method cleanUp.
private void cleanUp() {
final CalendarDate tmpNow = new CalendarDate();
for (final Entry<DataSource<?>, SourceCache.Value> tmpEntry : myCache.entrySet()) {
if (myResolution.count(tmpEntry.getValue().used.millis, tmpNow.millis) > 1L) {
tmpEntry.getValue().series.clear();
myCache.remove(tmpEntry.getKey());
}
}
}
use of org.ojalgo.type.CalendarDate in project ojAlgo-finance by optimatika.
the class SourceCache method get.
public synchronized CalendarDateSeries<Double> get(final DataSource<?> key) {
final CalendarDate tmpNow = new CalendarDate();
Value tmpValue = myCache.get(key);
if (tmpValue != null) {
if (myResolution.count(tmpValue.updated.millis, tmpNow.millis) > 0L) {
this.update(tmpValue, key, tmpNow);
}
} else {
tmpValue = new SourceCache.Value(key.getSymbol(), myResolution);
myCache.put(key, tmpValue);
this.update(tmpValue, key, tmpNow);
}
tmpValue.used = tmpNow;
return tmpValue.series;
}
Aggregations