Repository navigation
Model PortfolioOptimComparisons1Demo
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
This is a comparison of different allocation ideas, rather than an implementation of one paper. Markowitz (1952), Portfolio Selection, balances expected return against covariance-based risk. Black and Litterman (1992), Global Portfolio Optimization, combines an equilibrium starting point with investor views and uncertainty about those views.
Corvalán (2005), Well Diversified Efficient Portfolios, seeks diversification among nearly equivalent risk–return allocations. Lai, Xing and Chen (2011) address uncertainty in estimated means and covariances using predictive reasoning and resampling. These approaches answer different questions, so their risk parameters and assumptions are not directly interchangeable.
The demo's common synthetic return matrix makes computed weights comparable on that input; it does not establish an out-of-sample winner. Its Black–Litterman wrapper supplies equal market weights and sample means as views, rather than eliciting independent investor forecasts. The literature guide records the review scope for each reference; the Black–Litterman scan was inspected, but detailed derivations were not independently verified.
Compares multiple optimizer families on one synthetic return matrix. Black–Litterman combines equilibrium information with views. The wrapper assumes equal market weights, sample means as views and tau=1/T; this demo supplies risk aversion rather than explicit investor views. Other branches use Markowitz, Corvalán, smart-beta assumptions and Lai-style resampling. These are separate models, not interchangeable solver settings.
This demo shows how to build customized portfolio optimization algorithms and call these optimizers for the same data set.
AQ has a suite of tools to do asset allocation/portfolio optimization. It comes with out-of-box ready to use tools and users can also put together different models to customize their own optimizers. This demo shows a few simple out-of-box optimizers.
The simulated returns are from beta distribution and are correlated so the regular smart beta algorithms don't exhibit usual behaviors when uncorrelated normal distributions are assumed.
Using this example. Feeds the same generated return matrix to several optimizer implementations to compare their weights. Rows are observations and columns are assets; keep this order when wrapping a result in PortfolioWeights. This is a numerical comparison without a transaction-cost or execution simulation.
Model and publication. Related theory and the scope of this example are distinguished below.
Implementation in this tutorial. Compares multiple optimizer families on one synthetic return matrix. Black–Litterman combines equilibrium information with views. The wrapper assumes equal market weights, sample means as views and tau=1/T; this demo supplies risk aversion rather than explicit investor views. Other branches use Markowitz, Corvalán, smart-beta assumptions and Lai-style resampling. These are separate models, not interchangeable solver settings.
| Item | Value |
|---|---|
| Status | completed |
| Run | 39122217560 |
| UTC publication | 2026-10-18 11:43 UTC |
| Source commit | f497645628296f441e1e254127a7547d15106bbc |
| Data mode | original main defaults |
| Exit code | 0 |
| Elapsed seconds | 7.71 |
| Time limit seconds | 1800 |
| Maximum Java heap | 6g |
| AlgoQuant source commit | aba178deb0e78dc72184546a1e0934c3abce74a1 |
| NM Dev source commit | 04c12d1640fb700f52a2f7dc5cadf560040490e6 |
| Combined runtime SHA-256 | c1199a1c204cc4ffdf937b756bceacaf30bb64f35a844770490fea268742379b |
The original main returned successfully without a detected calculation error. Read its 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.portfoliooptimization.PortfolioOptimComparisons1DemoThe 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.
11:15:54.991 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - Markowitz model weights: [0.000000, 0.091766, 0.089007, 0.250419, 0.052848, 0.158530, 0.104201, 0.182553, 0.048576, 0.022100]
11:15:55.015 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - BlackLitterman model weights: [0.057903, 0.086740, 0.086342, 0.126650, 0.128685, 0.108934, 0.089547, 0.142704, 0.089683, 0.082813]
11:15:55.065 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - Corvalan2005 model weights: [0.118030, 0.102017, 0.067548, 0.120184, 0.089430, 0.097481, 0.103445, 0.118982, 0.094115, 0.088767]
11:15:55.150 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - SOCP model weights: [-0.001007, -0.002236, 0.003561, 0.003692, 0.007567, 0.006191, -0.000627, 0.000360, 0.005587, -0.000938]
11:15:55.195 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - EqualCor model weights: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000]
11:15:55.199 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - EqualMean model weights: [0.250000, 0.201146, 0.000000, 0.201146, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.093392]
11:15:55.299 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - EqualWeights model weights: [0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000]
optimal eta = 2.500000
11:15:56.272 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - SAAM model weights: [0.000000, 0.096615, 0.086594, 0.251677, 0.046686, 0.155084, 0.108279, 0.185712, 0.045388, 0.023967]
optimal eta = 3.500000
11:15:56.894 [main] INFO t.n.a.d.m.p.PortfolioOptimComparisons1Demo - CorvalanSAAM model weights: [0.079559, 0.090477, 0.081215, 0.115986, 0.064277, 0.181027, 0.109558, 0.100628, 0.083025, 0.094247]
Input asset-column indices; weights are fractions, not monetary P/L. Printed precision is retained.
Derived from stdout.log using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Input asset-column indices; weights are fractions, not monetary P/L. Printed precision is retained.
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 PortfolioOptimComparisons1Demo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.
| Export | Bytes |
|---|---|
files/derived-charts/charts.json |
1019 |
files/derived-charts/derived-01.csv |
2119 |
files/derived-charts/derived-01.png |
137932 |
files/derived-charts/derived-02.csv |
1064 |
files/derived-charts/derived-02.png |
85730 |
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.