Repository navigation
Model GMA12Demo
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
Knight, Satchell and Tran (1995), Statistical modelling of asymmetric risk in asset returns motivates modeling positive and negative return behavior separately. In this example, a return process is the input to an analytical trading-rule calculation, rather than a historical portfolio backtest.
A related theoretical reference is Emmanuel Acar and Stephen Satchell (1997), A theoretical analysis of trading rules: an application to the moving average case with Markovian returns. It studies moving-average trading rules under an assumed return process. The general lesson is that a rule's behavior depends on the distribution and serial dependence of returns, not just its moving-average parameters.
The publication abstracts/identities were checked, but the full derivations were not independently reviewed. The Acar–Satchell paper is related literature: an exact equivalence between its assumptions and GMA12 has not been established. The printed trade quantities are model-based calculations, not realized account performance.
Convert Yahoo adjusted closes to log returns, call KnightSatchellTran1995MLE.fitModel, then construct GMA12. PrHoldingTime(1) and ERRLong() are model-derived quantities, not realized Sharpe ratios or total portfolio returns. Fitting an asymmetric return law does not by itself establish stable out-of-sample trend profitability.
Demonstrates Acar's framework of a trend following strategy. We first fit the Acar's model with some real price data. Then we compute the properties of the model, e.g., the expected P&L for playing the GMA(1, 2) strategy.
Using this example. Loads Yahoo prices, fits a Knight-Satchell-Tran model and evaluates GMA(1,2) trend-following properties. The output describes the fitted model; it is not automatically the return of a fully invested trading account.
Model and publication. Knight–Satchell–Tran is the fitted return-model reference. Acar–Satchell is related moving- average analysis, not a claim that its switching-Gaussian derivation is identical to this GMA12 implementation; both originals were unavailable in full during this audit.
Implementation in this tutorial. Convert Yahoo adjusted closes to log returns, call KnightSatchellTran1995MLE.fitModel, then construct GMA12. PrHoldingTime(1) and ERRLong() are model-derived quantities, not realized Sharpe ratios or total portfolio returns. Fitting an asymmetric return law does not by itself establish stable out-of-sample trend profitability.
| Item | Value |
|---|---|
| Status | completed |
| Run | 39114360151 |
| UTC publication | 2026-10-18 11:43 UTC |
| Source commit | 355aa9242fc2a247b256aecc8406cbb409aa5ff3 |
| Data mode | original main defaults |
| Exit code | 0 |
| Elapsed seconds | 2.94 |
| Time limit seconds | 180 |
| Maximum Java heap | 1200m |
The original main returned successfully. Read the output and model assumptions before interpreting it.
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.kst1995.GMA12DemoThe 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.
09:12:53.658 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:12:53.660 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:12:53.661 [main] INFO t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/GMA12Demo/work/config/config.default.xml
09:12:53.833 [main] INFO t.n.algoquant.util.config.AQConfig,95 - current directory: /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/GMA12Demo/work
09:12:53.833 [main] INFO t.n.algoquant.util.config.AQConfig,169 - current config:
09:12:53.850 [main] INFO t.n.algoquant.util.config.AQConfig,11 - nm.license: /home/runner/work/algoquant-examples/algoquant-examples/license/nm.lic
09:12:53.851 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_FOLDER: ./test-data
09:12:53.851 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
09:12:53.851 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
09:12:53.851 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_YAHOO: ${DATA_FOLDER}/yahoo
09:12:53.851 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_SGX: ${DATA_FOLDER}/raw/sgx
09:12:53.852 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_HOLIDAYS: ./log/holidays
09:12:53.852 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/[database configuration redacted]/hk
09:12:53.852 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_OUTPUT_FOLDER: ./log/
09:12:53.852 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_WIDTH: 800
09:12:53.853 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_HEIGHT: 600
09:12:55.042 [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:55.042 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ^HSI from the Internet from 2009-01-01T00:00 to 2010-12-31T16:00
09:12:55.155 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/^HSI.csv.zip
09:12:55.179 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/^HSI.csv.zip
09:12:55.712 [main] INFO t.n.a.demo.model.kst1995.GMA12Demo,100 - state 0: q = 0.200000, alpha0 = 1.126335, rate0 = 129.452917; state 1: p = 0.868545, alpha1 = 2.682338, rate1 = 119.911951; mu: -0.017136
09:12:55.713 [main] INFO t.n.a.demo.model.kst1995.GMA12Demo,103 - the probability of holding time = 1: 0.11290322580645161
09:12:55.713 [main] INFO t.n.a.demo.model.kst1995.GMA12Demo,107 - the expected pnl for a long position: 0.13909597851782685
Printed analytical quantities at the reported parameter estimates; not historical account returns.
Derived from stdout.log using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Parameter axes are separate. Record order is preserved; estimated parameters are not investment performance.
Derived from stdout.log using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Parameter axes are separate. Record order is preserved; estimated parameters are not investment performance.
Derived from stdout.log using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Download GMA12Demo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.
| Export | Bytes |
|---|---|
files/derived-charts/charts.json |
1540 |
files/derived-charts/derived-01.csv |
158 |
files/derived-charts/derived-01.png |
53099 |
files/derived-charts/derived-02.csv |
151 |
files/derived-charts/derived-02.png |
99811 |
files/derived-charts/derived-03.csv |
46 |
files/derived-charts/derived-03.png |
41097 |
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.