Skip to content

Model CSI300SimulationDemo

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

CSI300SimulationDemo — quantitative model tutorial

All quantitative model results · Pinned source · Javadoc

Paper introduction

Harry Markowitz, Portfolio Selection (1952) explains diversification as a portfolio problem: an asset's risk cannot be judged independently of how its returns move with the other holdings. Expected portfolio return is a weighted mean; portfolio variance depends on the full covariance matrix.

The efficient set contains portfolios for which expected return cannot be improved without accepting more variance, or variance reduced without giving up expected return. An investor selects a tradeoff according to preferences and constraints. Holding many positively correlated assets need not provide much diversification.

The framework assumes the relevant return means and covariances are supplied. In practice, estimates can be unstable and constraints can materially change the answer. A solved optimization is therefore a set of weights under assumptions, not evidence of future outperformance. The original article was reviewed. Rolling calibration, rebalance schedules, costs and the dataset used here belong to the demo, not to the static 1952 formulation.

How this demo connects to the idea

Reuses rolling portfolio optimization with configured CSI 300 constituents and adjusted prices. A constituent list needs time-consistent membership, and a price history needs coverage for calibration as well as trading. These dataset choices are separate from the underlying optimization theory.

What this example teaches

Using this example. Configures CSI 300 constituents and local adjusted-price files for a portfolio simulation. The constituent CSV and price directory are independent inputs and must cover compatible dates. Paths in main are examples to adapt to your own dataset.

Model and publication. Related theory and the scope of this example are distinguished below.

Implementation in this tutorial. Reuses rolling portfolio optimization with configured CSI 300 constituents and adjusted prices. A constituent list needs time-consistent membership, and a price history needs coverage for calibration as well as trading. These dataset choices are separate from the underlying optimization theory.

Verified execution record

Item Value
Status timeout
Run 39114360151
UTC publication 2026-10-18 09:18 UTC
Source commit 355aa9242fc2a247b256aecc8406cbb409aa5ff3
Data mode original main defaults
Exit code -15
Elapsed seconds 180.01
Time limit seconds 180
Maximum Java heap 1200m

The original main exceeded the configured execution limit; partial outputs are not a completed 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.portfoliooptimization.csi300.CSI300SimulationDemo

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:14:16.551 [main] INFO  t.n.a.d.h.c.ChinaIndexConstituentsHistoryReader,100 - reading constituents from ./test-data/china/constituent_index_300.csv...
09:14:17.586 [main] INFO  t.n.a.d.m.p.c.CSI300SimulationDemo,451 - simulating buy-and-hold for interval [2010-01-01T00:00,2017-01-01T00:00)...
09:14:17.588 [main] INFO  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,12 - Running algorithm 'buy-and-hold' (window=P7D, rebalance=P7Y)...
09:14:17.600 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:14:17.601 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:14:17.601 [main] INFO  t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/CSI300SimulationDemo/work/config/config.default.xml


09:14:17.728 [main] INFO  t.n.algoquant.util.config.AQConfig,95 - current directory: /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/CSI300SimulationDemo/work
09:14:17.728 [main] INFO  t.n.algoquant.util.config.AQConfig,169 - current config:
09:14:17.737 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - nm.license: /home/runner/work/algoquant-examples/algoquant-examples/license/nm.lic
09:14:17.737 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_FOLDER: ./test-data
09:14:17.737 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
09:14:17.738 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
09:14:17.738 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_YAHOO: ${DATA_FOLDER}/yahoo
09:14:17.738 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_SGX: ${DATA_FOLDER}/raw/sgx
09:14:17.738 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_HOLIDAYS: ./log/holidays
09:14:17.739 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/[database configuration redacted]/hk
09:14:17.739 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_OUTPUT_FOLDER: ./log/
09:14:17.739 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_WIDTH: 800
09:14:17.739 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_HEIGHT: 600
09:14:18.543 [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:18.543 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for 000300.SS from the Internet from 2005-01-01T00:00 to 2017-01-01T15:00
09:14:18.708 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./test-data/china/20070104-20171027/adjust_prices/000300.SS.csv.zip
09:14:18.709 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./test-data/china/20070104-20171027/adjust_prices/000300.SS.csv.zip
09:14:20.102 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000866.SZ @ SZ
09:14:20.103 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000866.SZ @ SZ, ignored
09:14:20.158 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000817.SZ @ SZ
09:14:20.158 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000817.SZ @ SZ, ignored
09:14:20.529 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000406.SZ @ SZ
09:14:20.529 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000406.SZ @ SZ, ignored
09:14:20.762 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 600002.SH @ SS
09:14:20.762 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 600002.SH @ SS, ignored
09:14:20.798 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000956.SZ @ SZ
09:14:20.798 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000956.SZ @ SZ, ignored
09:14:20.821 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000763.SZ @ SZ
09:14:20.821 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000763.SZ @ SZ, ignored
09:14:20.861 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for T00018.SH @ SS
09:14:20.861 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for T00018.SH @ SS, ignored
09:14:21.940 [main] WARN  t.n.a.d.h.c.z.s.c.CSI300DataProvider,10 - failed to load data for 000618.SZ @ SZ
09:14:21.940 [main] WARN  t.n.a.m.p.s.OptimizationAlgorithmComparisonSimulation,298 - failed to load cache for 000618.SZ @ SZ, ignored
09:14:23.117 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ^IRX from the Internet from 2009-12-01T00:00 to 2017-01-01T16:00
09:14:23.330 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ^GSPC from the Internet from 2009-11-25T00:00 to 2017-01-15T16:00
09:14:23.675 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2010-01-01T00:00
09:14:24.770 [main] INFO  t.n.a.m.s.r.RebalancePortfolioTechnical,153 - dropped products with no data (1): [000300.SS @ SS]
09:14:24.794 [main] WARN  t.n.a.m.s.r.RebalancePortfolio,194 - failed to compute new positions: 'beginRow' must be in range [1 0]: 1
java.lang.IllegalArgumentException: 'beginRow' must be in range [1 0]: 1
	at dev.nm.misc.ArgumentAssertion.assertRange(meb:207)
	at dev.nm.algebra.linear.matrix.doubles.matrixtype.dense.DenseMatrix.getColumn(cf:310)
	at dev.nm.algebra.linear.matrix.doubles.matrixtype.dense.DenseMatrix.getColumn(cf:446)
	at tech.nmfin.algoquant.model.portfoliooptimization.IndexAwareOptimizer.getOptimalWeights(qb:71)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolioTechnical.getPositions(r:19)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolio.s(z:196)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolio.onEvent(z:11)
	at tech.nmfin.algoquant.execution.component.simulator.message.handler.ChannelMessageHandlerFactories$1$1.handle(hmb:200)
	at tech.nmfin.algoquant.execution.component.simulator.message.dispatcher.SimpleChannelMessageDispatcher.dispatch(pfb:187)
	at tech.nmfin.algoquant.execution.component.simulator.StrategyComponent.dispatch(ybb:150)
	at dev.nm.nmutils.circuit.controller.SingleThreadedController.run(uwb:137)
	at tech.nmfin.algoquant.execution.component.simulator.SimpleSimulator.run(ujb:132)
	at tech.nmfin.algoquant.execution.simulation.template.SimTemplateUtils.run(kq:48)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.PortfolioOptimizationSimulation.run(ym:767)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.s(ne:437)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.s(ne:163)
	at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.run(ne:193)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.simulateAlgorithm(CSI300SimulationDemo.java:454)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.simulateBaseline(CSI300SimulationDemo.java:138)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.run(CSI300SimulationDemo.java:111)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.main(CSI300SimulationDemo.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)
09:14:58.006 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2017-01-01T00:00
09:14:58.843 [main] INFO  t.n.a.m.s.r.RebalancePortfolioTechnical,153 - dropped products with no data (1): [000300.SS @ SS]
09:14:58.847 [main] WARN  t.n.a.m.s.r.RebalancePortfolio,194 - failed to compute new positions: 'beginRow' must be in range [1 0]: 1
java.lang.IllegalArgumentException: 'beginRow' must be in range [1 0]: 1
	at dev.nm.misc.ArgumentAssertion.assertRange(meb:207)
	at dev.nm.algebra.linear.matrix.doubles.matrixtype.dense.DenseMatrix.getColumn(cf:310)
	at dev.nm.algebra.linear.matrix.doubles.matrixtype.dense.DenseMatrix.getColumn(cf:446)
	at tech.nmfin.algoquant.model.portfoliooptimization.IndexAwareOptimizer.getOptimalWeights(qb:71)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolioTechnical.getPositions(r:19)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolio.s(z:196)
	at tech.nmfin.algoquant.model.strategy.rebalance.RebalancePortfolio.onEvent(z:11)
	at tech.nmfin.algoquant.execution.component.simulator.message.handler.ChannelMessageHandlerFactories$1$1.handle(hmb:200)
	at tech.nmfin.algoquant.execution.component.simulator.message.dispatcher.SimpleChannelMessageDispatcher.dispatch(pfb:187)
	at tech.nmfin.algoquant.execution.component.simulator.StrategyComponent.dispatch(ybb:150)
	at dev.nm.nmutils.circuit.controller.SingleThreadedController.run(uwb:137)
	at tech.nmfin.algoquant.execution.component.simulator.SimpleSimulator.run(ujb:132)
	at tech.nmfin.algoquant.execution.simulation.template.SimTemplateUtils.run(kq:48)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.PortfolioOptimizationSimulation.run(ym:767)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.s(ne:437)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.s(ne:163)
	at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
	at tech.nmfin.algoquant.model.portfoliooptimization.simulation.OptimizationAlgorithmComparisonSimulation.run(ne:193)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.simulateAlgorithm(CSI300SimulationDemo.java:454)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.simulateBaseline(CSI300SimulationDemo.java:138)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.run(CSI300SimulationDemo.java:111)
	at tech.nmfin.algoquant.demo.model.portfoliooptimization.csi300.CSI300SimulationDemo.main(CSI300SimulationDemo.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)

Diagnostic and prerequisites

java.lang.IllegalArgumentException: 'beginRow' must be in range [1 0]: 1
java.lang.IllegalArgumentException: 'beginRow' must be in range [1 0]: 1

Downloadable evidence

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

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