Skip to content

Model SMA2Demo020

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

SMA2Demo020 — AlgoQuant usage tutorial

Wiki home · Tutorials · Execution records

These examples are tutorials that teach how to use AlgoQuant. Their numerical results are incidental and irrelevant to their teaching purpose. Use them to learn API calls, simulation setup, data flow and reporting. The technical examples use synthetic quick-mode data. Read a result here as an illustration of a library call, not as investment evidence.

Tutorials and quantitative model references · Pinned source · Javadoc

Strategy introduction

This is a technical-indicator tutorial. No single original research paper has been established as the source of this exact demo policy, so the introduction explains its mechanics rather than attributing it to an unverified publication.

An indicator transforms observed price or volume history into a statistic. A strategy adds decisions about when the statistic is available, what constitutes an entry or exit, how large a position to hold and how orders are executed. Those extra choices determine account performance; an indicator series alone is not a backtest.

The recorded run uses the documented synthetic quick-mode inputs, so it teaches the AlgoQuant API rather than measuring a historical market opportunity. Read the specific mechanism below together with the signal, order, simulation and report code. Distinguish periods measured in observations from calendar time and avoid treating parameter tuning on one sample as independent validation.

How this demo connects to the idea

The signal compares a fast and a slow arithmetic mean of prices. A fast mean above or below the slow mean produces a directional target after the required history is available. Lag parameters count observations. SMA2DynamicDemo additionally recalibrates parameters on trailing windows; that procedure is separate from the crossover formula.

This variant demonstrates a further SMA2 simulation setup. Read its strategy construction and registered performance measures to distinguish signal calculation from account accounting.

What this example teaches

Demonstrates a fixed SMA crossover using a reusable simulation specification. The template supplies products, dates, data, strategy, currency and measures; SimTemplateUtils builds and runs the simulator from those specifications. The data override keeps this example offline by default despite its Yahoo template. Pass --live to request Yahoo data. Results are printed to the console.

Using this example. Use this after SMA2Demo010 to see the same setup expressed through template overrides. SimTemplateUtils.run creates the simulation from the specification. The built-in SMA2 remains fixed-unit sized even when the template supplies a large initial cash balance.

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

Implementation in this tutorial. The signal compares a fast and a slow arithmetic mean of prices. A fast mean above or below the slow mean produces a directional target after the required history is available. Lag parameters count observations. SMA2DynamicDemo additionally recalibrates parameters on trailing windows; that procedure is separate from the crossover formula.

Verified execution record

Item Value
Status completed
Run 39114360151
UTC publication 2026-10-18 11:43 UTC
Source commit 355aa9242fc2a247b256aecc8406cbb409aa5ff3
Data mode synthetic --quick
Exit code 0
Elapsed seconds 1.59
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.technical.SMA2Demo020 -Dexec.args="--quick"

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


Data: deterministic SYNTHETIC prices; charts: false; quick: true
Simulation checked: 263 NAV observations; 11 executions.
09:14:29.178 [main] INFO  t.n.a.d.model.technical.SMA2Demo020,153 - Performance Report:
Product	Profit Loss	Information Ratio For Trades	Omega For Trades	Max Exposure
XOM	168.88069888786413	4.956691890113746	Infinity	84.98720930763326
Total	168.88069888786413	4.956691890113746	Infinity	84.98720930763326
09:14:29.181 [main] INFO  t.n.a.d.model.technical.SMA2Demo020,154 - There are 11 executions.

Charts from this run

Reported performance statistics

Products and aggregate shown exactly as reported; P/L is monetary, not percent. Currency conventions belong to the demo.

Derived from stdout.log using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Chart 1

Downloadable evidence

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

Export Bytes
files/derived-charts/charts.json 521
files/derived-charts/derived-01.csv 280
files/derived-charts/derived-01.png 81228

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