Skip to content

About

Runnable AlgoQuant technical-analysis examples using the public obfuscated distribution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

90 Commits

Folders and files

Repository files navigation

AlgoQuant examples

AlgoQuant is a framework and host/hub for studying, simulating, researching and applying quantitative strategies. This repository provides usage tutorials, quantitative model references and web analysis applications.

The public repository contains the example and application source. The underlying library is supplied by the obfuscated combined Maven artifact tech.nmfin:algoquant-dist:3.3.2 and requires a valid NM license. The examples explicitly use dev.nm:nmdev-dist:1.2.7 from the same public Maven repository.

NM Dev is declared before AlgoQuant in Maven and placed before target/lib/* in Java launch commands and the container classpath. This ensures NM Dev 1.2.7 takes precedence over the older classes embedded in AlgoQuant 3.3.2. Preserve this ordering in custom launch configurations; a wildcard alone has unspecified JAR order.

AlgoQuant 3.3.2 historical-data tutorial

Use the CSI300 tutorial to learn constituent loading, benchmark history, simulation and exports. Eastmoney is the default index source; select Sina with -Dcsi300.indexSource=sina. Both use the shared CSV ZIP disk cache. Yahoo, Sina and Eastmoney also accept individual stocks; see the downloader and cache guide.

Release downloads · Execution coverage and known limitations. CSI300 completed both default baselines, but skipped some unavailable constituent histories and reported NaN correlation measures. The opt-in optimizer grid was not run.

Learning the library

Browse the examples and tutorials Javadoc alongside the AlgoQuant library API. Regenerate and publish the examples documentation with the manual Publish examples Javadoc without tests workflow; it compiles source and validates documentation without running the test suite.

Start with the tutorial reading guide, then follow the class Javadoc and inline comments in each example. The audit notes record known limitations without changing the existing algorithms.

Tutorials and quantitative model references

Browse the tutorial-first wiki to learn how to use AlgoQuant, then explore quantitative model implementations for reference, study, further research and actual application. Tutorial results are incidental and irrelevant to their teaching purpose. Execution records retain measured outputs, charts and diagnostics. Raw output archives are versioned as GitHub releases.

The manual Run model demos and prepare tutorials workflow compiles and runs demos without running the test suite. Technical examples use their documented synthetic --quick mode; other demos use their original defaults. Each page distinguishes completed calculations from failed, resource-limited or timed-out attempts. See runner setup and limits.

SMA2 web application

Choose a supported US stock, an inclusive backtesting period, and fast/slow SMA periods in trading days, such as 10 days and 30 days. Each new backtest simulates three independently funded accounts, each starting with $10,000:

Account Simulation
SMA2 Full-equity long/short moving-average crossover strategy
Underlying buy-and-hold Invest in fractional shares at the first selected adjusted close and hold
S&P 500 Independently buy and hold hypothetical fractional units of Yahoo ^GSPC over the requested period

The report compares 187 configured scalar performance results per account, including returns, drawdowns, volatility, risk-adjusted ratios, CAPM measures, exposures and trade statistics. Summary charts support hover/focus and legend toggles. Price/SMA and portfolio-history charts support zoom, pan and value inspection.

Every successful run has a saved, shareable URL. Reloading a saved report does not rerun the simulation.

Report exports

  • Excel: one workbook with SMA2 statistics, Buy and hold statistics, S&P 500 statistics, and Daily data tabs.
  • Daily data: date, adjusted_close, fast_sma, slow_sma, sma2_nav, fully_invested_buy_hold_nav, sp500_close, sp500_nav.
  • PDF: click Export to PDF, then choose Save as PDF in the browser print dialog. The print layout includes expanded statistics and charts.
  • CSV and JSON: SMA2 and underlying buy-and-hold performance CSVs, plus the complete saved report JSON. The API also offers an S&P 500 CSV.

Excel and webpage values display two decimal places. Excel numeric cells, CSVs and JSON retain full precision. Strategy statistics exports use AlgoQuant's PerformanceReportCsvExporter.

The S&P 500 benchmark is a price index without reinvested dividends. Stock adjusted prices may include dividend adjustments. The simulations assume zero trading, financing and short-borrow costs; results are educational rather than a representation of executable live performance. See simulation conventions.

Setup

Use JDK 8 and Maven 3.9.9.

Maven authentication

Merge this server entry into ~/.m2/settings.xml (Windows: %USERPROFILE%\.m2\settings.xml):

<settings>
    <servers>
        <server>
            <id>github-nm-packages</id>
            <username>YOUR_GITHUB_USERNAME</username>
            <password>YOUR_GITHUB_TOKEN</password>
        </server>
    </servers>
</settings>

Use your own GitHub personal access token (classic) with read:packages. The POM already configures the public distribution repository at https://maven.pkg.github.com/nmltd/maven-packages. GitHub Packages requires authentication even for these public Maven packages. No private source access or internal NM_REPOSITORIES_TOKEN is needed.

NM license

Put a valid license at license/nm.lic before building and running. A public starter trial license is available; the library enforces its validity and entitlements. Licenses are loaded externally and excluded from the examples JAR.

The web server and web tests also accept NM_LICENSE_FILE=/absolute/path/nm.lic. The six command-line demos use -Dnm.license=/absolute/path/nm.lic to override their default license path.

Build and run the web app

From the repository root:

mvn -U clean verify
java -Djava.awt.headless=true -Dlogback.configurationFile=web/logback.xml \
  -cp 'target/classes:target/lib/nmdev-dist-1.2.7.jar:target/lib/*' tech.nmfin.algoquant.web.ToolsWeb

Open http://localhost:8080/sma2/ for SMA2, or http://localhost:8080/ for the tools directory. The command above uses Unix classpath separators; use ; instead of : on Windows.

The web app downloads Yahoo data by default. For explicitly labeled offline verification, set SMA2_DATA_MODE=synthetic. There is no automatic synthetic fallback on download failure.

See the web README for environment variables, API routes, testing and deployment.

Performance Analyzer

Open Performance Analyzer or see its input format, assumptions and API. Supply a public Google Sheet or direct HTTPS CSV with Date followed by one or more NAV/price columns. An S&P 500 column is reused; otherwise Yahoo ^GSPC is downloaded and simulated. The report aligns common dates and rebases each account to 10,000 normalized units. It does not infer trades or remove deposits/withdrawals. Shared classes support both apps, including AlgoQuant statistics, snapshot storage, CSV/Excel exports and report components.

Six command-line technical examples

These examples retain their original package names under tech.nmfin.algoquant.demo.model.technical.

mvn exec:java
mvn exec:java -Dexec.mainClass=tech.nmfin.algoquant.demo.model.technical.ChaikinMoneyFlowDemo
mvn exec:java -Dexec.mainClass=tech.nmfin.algoquant.demo.model.technical.SMA2DynamicDemo -Dexec.args="--quick"

The default is SMA2Demo010.

Class Demonstrates
SMA2Demo010 Two moving-average crossover simulation
SMA2Demo011 Crossover simulation with currency conversion
SMA2Demo020 The simulation-template API
AccumulationDistributionLineDemo An ADL-based strategy
ChaikinMoneyFlowDemo A CMF-based strategy
SMA2DynamicDemo Periodic parameter calibration and CSV report export

Unlike the web app, all six demos default to deterministic synthetic OHLC/volume data from DemoSupport. Prices are keyed by calendar date, so calibration and main-simulation windows see consistent history. These results demonstrate APIs, not historical investment performance.

Options may be combined:

  • --charts: open desktop charts where a plotter is available; requires a graphical environment.
  • --live: download Yahoo historical data; requires network access and available symbol history.
  • --quick: limit dynamic calibration to one parameter combination over three months. The full run searches 16 combinations over several years.
mvn exec:java -Dexec.args="--charts"
mvn exec:java -Dexec.mainClass=tech.nmfin.algoquant.demo.model.technical.SMA2Demo011 -Dexec.args="--live --charts"

Live examples use META rather than the retired FB ticker and AAPL rather than the historical JWN example. The dynamic example creates fresh simulators and performance measures for each parameter combination. Dynamic CSV outputs are written under log/.

After building, run all six offline:

bash scripts/run-offline.sh

The script uses target/lib/, disables desktop charts and bounds each run to five minutes. CI also checks the web API, saved-report persistence, Excel/CSV values, Chrome interactions and PDF export, and the production container.

Repository layout

Location Purpose
Technical demos Six examples and DemoSupport
Shared web code Reusable BuyAndHoldBenchmark and AllPerformanceMeasures
SMA2 Java code App, HTTP server, saved-report storage and export adapters
SMA2 frontend HTML, JavaScript and styles
Shared web resources Tools-directory page and styles
Web tests Shared benchmark and SMA2 tests
Web operations Setup/deployment scripts, Dockerfile and browser/API checks
Tutorial documentation Guides, publication references and validation notes; generated results live in Wiki/Releases

New applications should have their own package and resource directory under web/<app>; reusable simulation/reporting code belongs directly under the shared web package.

Disclaimer

The tools homepage disclaimer covers all hosted tools, applications, data and outputs: educational/informational use, no warranties, use at your own risk and liability limits subject to applicable law and mandatory rights.

Further reading

AlgoQuant Javadoc · Minimal starter · Public distributions · Example results Wiki

The example sources retain their original copyright and license notices. The underlying AlgoQuant/NM Dev libraries require a valid NM license.

Complete demo collection

The remaining 57 Java demo/support files from nmltd/algoquant/demo are now alongside the existing technical examples under src/main/java/tech/nmfin/algoquant/demo. Their packages and class names are preserved. Configuration, the historical-data fixtures (about 334 MB) and IB container assets live at config/, test-data/ and ibdemo/, so relative data paths still work from this repository's root. The old private demo POM is superseded by this repository's standalone public-consumer POM.

Compile and package all examples without running tests:

mvn -B -ntp -Dmaven.test.skip=true clean package

Run a selected class from the repository root with your NM license on the classpath:

java -cp 'license:target/classes:target/lib/nmdev-dist-1.2.7.jar:target/lib/*' tech.nmfin.algoquant.demo.model.tutorial.TutorialStrategyDemo

The imported demos cover charts, historical data, IB execution, simulation, mean reversion, factor models, portfolio optimization and volatility arbitrage. Unlike the six synthetic technical demos, many need a desktop, network data, database access, custom file paths or a configured broker. Read each class before running it; do not run RunAllDemo as an offline smoke test.

See the migration record for provenance and validation.

Demonstration execution records

The maintained Wiki execution collection records 40 completed examples and one missing-data prerequisite for CSI300. Twelve repaired demos were rerun; older successful records retain their original provenance. See repair details and validation limits. Results are incidental to teaching AlgoQuant, rather than evidence for choosing an investment strategy.

Batch historical runs use the documented resource profile:

python3 scripts/run-model-demos.py --workers 1 --historical-resources

Prepare target/model-runner, target/classes, target/lib, an external license and a virtual display as shown in the manual demonstration workflow. The historical profile allows a 6 GB heap and 30 minutes for larger examples. Per-run outcomes, including caught calculation errors and missing inputs, remain in result.json.

About

Runnable AlgoQuant technical-analysis examples using the public obfuscated distribution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages