Search in sources :

Example 11 with CalendarDate

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);
}
Also used : CalendarDateUnit(org.ojalgo.type.CalendarDateUnit) CalendarDate(org.ojalgo.type.CalendarDate) CalendarDateDuration(org.ojalgo.type.CalendarDateDuration)

Example 12 with CalendarDate

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;
}
Also used : CalendarDate(org.ojalgo.type.CalendarDate) BigDecimal(java.math.BigDecimal) CalendarDateSeries(org.ojalgo.series.CalendarDateSeries)

Example 13 with CalendarDate

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());
        }
    }
}
Also used : CalendarDate(org.ojalgo.type.CalendarDate)

Example 14 with CalendarDate

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;
}
Also used : CalendarDate(org.ojalgo.type.CalendarDate)

Aggregations

CalendarDate (org.ojalgo.type.CalendarDate)14 CalendarDateSeries (org.ojalgo.series.CalendarDateSeries)5 BigDecimal (java.math.BigDecimal)4 GeometricBrownianMotion (org.ojalgo.random.process.GeometricBrownianMotion)2 CalendarDateUnit (org.ojalgo.type.CalendarDateUnit)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 ProgrammingError (org.ojalgo.ProgrammingError)1 SimpleAsset (org.ojalgo.finance.portfolio.SimpleAsset)1 PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)1 Deterministic (org.ojalgo.random.Deterministic)1 RandomNumber (org.ojalgo.random.RandomNumber)1 GeometricBrownian1D (org.ojalgo.random.process.GeometricBrownian1D)1 CalendarDateDuration (org.ojalgo.type.CalendarDateDuration)1