Repository navigation
Model Corvalan2005Demo
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
Alejandro Corvalán, Well Diversified Efficient Portfolios (Central Bank of Chile Working Paper 336, 2005) asks why mean–variance portfolios can concentrate in a few assets even when investors want diversification.
The paper argues that treating estimated risk and return as infinitely precise forces an unnecessarily exact choice on the efficient frontier. Allowing a small tolerance around an efficient risk–return point admits many nearly equivalent allocations. A second optimization can then favor diversification within that neighborhood.
The lesson is to separate the selection of a risk–return target from the choice among near-equivalent portfolios. Relaxing the target changes the feasible set; it does not magically improve the estimates. This demo exposes relative return/volatility relaxation parameters and a diversification measure. Their normalization must be read from the library rather than copied directly from a paper tolerance. The original working paper and its two-stage formulation were reviewed; an accessible original PDF is also available.
Corvalan2005 in this example exposes the relaxation settings and chosen diversification measure through library classes. Its documented constraints use relative return/volatility relaxations; check that parameterization rather than substituting a tolerance directly from the paper. Weights, estimated risk and forecast return are optimizer outputs, not a realized account-performance report.
This paper tackles the corner solution problem of many portfolio
optimizers, by optimizing the portfolio diversification with some relaxation
on the volatility σ and the expected return R of a given
optimized (but non-diversified) portfolio. This implementation generalizes
this framework as the following optimization problem: [ \max_{w} D(w) \quad
\text{s.t.} \ \begin{aligned} \sqrt{w' \Sigma w} & \le \sigma^* (1 + \Delta
\sigma) \ R^* (1 - \Delta R) & \le w'r \ w' 1 & = 1 \ ... & \text{some
extra constraints} \end{aligned} ] where ( ( \sigma^* , R^* ) = (
\sqrt{w^{'} \Sigma w^} , w^{'} r ) ), (w^) is the original optimal
weights, (\Delta \sigma, \Delta R) are the relaxation tolerance parameters,
and (D(w)) is a defined measure for portfolio diversification
(DiversificationMeasure).
Using this example. Applies portfolio diversification with return and volatility relaxation around an optimized portfolio. The Yahoo sample supplies estimation data; tolerance parameters alter the feasible portfolio set. The reported weights are allocations, not share quantities or realized backtest returns.
Model and publication. Corvalán proposes two stages: find a mean–variance reference portfolio, then improve diversification while allowing a neighborhood of return/risk deviations. The paper discusses multiple diversification measures.
Implementation in this tutorial. Corvalan2005 in this example exposes the relaxation settings and chosen diversification measure through library classes. Its documented constraints use relative return/volatility relaxations; check that parameterization rather than substituting a tolerance directly from the paper. Weights, estimated risk and forecast return are optimizer outputs, not a realized account-performance report.
| 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 | 3.03 |
| 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.portfoliooptimization.Corvalan2005DemoThe 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:14:12.815 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:14:12.817 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:14:12.818 [main] INFO t.n.algoquant.util.config.AQConfig,209 - loading config file: file:/home/runner/work/algoquant-examples/algoquant-examples/target/model-results/Corvalan2005Demo/work/config/config.default.xml
09:14:12.933 [main] INFO t.n.algoquant.util.config.AQConfig,95 - current directory: /home/runner/work/algoquant-examples/algoquant-examples/target/model-results/Corvalan2005Demo/work
09:14:12.933 [main] INFO t.n.algoquant.util.config.AQConfig,169 - current config:
09:14:12.944 [main] INFO t.n.algoquant.util.config.AQConfig,11 - nm.license: /home/runner/work/algoquant-examples/algoquant-examples/license/nm.lic
09:14:12.945 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_FOLDER: ./test-data
09:14:12.945 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_GAINCAPITAL: ${DATA_FOLDER}/processed/gaincapital/extracted-from-raw-arrange-by-dates
09:14:12.946 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_BLOOMBERG: ${DATA_FOLDER}/processed/bloomberg
09:14:12.946 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_YAHOO: ${DATA_FOLDER}/yahoo
09:14:12.946 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_SGX: ${DATA_FOLDER}/raw/sgx
09:14:12.946 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_HOLIDAYS: ./log/holidays
09:14:12.947 [main] INFO t.n.algoquant.util.config.AQConfig,11 - DATA_COMPUSTAT_HK: ${DATA_FOLDER}/[database configuration redacted]/hk
09:14:12.947 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_OUTPUT_FOLDER: ./log/
09:14:12.947 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_WIDTH: 800
09:14:12.948 [main] INFO t.n.algoquant.util.config.AQConfig,11 - PDF_PLOT_HEIGHT: 600
09:14:14.375 [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:14:14.376 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for ORCL from the Internet from 2011-01-01T00:00 to 2012-01-01T16:00
09:14:14.519 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/ORCL.csv.zip
09:14:14.528 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/ORCL.csv.zip
09:14:14.530 [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:14:14.531 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AAPL from the Internet from 2011-01-01T00:00 to 2012-01-01T16:00
09:14:14.691 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/AAPL.csv.zip
09:14:14.696 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,81 - finished writing ./log/Yahoo/AAPL.csv.zip
09:14:14.696 [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:14:14.696 [main] INFO t.n.a.d.h.yahoo.YahooEODCacheFactory,196 - reading Yahoo! data for AMZN from the Internet from 2011-01-01T00:00 to 2012-01-01T16:00
09:14:14.839 [main] INFO t.n.a.d.h.y.YahooEODCsvZipFileWriter,30 - writing csv.zip file ./log/Yahoo/AMZN.csv.zip
... excerpt shortened; complete stdout is in the release archive ...
[191,] 0.028180, 0.015318, 0.032410, 0.012003, 0.021473,
[192,] 0.018799, -0.002329, 0.009115, 0.027000, 0.017232,
[193,] -0.003338, -0.020264, 0.014477, 0.003845, -0.003422,
[194,] 0.034826, 0.050128, 0.028858, 0.022927, 0.025946,
[195,] -0.001292, 0.029099, 0.017824, -0.008719, 0.002225,
[196,] 0.005803, 0.004735, 0.005632, 0.006036, -0.001483,
[197,] 0.000964, 0.015396, -0.002791, 0.003754, 0.008127,
[198,] 0.022544, 0.032685, 0.043746, 0.019664, 0.003306,
[199,] -0.019658, -0.004774, -0.017913, -0.020897, -0.010691,
[200,] 0.020600, 0.005343, 0.006376, -0.042086, 0.012157,
[201,] -0.012309, -0.057565, -0.051967, -0.008477, -0.006613,
[202,] 0.001270, -0.008339, 0.008944, -0.000790, -0.003322,
[203,] 0.018539, -0.006191, 0.004996, 0.024411, 0.004428,
[204,] 0.023082, 0.032308, 0.011982, 0.003407, 0.001104,
[205,] -0.015328, -0.019913, -0.045020, -0.010424, -0.014074,
[206,] 0.000926, 0.007089, -0.135325, 0.008887, -0.008240,
[207,] 0.038151, 0.010158, 0.041370, 0.021259, 0.024519,
[208,] 0.000891, 0.000642, 0.049716, 0.008411, -0.009958,
[209,] -0.027687, -0.000420, -0.017687, -0.015158, -0.013058,
[210,] -0.033512, -0.020642, -0.006626, -0.017925, -0.024327,
[211,] 0.018446, 0.002267, 0.016460, 0.014072, 0.000770,
[212,] 0.025388, 0.014141, 0.012307, 0.018210, 0.019795,
[213,] -0.017058, -0.007045, -0.008326, -0.004924, -0.010610,
[214,] 0.009783, -0.001275, 0.002399, 0.005030, 0.020736,
[215,] 0.022263, 0.016130, 0.004552, 0.003638, 0.013343,
[216,] -0.061983, -0.027325, -0.031549, -0.027120, -0.035986,
[217,] 0.004422, -0.025780, -0.002038, 0.006073, 0.003049,
[218,] 0.019970, -0.001558, 0.030831, 0.021742, 0.023690,
[219,] -0.002165, -0.014034, 0.007059, -0.000160, -0.005590,
[220,] 0.020227, 0.024921, -0.005037, 0.007445, 0.006754,
[221,] -0.029871, -0.010497, -0.027176, -0.011349, -0.025375,
[222,] -0.037259, -0.019314, -0.035873, -0.004781, -0.020540,
[223,] -0.007164, -0.006566, -0.036752, -0.002642, -0.009442,
[224,] -0.022807, -0.015942, -0.040845, -0.020507, -0.011928,
[225,] -0.003349, 0.020121, 0.016196, -0.000937, -0.008435,
[226,] -0.027548, -0.025610, -0.017570, -0.018706, -0.012993,
[227,] -0.009006, -0.009363, -0.035492, -0.005014, -0.006972,
[228,] 0.038565, 0.033936, 0.062429, 0.028671, 0.023186,
[229,] -0.004362, -0.007794, -0.030117, -0.006994, -0.001207,
[230,] 0.052721, 0.023830, 0.020490, 0.038276, 0.029356,
[231,] 0.010156, 0.014881, 0.024859, 0.007683, -0.011798,
[232,] -0.014952, 0.004552, -0.005596, 0.001108, -0.002376,
[233,] 0.022188, 0.008458, 0.001071, 0.006202, 0.018853,
[234,] -0.005344, -0.005255, -0.021895, 0.010944, -0.001557,
[235,] -0.006006, -0.004768, 0.017196, 0.005736, -0.002341,
[236,] -0.025692, 0.004027, -0.025092, -0.012810, -0.007843,
[237,] 0.030436, 0.007548, 0.013298, 0.015435, 0.011742,
[238,] -0.011744, -0.004532, -0.018351, -0.012308, -0.007420,
[239,] -0.015769, -0.007763, -0.048708, -0.005374, 0.009752,
[240,] -0.031634, -0.022420, -0.001663, -0.012794, -0.006621,
[241,] -0.028525, -0.003293, 0.005810, -0.006592, -0.001174,
[242,] 0.006181, 0.005474, 0.000000, -0.021076, 0.017068,
[243,] -0.020754, 0.003118, -0.010705, -0.003711, -0.018242,
[244,] 0.019384, 0.035317, 0.017632, 0.023506, 0.019395,
[245,] -0.123930, 0.001262, -0.045795, -0.031301, -0.010427,
[246,] -0.003109, 0.005283, 0.026489, 0.003136, 0.001939,
[247,] 0.014300, 0.011922, -0.009823, 0.014777, 0.008488,
[248,] -0.016638, 0.007903, -0.005713, 0.001082, 0.000384,
[249,] -0.004693, -0.009615, -0.013594, -0.005204, -0.008485,
[250,] 0.011304, 0.006141, -0.000173, 0.011833, 0.007716,
[251,] -0.005831, -0.000296, -0.004381, -0.012430, -0.002309,
covariance matrix (sigma): 5x5
[,1] [,2] [,3] [,4] [,5]
[1,] 0.000515, 0.000224, 0.000330, 0.000200, 0.000207,
[2,] 0.000224, 0.000273, 0.000237, 0.000139, 0.000146,
[3,] 0.000330, 0.000237, 0.000592, 0.000204, 0.000214,
[4,] 0.000200, 0.000139, 0.000204, 0.000200, 0.000129,
[5,] 0.000207, 0.000146, 0.000214, 0.000129, 0.000220,
avg. returns (mu): [-0.000805, 0.000821, -0.000248, 0.000946, -0.000194]
period returns (R): [-0.182974, 0.228874, -0.060363, 0.267899, -0.047545]
optimal weights: [0.000000, 0.000000, 0.000000, 1.000000, 0.000000]
diversified weights: [0.017686, 0.065403, 0.029497, 0.867102, 0.020312]
diversification(optimal): 0.0
diversification(diversified): 6.009457294425512E-7
returns(optimal): 0.2678994803003214
returns(diversified): 0.2412827487680006
sigma(optimal): 0.014136364116983194
sigma(diversified): 0.013843432800963297
ir(optimal): 0.06689581933377974
ir(diversified): 0.0612988083569351
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 Corvalan2005Demo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.
| Export | Bytes |
|---|---|
files/derived-charts/charts.json |
497 |
files/derived-charts/derived-01.csv |
301 |
files/derived-charts/derived-01.png |
56146 |
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.