Repository navigation
Model Corvalan2005Demo
All model results · Pinned source · Javadoc
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 | 39114006111 |
| UTC publication | 2026-10-18 09:11 UTC |
| Source commit | 0097e73c040bdaaddac570e2fe694d9836b676ee |
| Data mode | original main defaults |
| Exit code | 0 |
| Elapsed seconds | 2.58 |
| 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:07:55,446 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:07:55,446 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:07:55,447 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/home/runner/work/algoquant-examples/algoquant-examples/target/lib/algoquant-dist-3.3.0-SNAPSHOT.jar!/logback.xml]
09:07:55,458 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@2d3fcdbd - URL [jar:file:/home/runner/work/algoquant-examples/algoquant-examples/target/lib/algoquant-dist-3.3.0-SNAPSHOT.jar!/logback.xml] is not of type file
09:07:55,483 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:07:55,483 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:07:55,488 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:07:55,492 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:07:55,515 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
09:07:55,516 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="2026.10.18,09.07.55" to the LOCAL scope
09:07:55,516 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
09:07:55,518 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE1]
09:07:55,522 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@617c74e5 - Will use zip compression
09:07:55,523 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@617c74e5 - Large window sizes are not allowed.
09:07:55,523 |-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@617c74e5 - MaxIndex reduced to 21
09:07:55,525 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:07:55,525 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - Active log file name: log/algoquant.2026.10.18,09.07.55.log
09:07:55,525 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE1] - File property is set to [log/algoquant.2026.10.18,09.07.55.log]
09:07:55,526 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
09:07:55,526 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
09:07:55,526 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE1] to Logger[ROOT]
09:07:55,526 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:07:55,527 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@6537cf78 - Registering current configuration as safe fallback point
09:07:55.551 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config.default.xml
09:07:55.553 [main] INFO t.n.algoquant.util.config.AQConfig,194 - looking up configuration file: config/config.default.xml
09:07:55.553 [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:07:55.642 [main] INFO t.n.algoquant.util.config.AQConfig,148 - 09:07:55,446 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:07:55,446 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:07:55,447 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/home/runner/work/algoquant-examples/algoquant-examples/target/lib/algoquant-dist-3.3.0-SNAPSHOT.jar!/logback.xml]
... excerpt shortened; complete stdout is in the release archive ...
[191,] 0.028181, 0.015319, 0.032410, 0.012003, 0.021473,
[192,] 0.018799, -0.002329, 0.009115, 0.027000, 0.017232,
[193,] -0.003338, -0.020263, 0.014477, 0.003845, -0.003423,
[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.015397, -0.002791, 0.003754, 0.008127,
[198,] 0.022544, 0.032685, 0.043746, 0.019664, 0.003305,
[199,] -0.019658, -0.004775, -0.017913, -0.020896, -0.010691,
[200,] 0.020600, 0.005343, 0.006376, -0.042087, 0.012157,
[201,] -0.012309, -0.057565, -0.051967, -0.008476, -0.006613,
[202,] 0.001270, -0.008338, 0.008944, -0.000789, -0.003323,
[203,] 0.018539, -0.006192, 0.004996, 0.024410, 0.004428,
[204,] 0.023082, 0.032308, 0.011982, 0.003408, 0.001104,
[205,] -0.015328, -0.019913, -0.045020, -0.010425, -0.014074,
[206,] 0.000927, 0.007090, -0.135325, 0.008887, -0.008240,
[207,] 0.038151, 0.010158, 0.041370, 0.021260, 0.024519,
[208,] 0.000891, 0.000642, 0.049716, 0.008411, -0.009958,
[209,] -0.027688, -0.000420, -0.017687, -0.015159, -0.013058,
[210,] -0.033512, -0.020643, -0.006626, -0.017925, -0.024326,
[211,] 0.018446, 0.002267, 0.016460, 0.014072, 0.000769,
[212,] 0.025388, 0.014142, 0.012307, 0.018211, 0.019795,
[213,] -0.017058, -0.007046, -0.008326, -0.004924, -0.010610,
[214,] 0.009783, -0.001275, 0.002399, 0.005031, 0.020736,
[215,] 0.022263, 0.016130, 0.004552, 0.003638, 0.013344,
[216,] -0.061983, -0.027325, -0.031549, -0.027120, -0.035986,
[217,] 0.004422, -0.025780, -0.002038, 0.006072, 0.003049,
[218,] 0.019969, -0.001559, 0.030831, 0.021742, 0.023689,
[219,] -0.002165, -0.014034, 0.007059, -0.000160, -0.005589,
[220,] 0.020227, 0.024920, -0.005037, 0.007445, 0.006754,
[221,] -0.029871, -0.010496, -0.027176, -0.011349, -0.025375,
[222,] -0.037260, -0.019314, -0.035873, -0.004780, -0.020540,
[223,] -0.007164, -0.006566, -0.036752, -0.002642, -0.009441,
[224,] -0.022807, -0.015942, -0.040845, -0.020507, -0.011929,
[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.033937, 0.062429, 0.028672, 0.023186,
[229,] -0.004362, -0.007794, -0.030117, -0.006995, -0.001207,
[230,] 0.052721, 0.023829, 0.020490, 0.038277, 0.029356,
[231,] 0.010156, 0.014881, 0.024859, 0.007683, -0.011797,
[232,] -0.014952, 0.004552, -0.005596, 0.001108, -0.002377,
[233,] 0.022188, 0.008458, 0.001071, 0.006202, 0.018854,
[234,] -0.005343, -0.005255, -0.021895, 0.010944, -0.001558,
[235,] -0.006006, -0.004769, 0.017196, 0.005737, -0.002341,
[236,] -0.025692, 0.004027, -0.025092, -0.012810, -0.007843,
[237,] 0.030437, 0.007548, 0.013298, 0.015435, 0.011742,
[238,] -0.011744, -0.004533, -0.018351, -0.012308, -0.007420,
[239,] -0.015769, -0.007763, -0.048708, -0.005374, 0.009752,
[240,] -0.031633, -0.022419, -0.001663, -0.012794, -0.006621,
[241,] -0.028525, -0.003294, 0.005810, -0.006592, -0.001173,
[242,] 0.006181, 0.005474, 0.000000, -0.021076, 0.017067,
[243,] -0.020755, 0.003118, -0.010705, -0.003711, -0.018242,
[244,] 0.019384, 0.035317, 0.017632, 0.023506, 0.019396,
[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.011832, 0.007716,
[251,] -0.005831, -0.000297, -0.004381, -0.012431, -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.047546]
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.26789891553214107
returns(diversified): 0.24128221313132098
sigma(optimal): 0.014136390332510776
sigma(diversified): 0.013843455839212726
ir(optimal): 0.06689556973998209
ir(diversified): 0.06129858643965346
Download Corvalan2005Demo.zip contains stdout, stderr, the execution record, checksums and any exported CSV/chart files.
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.