本文整理匯總了Java中org.ojalgo.series.CoordinationSet類的典型用法代碼示例。如果您正苦於以下問題:Java CoordinationSet類的具體用法?Java CoordinationSet怎麽用?Java CoordinationSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CoordinationSet類屬於org.ojalgo.series包,在下文中一共展示了CoordinationSet類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectQuotesSeries
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
/**
* NOT coordinated, completed, pruned or anything...
*/
public static CoordinationSet<Double> collectQuotesSeries(final Collection<? extends PriceSeries> series, final CalendarDateUnit resolution) {
final CoordinationSet<Double> retVal = new CoordinationSet<>(resolution);
for (final PriceSeries tmpSeries : series) {
final CalendarDateSeries<Double> tmpQuotesSeries = tmpSeries.getQuotesSeries();
BasicLogger.debug(tmpQuotesSeries);
BasicLogger.debug("\t" + SampleSet.wrap(tmpQuotesSeries.asPrimitive()));
retVal.put(tmpQuotesSeries);
}
return retVal;
}
示例2: makeAssetSeries
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
public static CalendarDateSeries<Double> makeAssetSeries(final FinancialMarket.Asset asset, final FinancialMarket market) {
final String tmpSeriesKey = asset.getRawHistoricalValues().getName();
final CalendarDate tmpHistoricalHorizon = market.getHistoricalHorizon();
CoordinationSet<Double> tmpMarketData = market.getCoordinatedMarketData();
CalendarDateSeries<Double> tmpCalendarDateSeries = tmpMarketData.get(tmpSeriesKey);
if (tmpCalendarDateSeries == null) {
final CalendarDateSeries<Double> tmpRawHistoricalValues = asset.getRawHistoricalValues();
tmpRawHistoricalValues.complete();
tmpMarketData.put(tmpRawHistoricalValues);
tmpMarketData = tmpMarketData.prune();
tmpCalendarDateSeries = tmpMarketData.get(tmpSeriesKey);
}
CalendarDateSeries<Double> retVal = tmpCalendarDateSeries.tailMap(tmpHistoricalHorizon);
if (market.isHistoricalRiskFreeReturn()) {
final CalendarDateSeries<Double> tmpRawHistoricalRiskFreeReturns = market.getRawHistoricalRiskFreeReturns();
final String tmpName = tmpRawHistoricalRiskFreeReturns.getName();
final CalendarDateSeries<Double> tmpRiskFreeInterestRateSeries = tmpMarketData.get(tmpName).tailMap(tmpHistoricalHorizon);
retVal = FinanceUtils.makeNormalisedExcessPrice(retVal, tmpRiskFreeInterestRateSeries);
}
// TODO Fix this
// retVal.modifyAll(PrimitiveFunction.MULTIPLY.second(PrimitiveMath.HUNDRED / retVal.firstValue().doubleValue()));
final String tmpAssetKey = asset.getAssetKey();
retVal.name(tmpAssetKey);
final Color tmpAssetColour = asset.getAssetColour();
retVal.colour(new ColourData(tmpAssetColour.getRGB()));
return retVal;
}
示例3: makeCoordinatedMarketData
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
public static CoordinationSet<Double> makeCoordinatedMarketData(final FinancialMarket market, final Collection<? extends FinancialMarket.Asset> assets,
final CalendarDateUnit resolution) {
final CoordinationSet<Double> retVal = new CoordinationSet<>(resolution);
for (final FinancialMarket.Asset tmpAsset : assets) {
retVal.put(tmpAsset.getRawHistoricalValues());
}
if (market.isHistoricalRiskFreeReturn()) {
retVal.put(market.getRawHistoricalRiskFreeReturns());
}
return retVal.prune();
}
示例4: testDailyComparison
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
public void testDailyComparison() {
final String tmpYahooSymbol = "AAPL";
final String tmpGoogleSymbol = "NASDAQ:AAPL";
final YahooSymbol tmpYahooSource = new YahooSymbol(tmpYahooSymbol, CalendarDateUnit.DAY);
final CalendarDateSeries<Double> tmpYahooPrices = tmpYahooSource.getPriceSeries();
final GoogleSymbol tmpGoogleSource = new GoogleSymbol(tmpGoogleSymbol, CalendarDateUnit.DAY);
final CalendarDateSeries<Double> tmpGooglePrices = tmpGoogleSource.getPriceSeries();
CoordinationSet<Double> tmpCoordinator = new CoordinationSet<>();
tmpCoordinator.put(tmpYahooPrices);
tmpCoordinator.put(tmpGooglePrices);
tmpCoordinator.complete();
tmpCoordinator = tmpCoordinator.prune();
final CalendarDateSeries<Double> tmpPrunedYahoo = tmpCoordinator.get(tmpYahooSymbol);
final CalendarDateSeries<Double> tmpPrunedGoogle = tmpCoordinator.get(tmpGoogleSymbol);
TestUtils.assertEquals("count", tmpPrunedYahoo.size(), tmpPrunedGoogle.size());
TestUtils.assertEquals("Last Value", tmpPrunedYahoo.lastValue(), tmpPrunedGoogle.lastValue(), NumberContext.getGeneral(8, 14));
// Doesn't work. Goggle and Yahoo seemsto have different data
// JUnitUtils.assertEquals("First Value", tmpPrunedYahoo.firstValue(), tmpPrunedGoogle.firstValue(), PrimitiveMath.IS_ZERO);
// for (final CalendarDate tmpKey : tmpCoordinator.getAllContainedKeys()) {
// final double tmpYahooValue = tmpPrunedYahoo.get(tmpKey);
// final double tmpGoogleValue = tmpPrunedGoogle.get(tmpKey);
// if (tmpYahooValue != tmpGoogleValue) {
// BasicLogger.logDebug("Date={} Yahoo={} Google={}", tmpKey, tmpYahooValue, tmpGoogleValue);
// }
// }
}
示例5: add
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
public void add(final CoordinationSet<?> aSet) {
for (final CalendarDateSeries<?> tmpSeries : aSet.values()) {
this.add(tmpSeries);
}
}
示例6: SeriesForecaster
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
protected SeriesForecaster(final CoordinationSet<? extends Number> coordinatedHistoricalData) {
super(coordinatedHistoricalData);
myLastKey = coordinatedHistoricalData.getEarliestLastKey();
myResolution = coordinatedHistoricalData.getResolution();
}
示例7: makeCovarianceMatrix
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
/**
* @param timeSeriesCollection
* @return Annualised covariances
*/
public static <V extends Number> BasicMatrix makeCovarianceMatrix(final Collection<CalendarDateSeries<V>> timeSeriesCollection) {
final CoordinationSet<V> tmpCoordinator = new CoordinationSet<>(timeSeriesCollection).prune();
final ArrayList<SampleSet> tmpSampleSets = new ArrayList<>();
for (final CalendarDateSeries<V> tmpTimeSeries : timeSeriesCollection) {
final double[] values = tmpCoordinator.get(tmpTimeSeries.getName()).asPrimitive().toRawCopy1D();
final int tmpSize1 = values.length - 1;
final double[] retVal = new double[tmpSize1];
for (int i = 0; i < tmpSize1; i++) {
retVal[i] = PrimitiveFunction.LOG.invoke(values[i + 1] / values[i]);
}
final SampleSet tmpMakeUsingLogarithmicChanges = SampleSet.wrap(Access1D.wrap(retVal));
tmpSampleSets.add(tmpMakeUsingLogarithmicChanges);
}
final int tmpSize = timeSeriesCollection.size();
final Builder<PrimitiveMatrix> retValStore = PrimitiveMatrix.FACTORY.getBuilder(tmpSize, tmpSize);
final double tmpToYearFactor = (double) CalendarDateUnit.YEAR.size() / (double) tmpCoordinator.getResolution().size();
SampleSet tmpRowSet;
SampleSet tmpColSet;
for (int j = 0; j < tmpSize; j++) {
tmpColSet = tmpSampleSets.get(j);
for (int i = 0; i < tmpSize; i++) {
tmpRowSet = tmpSampleSets.get(i);
retValStore.set(i, j, tmpToYearFactor * tmpRowSet.getCovariance(tmpColSet));
}
}
return retValStore.build();
}
示例8: getCoordinatedMarketData
import org.ojalgo.series.CoordinationSet; //導入依賴的package包/類
CoordinationSet<Double> getCoordinatedMarketData();