Skip to content

Model MRModelRanged2Demo

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

MRModelRanged2Demo — quantitative model tutorial

All quantitative model results · Pinned source · Javadoc

Strategy introduction

This example illustrates a mean-reversion or grid-style trading policy assembled in code. No single original publication has been established for the exact rule, so this page explains the strategy without inventing a paper citation.

The broad idea is to change inventory as price moves through configured levels, or as a spread deviates from a reference. Reversals can allow purchases and sales at different levels, while a persistent trend can accumulate exposure or losses. A rule that repeatedly realizes small gains can still carry substantial open-position risk.

The result depends on grid spacing, reference updates, position limits, data frequency, fills and costs. Mean reversion is an assumption to examine, not a property created by the grid itself. Read the implementation below for the exact configuration, and inspect both account value and outstanding inventory when interpreting a simulation.

How this demo connects to the idea

Here the pair coefficient is -1.5 and MRModelRanged receives 0.0025; these values specify a spread and a range, not an allocation percentage. These are library-specific spread/grid trading policies. A basket converts product prices into a spread; the configured mean-reversion model maps its level or deviation into a desired state, and MeanReversionStrategy translates that state into product orders. Grid distance, periodic/ranged update behavior and scale are distinct controls. The folder name does not mean that option implied volatility is being traded. Mean reversion is an assumption to check, not a property guaranteed by this policy.

What this example teaches

Using this example. Builds an AUD/USD and NZD/USD pair basket with coefficient -1.5 and MRModelRanged threshold 0.0025. It uses local GainCapital tick files, a desktop plotter and trade-based measures. The scale and lot inputs are quantities, not percentages of initial capital.

Model and publication. No single original research publication is claimed for this library/example policy.

Implementation in this tutorial. Here the pair coefficient is -1.5 and MRModelRanged receives 0.0025; these values specify a spread and a range, not an allocation percentage. These are library-specific spread/grid trading policies. A basket converts product prices into a spread; the configured mean-reversion model maps its level or deviation into a desired state, and MeanReversionStrategy translates that state into product orders. Grid distance, periodic/ranged update behavior and scale are distinct controls. The folder name does not mean that option implied volatility is being traded. Mean reversion is an assumption to check, not a property guaranteed by this policy.

Verified execution record

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 1.25
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.volarb.MRModelRanged2Demo

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.


java.time.format.DateTimeParseException: Text '2011-03-04 00:00:14:001' could not be parsed, unparsed text found at index 22
	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
	at java.time.LocalDateTime.parse(LocalDateTime.java:492)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXFileUtils.parseDateTime(sjb:186)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXFileUtils.toData(sjb:232)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory.loadFromFile(meb:199)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory$2$1.s(meb:56)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory$2$1.p(meb:81)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory$2$1.s(meb:21)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory$2$1.<init>(meb:30)
	at tech.nmfin.algoquant.data.historicaldata.gaincapital.GainCapitalFXCacheFactory$2.iterator(meb:88)
	at tech.nmfin.algoquant.execution.component.simulator.DynamicEventQueue.enqueueEventIterable(ehb:82)
	at tech.nmfin.algoquant.execution.component.simulator.SimpleSimulator.s(ujb:252)
	at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608)
	at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082)
	at tech.nmfin.algoquant.execution.component.simulator.SimpleSimulator.s(ujb:396)
	at tech.nmfin.algoquant.execution.component.simulator.SimpleSimulator.run(ujb:97)
	at tech.nmfin.algoquant.demo.model.volarb.MRModelRanged2Demo.main(MRModelRanged2Demo.java:134)
	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

DEMO_RUNNER_FAILURE java.time.format.DateTimeParseException
java.time.format.DateTimeParseException: Text '2011-03-04 00:00:14:001' could not be parsed, unparsed text found at index 22

Downloadable evidence

Download MRModelRanged2Demo.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