Skip to content

Model KagiMRBasketSimulationDemo

github-actions[bot] edited this page Oct 18, 2026 · 8 revisions

KagiMRBasketSimulationDemo — execution tutorial

All model results · Pinned source · Javadoc

What this example teaches

Using this example. Creates mean-reverting baskets with SimpleMRBasketProvider and evaluates a basket through KagiMRBasketSimulation. MRSimParamSP500 supplies the data and interval conventions; the plotted P/L belongs to the selected basket and trading period.

Model and publication. The paper searches for sparse portfolios with low autoregressive predictability, using generalized eigenvalue formulations and sparse approximations. Basket selection and profitable execution are separate questions.

Implementation in this tutorial. SimpleMRBasketProvider uses the configured price matrix, covariance penalty, clustering and basket-selection windows. The demo selects the first basket and passes it to KagiMRBasketSimulation for a trading interval. The Kagi simulation and S&P 500 settings are implementation choices; the example does not demonstrate every greedy/semidefinite method in the paper.

Verified execution record

Item Value
Status failed
Run 39114006111
UTC publication 2026-10-18 09:11 UTC
Source commit 0097e73c040bdaaddac570e2fe694d9836b676ee
Data mode original main defaults
Exit code 1
Elapsed seconds 94.26
Time limit seconds 180
Maximum Java heap 1200m

The demo raised an exception or did not return normally. This is not a verified numerical result.

Reproduce the calculation

Follow the repository setup for JDK 8, Maven credentials and an external NM license. From the repository root:

mvn -U -Dmaven.test.skip=true clean package
mvn exec:java -Dexec.mainClass=tech.nmfin.algoquant.demo.model.daspremont2008.KagiMRBasketSimulationDemo

The automated run uses scripts/ModelDemoRunner.java to initialize the external license before the unchanged main, save JFreeChart windows as PNGs, and exit after main returns. It uses an isolated working directory with the repository datasets/configuration linked in. Running directly may leave desktop windows open.

Observed output

This is an incomplete or blocked run. Output below is diagnostic or partial, not a verified strategy result.

09:06:56,751 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:06:56,752 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:06:56,752 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/home/runner/work/algoquant-examples/algoquant-examples/target/lib/algoquant-dist-3.3.0-SNAPSHOT.jar!/logback.xml]
09:06:56,779 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7cdbc5d3 - URL [jar:file:/home/runner/work/algoquant-examples/algoquant-examples/target/lib/algoquant-dist-3.3.0-SNAPSHOT.jar!/logback.xml] is not of type file
09:06:57,156 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:06:57,157 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:06:57,172 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:06:57,184 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:06:57,252 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
09:06:57,254 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="2026.10.18,09.06.57" to the LOCAL scope
09:06:57,255 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
09:06:57,259 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE1]
09:06:57,269 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3aa9e816 - Will use zip compression
09:06:57,270 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3aa9e816 - Large window sizes are not allowed.
09:06:57,270 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3aa9e816 - MaxIndex reduced to 21
09:06:57,275 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:06:57,276 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - Active log file name: log/algoquant.2026.10.18,09.06.57.log
09:06:57,276 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - File property is set to [log/algoquant.2026.10.18,09.06.57.log]
09:06:57,278 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
09:06:57,278 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
09:06:57,278 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE1] to Logger[ROOT]
09:06:57,278 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:06:57,279 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@17d99928 - Registering current configuration as safe fallback point

09:06:59.019 [main] INFO  t.n.a.m.m.d.s.SimpleMRBasketProvider,197 - computing baskets at time 2013-01-01T00:00 (covPenalty=1.5E-4; inSamplePeriodForClustering=P10Y; inSamplePeriodForBasketSelection=P5Y; nBaskets=1; basketSize=5)
09:06:59.068 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:06:59.069 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:06:59.069 [main] INFO  t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/KagiMRBasketSimulationDemo/work/config/config.default.xml
09:06:59.230 [main] INFO  t.n.algoquant.util.config.AQConfig,148 - 09:06:56,751 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:06:56,752 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
... excerpt shortened; complete stdout is in the release archive ...
09:08:25.727 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WFC.csv.zip
09:08:25.747 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WFC.csv.zip
09:08:25.747 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:25.747 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WELL from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:25.901 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WELL.csv.zip
09:08:25.920 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WELL.csv.zip
09:08:25.920 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:25.920 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WST from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.075 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WST.csv.zip
09:08:26.094 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WST.csv.zip
09:08:26.094 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:26.095 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WDC from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.258 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WDC.csv.zip
09:08:26.281 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WDC.csv.zip
09:08:26.282 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:26.282 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WY from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.412 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WY.csv.zip
09:08:26.431 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WY.csv.zip
09:08:26.432 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:26.432 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WSM from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.563 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WSM.csv.zip
09:08:26.583 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WSM.csv.zip
09:08:26.583 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:26.583 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WMB from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.773 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WMB.csv.zip
09:08:26.796 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WMB.csv.zip
09:08:26.796 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:26.796 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WTW from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:26.982 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WTW.csv.zip
09:08:27.001 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WTW.csv.zip
09:08:27.001 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.001 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WDAY from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.068 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WDAY.csv.zip
09:08:27.071 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WDAY.csv.zip
09:08:27.072 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.072 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for WYNN from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.220 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WYNN.csv.zip
09:08:27.239 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WYNN.csv.zip
09:08:27.240 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.240 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for XEL from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.450 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/XEL.csv.zip
09:08:27.487 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/XEL.csv.zip
09:08:27.487 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.487 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for XYL from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.555 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/XYL.csv.zip
09:08:27.560 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/XYL.csv.zip
09:08:27.560 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.560 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for YUM from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.746 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/YUM.csv.zip
09:08:27.770 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/YUM.csv.zip
09:08:27.770 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.770 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ZBRA from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:27.898 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZBRA.csv.zip
09:08:27.915 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/ZBRA.csv.zip
09:08:27.915 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:27.916 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ZBH from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:28.058 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZBH.csv.zip
09:08:28.078 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/ZBH.csv.zip
09:08:28.079 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,237 - failed to load from file, reason: no data read from file; load from web
09:08:28.079 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ZTS from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:08:28.159 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZTS.csv.zip
09:08:28.162 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/ZTS.csv.zip
java.lang.IllegalArgumentException: List length = -1
	at java.util.Collections.nCopies(Collections.java:4986)
	at dev.nm.algebra.linear.matrix.doubles.operation.MatrixUtils.deColumnMean(pfc:101)
	at dev.nm.stat.descriptive.covariance.SampleCovariance.b(jlb:30)
	at dev.nm.stat.descriptive.covariance.SampleCovariance.<init>(jlb:168)
	at dev.nm.stat.descriptive.covariance.SampleCovariance.<init>(jlb:3)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.ClusterFinder.s(uo:204)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.ClusterFinder.findClusters(uo:130)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.ClusterFinder.findLargestCluster(uo:205)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.MRMultiBasketFinder.findBaskets(ul:28)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.SimpleMRBasketProvider.s(mf:91)
	at tech.nmfin.algoquant.model.meanreversion.daspremont2008.strategy.SimpleMRBasketProvider.basketsAtTime(mf:92)
	at tech.nmfin.algoquant.demo.model.daspremont2008.KagiMRBasketSimulationDemo.main(KagiMRBasketSimulationDemo.java:86)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at ModelDemoRunner.main(ModelDemoRunner.java:35)

Downloadable evidence

Download KagiMRBasketSimulationDemo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.

Export Bytes
files/log/SP500-constituents.csv 21718

Interpreting the result

Use the first relevant exception and the source configuration to resolve the prerequisite or code issue, then rerun. A missing dataset requires the correct original schema and period; substituting synthetic values would be a different experiment. A timeout establishes only that this bounded attempt did not finish.

For model assumptions, original publications and adaptation limits, use the literature guide.

Clone this wiki locally