Skip to content

Model BootstrapSimulationDemo

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

BootstrapSimulationDemo — execution tutorial

All model results · Pinned source · Javadoc

What this example teaches

Demonstrates the bootstrap simulation of the Dai's trend following strategy.

Using this example. Resamples log returns for the Dai trend-following strategy, reconstructs price paths and runs a fresh strategy on each path. The output file under log/demo contains scenario reports. Sampled paths are hypothetical and the chosen block lengths and randomization affect the distribution.

Model and publication. Filtered regime probabilities and trading boundaries are the conceptual basis of the Dai strategy. The bootstrap performed here is a separate experiment layered over that strategy.

Implementation in this tutorial. The main uses Dai2011LongShort and reconstructed paths obtained from sampled log returns. Each scenario has its own market cache, simulator and report. PattonPolitisWhite2009 estimates a block length for dependent resampling; neither a resampled path nor a bootstrap P/L quantile is a new historical observation or a reproduction of the paper’s market test.

Verified execution record

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

The original main returned successfully. Read the output and model assumptions before interpreting it.

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.dai2011.BootstrapSimulationDemo

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

09:07:03,286 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:07:03,286 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:07:03,286 |-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:07:03,307 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@17d99928 - 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:07:04,124 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:07:04,125 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:07:04,136 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:07:04,143 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:07:04,176 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
09:07:04,179 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="2026.10.18,09.07.04" to the LOCAL scope
09:07:04,179 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
09:07:04,181 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE1]
09:07:04,188 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3834d63f - Will use zip compression
09:07:04,188 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3834d63f - Large window sizes are not allowed.
09:07:04,188 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@3834d63f - MaxIndex reduced to 21
09:07:04,193 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:07:04,194 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - Active log file name: log/algoquant.2026.10.18,09.07.04.log
09:07:04,194 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - File property is set to [log/algoquant.2026.10.18,09.07.04.log]
09:07:04,196 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
09:07:04,196 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
09:07:04,196 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE1] to Logger[ROOT]
09:07:04,196 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:07:04,198 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1ae369b7 - Registering current configuration as safe fallback point

09:07:04.378 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:07:04.380 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:07:04.380 [main] INFO  t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/BootstrapSimulationDemo/work/config/config.default.xml
09:07:04.725 [main] INFO  t.n.algoquant.util.config.AQConfig,148 - 09:07:03,286 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:07:03,286 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:07:03,286 |-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]
... excerpt shortened; complete stdout is in the release archive ...
in uptrend state: drift = 1.032854, lambda1 = 2.787133
in downtrend state: drift = -1.064117, lambda2 = 3.170913
volatility = 0.214787
09:07:31.556 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2011-01-12T16:00 to 2012-01-13T16:00...
09:07:31.556 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.097048, lambda1 = 2.929395
in downtrend state: drift = -1.163926, lambda2 = 3.025111
volatility = 0.224033
09:07:34.905 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2003-01-01T00:00 to 2006-01-03T16:00...
09:07:34.905 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.973395, lambda1 = 3.142775
in downtrend state: drift = -1.081302, lambda2 = 3.578530
volatility = 0.216144
09:07:35.566 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2003-01-01T00:00 to 2006-01-03T16:00...
09:07:35.566 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.707955, lambda1 = 2.463674
in downtrend state: drift = -0.923585, lambda2 = 2.944342
volatility = 0.194873
09:07:38.256 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2006-01-03T16:00 to 2007-01-04T16:00...
09:07:38.256 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.969217, lambda1 = 3.055478
in downtrend state: drift = -1.038905, lambda2 = 3.478893
volatility = 0.213564
09:07:38.825 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2006-01-03T16:00 to 2007-01-04T16:00...
09:07:38.825 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.057851, lambda1 = 2.565898
in downtrend state: drift = -1.061100, lambda2 = 3.006236
volatility = 0.208635
09:07:41.506 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2007-01-04T16:00 to 2008-01-07T16:00...
09:07:41.506 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.942961, lambda1 = 2.818706
in downtrend state: drift = -1.019287, lambda2 = 3.215782
volatility = 0.209477
09:07:41.869 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2007-01-04T16:00 to 2008-01-07T16:00...
09:07:41.869 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.119348, lambda1 = 2.775354
in downtrend state: drift = -1.132655, lambda2 = 3.147080
volatility = 0.217370
09:07:45.222 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2008-01-07T16:00 to 2009-01-08T16:00...
09:07:45.223 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.998776, lambda1 = 3.128300
in downtrend state: drift = -1.057083, lambda2 = 3.119595
volatility = 0.216113
09:07:45.937 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2008-01-07T16:00 to 2009-01-08T16:00...
09:07:45.937 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.113251, lambda1 = 2.775852
in downtrend state: drift = -1.115831, lambda2 = 3.156250
volatility = 0.216856
09:07:50.632 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2009-01-08T16:00 to 2010-01-11T16:00...
09:07:50.633 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.011021, lambda1 = 3.192920
in downtrend state: drift = -1.044158, lambda2 = 3.033416
volatility = 0.215987
09:07:51.621 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2009-01-08T16:00 to 2010-01-11T16:00...
09:07:51.622 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.286815, lambda1 = 2.784285
in downtrend state: drift = -1.206317, lambda2 = 3.268851
volatility = 0.223586
09:07:54.340 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2010-01-11T16:00 to 2011-01-12T16:00...
09:07:54.341 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 0.993780, lambda1 = 3.049375
in downtrend state: drift = -1.032823, lambda2 = 2.919936
volatility = 0.212683
09:07:55.088 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2010-01-11T16:00 to 2011-01-12T16:00...
09:07:55.089 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.339913, lambda1 = 2.798972
in downtrend state: drift = -1.187712, lambda2 = 3.143991
volatility = 0.225811
09:07:57.644 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2011-01-12T16:00 to 2012-01-13T16:00...
09:07:57.644 [Dai2011-1-thread-2] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.016614, lambda1 = 3.086687
in downtrend state: drift = -1.015461, lambda2 = 2.925112
volatility = 0.214270
09:07:58.407 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,173 - calibrated from 2011-01-12T16:00 to 2012-01-13T16:00...
09:07:58.407 [Dai2011-1-thread-1] INFO  t.n.a.m.t.d.s.Dai2011LongShort,188 - Dai 2011 HMM: 
in uptrend state: drift = 1.343235, lambda1 = 2.686253
in downtrend state: drift = -1.190351, lambda2 = 3.145819
volatility = 0.224015
09:08:01.500 [main] INFO  t.n.a.d.m.d.BootstrapSimulationDemo,246 - saving reports to /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/BootstrapSimulationDemo/work/./log/demo/trendfollowing_reports.txt...
09:08:01.503 [main] INFO  t.n.a.d.m.d.BootstrapSimulationDemo,263 - saving reports done.

Downloadable evidence

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

Export Bytes
files/log/demo/trendfollowing_reports.txt 1106

Interpreting the result

Read the reported units: optimizer weights, model-fit coefficients, forecast correlations and simulated P/L are different outputs. Synthetic runs demonstrate the API rather than historical market returns. Inspect undefined values and open positions instead of replacing them with zero. Chart exports visualize exactly this run.

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

Clone this wiki locally