Repository navigation
Model KagiMRBasketSimulationDemo
All quantitative model results · Pinned source · Javadoc
Alexandre d’Aspremont, Identifying Small Mean Reverting Portfolios (2008 author preprint; published 2011) asks how to build a mean-reverting basket using only a few assets. A dense basket may look attractive statistically but be expensive and difficult to trade.
The paper uses a vector autoregressive representation and a Box–Tiao predictability ratio as a proxy for mean reversion. Minimizing this ratio seeks combinations whose current variation is less explained by lagged variation. A cardinality restriction limits the number of nonzero holdings. Greedy search and semidefinite relaxations address the resulting sparse optimization problem; regularized estimation can help stabilize its inputs.
Its central tradeoff is between sparsity and the strength of the mean-reversion proxy. Finding a basket does not specify a complete trading strategy or guarantee a profit. Kagi signals, entry and exit policies, sizing and the S&P 500 universe in these demos are separate choices. Sections 2–3 of the author preprint were reviewed.
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.
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.
| Item | Value |
|---|---|
| Status | failed |
| Run | 39114360151 |
| UTC publication | 2026-10-18 09:18 UTC |
| Source commit | 355aa9242fc2a247b256aecc8406cbb409aa5ff3 |
| Data mode | original main defaults |
| Exit code | 1 |
| Elapsed seconds | 105.92 |
| 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.
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.KagiMRBasketSimulationDemoThe 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.
This is an incomplete or blocked run. Output below is diagnostic or partial, not a verified strategy result.
09:12:34.338 [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:12:34.368 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:12:34.368 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:12:34.369 [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:12:34.502 [main] INFO t.n.algoquant.util.config.AQConfig,95 - current directory: /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/KagiMRBasketSimulationDemo/work
09:12:34.502 [main] INFO t.n.algoquant.util.config.AQConfig,169 - current config:
09:12:34.512 [main] INFO t.n.algoquant.util.config.AQConfig,11 - nm.license: /home/runner/work/algoquant-examples/algoquant-examples/license/nm.lic
09:12:34.512 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_FOLDER: ./test-data
09:12:34.513 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
09:12:34.513 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
09:12:34.513 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_YAHOO: ${DATA_FOLDER}/yahoo
09:12:34.513 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_SGX: ${DATA_FOLDER}/raw/sgx
09:12:34.514 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_HOLIDAYS: ./log/holidays
09:12:34.514 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/[database configuration redacted]/hk
09:12:34.514 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_OUTPUT_FOLDER: ./log/
09:12:34.514 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_WIDTH: 800
09:12:34.514 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_HEIGHT: 600
09:12:35.466 [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:12:35.467 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for MMM from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:12:35.672 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/MMM.csv.zip
09:12:35.741 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/MMM.csv.zip
09:12:35.760 [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:12:35.761 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AOS from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
09:12:35.921 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/AOS.csv.zip
09:12:35.956 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/AOS.csv.zip
09:12:35.958 [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:12:35.958 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ABT from the Internet from 2003-01-01T00:00 to 2015-01-01T16:00
... excerpt shortened; complete stdout is in the release archive ...
09:14:07.472 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WFC.csv.zip
09:14:07.521 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WFC.csv.zip
09:14:07.521 [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:14:07.524 [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:14:07.703 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WELL.csv.zip
09:14:07.746 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WELL.csv.zip
09:14:07.749 [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:14:07.749 [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:14:07.906 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WST.csv.zip
09:14:07.958 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WST.csv.zip
09:14:07.958 [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:14:07.958 [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:14:08.117 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WDC.csv.zip
09:14:08.181 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WDC.csv.zip
09:14:08.181 [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:14:08.181 [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:14:08.346 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WY.csv.zip
09:14:08.391 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WY.csv.zip
09:14:08.392 [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:14:08.392 [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:14:08.537 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WSM.csv.zip
09:14:08.589 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WSM.csv.zip
09:14:08.590 [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:14:08.590 [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:14:08.772 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WMB.csv.zip
09:14:08.828 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WMB.csv.zip
09:14:08.831 [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:14:08.831 [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:14:09.167 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WTW.csv.zip
09:14:09.191 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WTW.csv.zip
09:14:09.192 [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:14:09.192 [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:14:09.274 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WDAY.csv.zip
09:14:09.282 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WDAY.csv.zip
09:14:09.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:14:09.282 [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:14:09.506 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/WYNN.csv.zip
09:14:09.558 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/WYNN.csv.zip
09:14:09.558 [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:14:09.558 [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:14:09.748 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/XEL.csv.zip
09:14:09.797 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/XEL.csv.zip
09:14:09.798 [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:14:09.798 [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:14:09.880 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/XYL.csv.zip
09:14:09.892 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/XYL.csv.zip
09:14:09.893 [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:14:09.893 [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:14:10.023 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/YUM.csv.zip
09:14:10.087 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/YUM.csv.zip
09:14:10.090 [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:14:10.090 [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:14:10.243 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZBRA.csv.zip
09:14:10.283 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/ZBRA.csv.zip
09:14:10.283 [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:14:10.284 [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:14:10.455 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZBH.csv.zip
09:14:10.508 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/yahoo/pricematrix/ZBH.csv.zip
09:14:10.508 [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:14:10.508 [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:14:10.595 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/yahoo/pricematrix/ZTS.csv.zip
09:14:10.599 [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:38)
DEMO_RUNNER_FAILURE java.lang.IllegalArgumentException
java.lang.IllegalArgumentException: List length = -1
Download KagiMRBasketSimulationDemo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.
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.