Repository navigation
Model MarkowitzDemo
Wiki home · Quantitative model references · Execution records
This quantitative model reference is provided for study, further research and application within the AlgoQuant framework. Read the research idea and implementation choices separately from the execution record.
Tutorials and quantitative model references · Pinned source · Javadoc
Harry Markowitz, Portfolio Selection (1952) explains diversification as a portfolio problem: an asset's risk cannot be judged independently of how its returns move with the other holdings. Expected portfolio return is a weighted mean; portfolio variance depends on the full covariance matrix.
The efficient set contains portfolios for which expected return cannot be improved without accepting more variance, or variance reduced without giving up expected return. An investor selects a tradeoff according to preferences and constraints. Holding many positively correlated assets need not provide much diversification.
The framework assumes the relevant return means and covariances are supplied. In practice, estimates can be unstable and constraints can materially change the answer. A solved optimization is therefore a set of weights under assumptions, not evidence of future outperformance. The original article was reviewed. Rolling calibration, rebalance schedules, costs and the dataset used here belong to the demo, not to the static 1952 formulation.
Trades off expected return against covariance-based portfolio risk. The historical optimizer example estimates inputs from Yahoo observations, chooses a risk parameter and computes weights. Mean estimates and covariance uncertainty are not eliminated by solving the quadratic program.
Using this example. Builds a Markowitz allocation from Yahoo history and the risk parameter in main. Asset ordering in the return matrix must match the products associated with the resulting weights. The optimizer computes weights; converting them to executable trades is a separate step.
Model and publication. Related theory and the scope of this example are distinguished below.
Implementation in this tutorial. Trades off expected return against covariance-based portfolio risk. The historical optimizer example estimates inputs from Yahoo observations, chooses a risk parameter and computes weights. Mean estimates and covariance uncertainty are not eliminated by solving the quadratic program.
| 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 | 18.24 |
| 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.MarkowitzDemoThe 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:16:21.332 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - looking up configuration file: config.default.xml
11:16:21.335 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - looking up configuration file: config/config.default.xml
11:16:21.336 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - loading config file: file:/home/runner/work/algoquant/algoquant/target/model-results/MarkowitzDemo/work/config/config.default.xml
11:16:21.603 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - current directory: /home/runner/work/algoquant/algoquant/target/model-results/MarkowitzDemo/work
11:16:21.603 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - current config:
11:16:21.616 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - logback.configurationFile: /home/runner/work/algoquant/algoquant/config/model-demo-logback.xml
11:16:21.616 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - nm.license: /home/runner/work/algoquant/algoquant/license/nm.lic
11:16:21.617 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_FOLDER: ./test-data
11:16:21.617 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
11:16:21.617 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
11:16:21.617 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_YAHOO: ${DATA_FOLDER}/yahoo
11:16:21.618 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_SGX: ${DATA_FOLDER}/raw/sgx
11:16:21.618 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_HOLIDAYS: ./log/holidays
11:16:21.618 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/compustat/hk
11:16:21.618 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - PDF_OUTPUT_FOLDER: ./log/
11:16:21.619 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - PDF_PLOT_WIDTH: 800
11:16:21.619 [main] INFO tech.nmfin.algoquant.util.config.AQConfig - PDF_PLOT_HEIGHT: 600
11:16:23.033 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:23.034 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0019.HK from the Internet from 2005-05-31T00:00 to 2011-10-01T16:00
11:16:23.146 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/0019.HK.csv.zip
11:16:23.185 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/0019.HK.csv.zip
11:16:23.188 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:23.188 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0483.HK from the Internet from 2005-05-31T00:00 to 2011-10-01T16:00
11:16:23.310 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/0483.HK.csv.zip
11:16:23.326 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/0483.HK.csv.zip
11:16:23.326 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:23.326 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0321.HK from the Internet from 2005-05-31T00:00 to 2011-10-01T16:00
11:16:23.428 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/0321.HK.csv.zip
11:16:23.450 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/0321.HK.csv.zip
11:16:23.450 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:23.450 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0001.HK from the Internet from 2005-05-31T00:00 to 2011-10-01T16:00
11:16:23.556 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/0001.HK.csv.zip
11:16:23.581 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/0001.HK.csv.zip
11:16:23.690 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2005-06-01T00:00
11:16:23.692 [main] INFO t.n.a.m.s.rebalance.RebalancePortfolioTechnical - Rebalance deferred: calibration data are not yet available at 2005-06-01T00:00
11:16:23.725 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2005-09-01T00:00
11:16:23.725 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:23.725 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0019.HK from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
11:16:23.924 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/20261018/0019.HK.csv.zip
11:16:24.002 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/20261018/0019.HK.csv.zip
11:16:24.011 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:24.011 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0483.HK from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
11:16:24.141 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/20261018/0483.HK.csv.zip
11:16:24.198 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/20261018/0483.HK.csv.zip
11:16:24.198 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:24.198 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0321.HK from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
11:16:24.349 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/20261018/0321.HK.csv.zip
11:16:24.408 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/20261018/0321.HK.csv.zip
11:16:24.409 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - failed to load from file, reason: no data read from file; load from web
11:16:24.409 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory - reading Yahoo! data for 0001.HK from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
11:16:24.569 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - writing csv.zip file ./log/Yahoo/20261018/0001.HK.csv.zip
11:16:24.611 [main] INFO t.n.a.d.h.yahoo.YahooEODCsvZipFileWriter - finished writing ./log/Yahoo/20261018/0001.HK.csv.zip
11:16:24.626 [main] INFO t.n.a.m.s.rebalance.RebalancePortfolioTechnical - products with not enough data (1): [0483.HK @ HKEX]
11:16:24.930 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2005-12-01T00:00
11:16:24.942 [main] INFO t.n.a.m.s.rebalance.RebalancePortfolioTechnical - products with not enough data (1): [0483.HK @ HKEX]
11:16:25.001 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2006-03-01T00:00
11:16:25.006 [main] INFO t.n.a.m.s.rebalance.RebalancePortfolioTechnical - products with not enough data (1): [0483.HK @ HKEX]
11:16:25.045 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2006-06-01T00:00
11:16:25.111 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2006-09-01T00:00
11:16:25.174 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2006-12-01T00:00
11:16:26.586 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2007-03-01T00:00
11:16:27.483 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2007-06-01T00:00
11:16:28.619 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2007-09-01T00:00
11:16:28.643 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2007-12-01T00:00
11:16:28.664 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2008-03-01T00:00
11:16:29.179 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2008-06-01T00:00
11:16:29.203 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2008-09-01T00:00
11:16:29.229 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2008-12-01T00:00
11:16:30.178 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2009-03-01T00:00
11:16:31.096 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2009-06-01T00:00
11:16:31.813 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2009-09-01T00:00
11:16:32.567 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2009-12-01T00:00
11:16:32.589 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2010-03-01T00:00
11:16:33.216 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2010-06-01T00:00
11:16:33.241 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2010-09-01T00:00
11:16:33.259 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2010-12-01T00:00
11:16:33.279 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2011-03-01T00:00
11:16:33.303 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2011-06-01T00:00
11:16:33.870 [main] INFO t.n.a.m.strategy.rebalance.RebalancePortfolio - Calculating weights for rebalancing point at 2011-09-01T00:00
11:16:34.035 [main] INFO t.n.a.d.m.portfoliooptimization.MarkowitzDemo - report = Performance Report:
Product Profit Loss Commission Information Ratio For Periods Max Drawdown Percentage Execution Count
0001.HK -49469.94618803053 37763.398747515515 -0.27113608687750196 0.44735270003658223 25.0
0019.HK 85513.25175963785 32212.059084052602 -0.08640129268268171 0.19488395287097005 25.0
0321.HK -598003.7301448649 64064.450465666174 0.019364667546052 0.9187222683546182 25.0
0483.HK 2876046.5190035393 77452.53536487158 0.7973271955769085 0.38842197970146586 22.0
Total 2314086.0944302813 211492.44366210588 0.6881394856982572 0.5794598662579848 97.0
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.

Download MarkowitzDemo.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 |
1115 |
files/derived-charts/derived-01.png |
136078 |
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.