Skip to content

Model Lai2010NPEBModelDemo

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

Lai2010NPEBModelDemo — quantitative model reference

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

Paper introduction

Tze Leung Lai, Haipeng Xing and Zehao Chen, Mean–variance portfolio optimization when means and covariances are unknown (2011) addresses a practical weakness of plug-in mean–variance optimization: historical estimates are uncertain, yet a naive optimizer treats them as known.

The paper formulates allocation using predictive return uncertainty and develops a nonparametric empirical Bayes (NPEB) approach with resampling. Conceptually, the investor should account for estimation risk when evaluating an allocation, rather than optimize once using a single estimated mean and covariance matrix. The method is compared with alternative allocation procedures in numerical and empirical examples.

Its conclusions depend on the statistical modeling and resampling design. The Java API retains Lai2010, but the cited journal paper is from 2011. Resampler selection, shrinkage, bootstrap count, risk preference and rebalancing are explicit demo choices, not interchangeable settings guaranteed to reproduce the article's tables. Sections 3–4 of the original text were reviewed.

How this demo connects to the idea

The active configuration uses Lai2010NPEBModel, a long-only MV optimizer, Ledoit–Wolf moments, an AR resampler, 100 bootstraps, lambda=1.4, a one-year calibration window and quarterly rebalancing. These choices adapt the framework; they do not reproduce all models or tables from the article. Follow the template’s data interval and rebalance strategy separately from the CSV exporters.

What this example teaches

Using this example. Exercises Lai portfolio optimization with Yahoo estimation data and writes performance and P/L CSV outputs under log. Resampling and optimization settings affect both runtime and the solution; inspect the estimation and evaluation intervals before interpreting the comparison.

Model and publication. Lai, Xing and Chen incorporate uncertainty in estimated moments into predictive portfolio risk and develop a nonparametric empirical-Bayes resampling rule. “2010” in the API is historical naming; the cited journal article appeared in 2011.

Implementation in this tutorial. The active configuration uses Lai2010NPEBModel, a long-only MV optimizer, Ledoit–Wolf moments, an AR resampler, 100 bootstraps, lambda=1.4, a one-year calibration window and quarterly rebalancing. These choices adapt the framework; they do not reproduce all models or tables from the article. Follow the template’s data interval and rebalance strategy separately from the CSV exporters.

Verified execution record

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 15.89
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.portfoliooptimization.Lai2010NPEBModelDemo

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


09:12:35.620 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:12:35.623 [main] INFO  t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:12:35.623 [main] INFO  t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/Lai2010NPEBModelDemo/work/config/config.default.xml


09:12:35.760 [main] INFO  t.n.algoquant.util.config.AQConfig,95 - current directory: /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/Lai2010NPEBModelDemo/work
09:12:35.761 [main] INFO  t.n.algoquant.util.config.AQConfig,169 - current config:
09:12:35.775 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - nm.license: /home/runner/work/algoquant-examples/algoquant-examples/license/nm.lic
09:12:35.775 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_FOLDER: ./test-data
09:12:35.776 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
09:12:35.776 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
09:12:35.776 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_YAHOO: ${DATA_FOLDER}/yahoo
09:12:35.777 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_SGX: ${DATA_FOLDER}/raw/sgx
09:12:35.777 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_HOLIDAYS: ./log/holidays
09:12:35.777 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/[database configuration redacted]/hk
09:12:35.778 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_OUTPUT_FOLDER: ./log/
09:12:35.778 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_WIDTH: 800
09:12:35.778 [main] INFO  t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_HEIGHT: 600
09:12:37.327 [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:37.327 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ORCL from the Internet from 2007-12-27T00:00 to 2013-01-01T16:00
09:12:37.476 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/ORCL.csv.zip
09:12:37.546 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/ORCL.csv.zip
09:12:37.555 [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:37.556 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AAPL from the Internet from 2007-12-27T00:00 to 2013-01-01T16:00
09:12:37.708 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/AAPL.csv.zip
09:12:37.765 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/AAPL.csv.zip
09:12:37.766 [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:37.767 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AMZN from the Internet from 2007-12-27T00:00 to 2013-01-01T16:00
09:12:37.875 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/AMZN.csv.zip
09:12:37.923 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/AMZN.csv.zip
09:12:37.924 [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:37.924 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for IBM from the Internet from 2007-12-27T00:00 to 2013-01-01T16:00
09:12:38.077 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/IBM.csv.zip
09:12:38.116 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/IBM.csv.zip
09:12:38.116 [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:38.116 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for MSFT from the Internet from 2007-12-27T00:00 to 2013-01-01T16:00
09:12:38.266 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/MSFT.csv.zip
09:12:38.289 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/MSFT.csv.zip
09:12:38.551 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2008-01-01T00:00
09:12:38.561 [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:38.561 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ORCL from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
09:12:38.868 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/20261018/ORCL.csv.zip
09:12:39.043 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/20261018/ORCL.csv.zip
09:12:39.067 [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:39.067 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AAPL from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
09:12:39.333 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/20261018/AAPL.csv.zip
09:12:39.530 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/20261018/AAPL.csv.zip
09:12:39.532 [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:39.532 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AMZN from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
09:12:39.812 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/20261018/AMZN.csv.zip
09:12:40.023 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/20261018/AMZN.csv.zip
09:12:40.028 [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:40.028 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for IBM from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
09:12:40.375 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/20261018/IBM.csv.zip
09:12:40.506 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/20261018/IBM.csv.zip
09:12:40.517 [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:40.518 [main] INFO  t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for MSFT from the Internet from 2000-01-01T00:00 to 2026-10-17T16:00
09:12:40.759 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/20261018/MSFT.csv.zip
09:12:40.822 [main] INFO  t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/20261018/MSFT.csv.zip
optimal eta = 2.100000
09:12:42.573 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2008-04-01T00:00
optimal eta = 4.300000
09:12:43.186 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2008-07-01T00:00
optimal eta = 1.300000
09:12:44.143 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2008-10-01T00:00
optimal eta = 1.000000
09:12:44.702 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2009-01-01T00:00
optimal eta = 1.000000
09:12:45.037 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2009-04-01T00:00
optimal eta = 1.000000
09:12:45.537 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2009-07-01T00:00
optimal eta = 1.100000
09:12:45.906 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2009-10-01T00:00
optimal eta = 1.500000
09:12:46.321 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2010-01-01T00:00
optimal eta = 1.800000
09:12:46.683 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2010-04-01T00:00
optimal eta = 1.700000
09:12:46.977 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2010-07-01T00:00
optimal eta = 1.600000
09:12:47.243 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2010-10-01T00:00
optimal eta = 1.300000
09:12:47.544 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2011-01-01T00:00
optimal eta = 1.300000
09:12:47.803 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2011-04-01T00:00
optimal eta = 1.300000
09:12:48.106 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2011-07-01T00:00
optimal eta = 1.400000
09:12:48.398 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2011-10-01T00:00
optimal eta = 1.200000
09:12:48.560 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2012-01-01T00:00
optimal eta = 8.800000
09:12:48.760 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2012-04-01T00:00
optimal eta = 1.200000
09:12:48.931 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2012-07-01T00:00
optimal eta = 1.400000
09:12:49.193 [main] INFO  t.n.a.m.s.r.RebalancePortfolio,173 - Calculating weights for rebalancing point at 2012-10-01T00:00
optimal eta = 4.700000

Charts from this run

CSV performance statistics (panel set 1)

One axis per measure; raw units and report definitions retained. Empty Product selects aggregate account rows.

Derived from files/log/lai2010NPEBModelDemo-performance.20080101-20130101.csv using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Chart 1

Reported P/L history

Source dates and raw P/L values are preserved; this is not reconstructed NAV or percentage return.

Derived from files/log/lai2010NPEBModelDemo-pnl.20080101-20130101.csv using the precision available in that file. Download plotted data. Undefined or malformed cells are omitted, never replaced by zero.

Chart 2

Downloadable evidence

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

Export Bytes
files/log/lai2010NPEBModelDemo-performance.20080101-20130101.csv 676
files/log/lai2010NPEBModelDemo-pnl.20080101-20130101.csv 157794
files/derived-charts/charts.json 1105
files/derived-charts/derived-01.csv 234
files/derived-charts/derived-01.png 112987
files/derived-charts/derived-02.csv 365964
files/derived-charts/derived-02.png 221383

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