How to Build a Minimum Semivariance Portfolio: Tutorial
Minimum semivariance optimization asks a narrower question than the textbook mean-variance problem. Instead of penalizing every deviation from the mean, it penalizes only the deviations that fall below a target — the losses. A stock that swings +4% and −4% every other week and a stock that drifts quietly upward are treated very differently by a semivariance objective, even when their standard deviations look similar.
That distinction matters if you care about drawdowns more than about dispersion in general. This tutorial walks through building such a portfolio end to end in RSJ Portfolio, a Windows desktop application that computes a statistically optimized allocation from historic end-of-day prices. The application does the matrix work; the article is about the six decisions you make around it.
By the end you will have an allocation whose weights minimize semivariance over a chosen history, subject to the weight limits you set, exported and sanity-checked. If you want the total-volatility version of this exercise instead, it is covered separately in How to Calculate Minimum Variance Portfolio Weights; here we stay on the downside.
Prerequisites
- A Windows machine. RSJ Portfolio is a Windows desktop application; there is no browser or Linux build described in the product documentation.
- A data provider account, if your provider needs credentials. The supported providers are listed on the Data and currencies page, along with the price cleaning pipeline and the local cache behaviour.
- Enough price history. The optimizer needs a date range wide enough that the downside estimate is not driven by a handful of observations. Daily data over several years is the sane default.
- The installer, verified. Download it from the Downloads page — the SHA-512 digest is published there next to a versioned filename. Check it before running anything; the procedure is in How to Verify a SHA-512 Checksum Before Installing Portfolio Software.
- A candidate list. Either hand-picked or pre-filtered. If you want the pre-filtered route, see How to Screen Stocks for Low Correlation Automatically.
- A working knowledge of returns, risk and correlation. The concept chapter of the user guide is the reference for the statistical background.
Step-by-Step: Building the Portfolio
Step 1: Configure the data provider, cache, currency and date range
Everything downstream depends on this step. The Configuration screen is where you set the data provider, the local cache, your local currency, the date range and the price cleaning settings.
The cleaning pipeline is not optional decoration — splits, dividends and stale quotes will otherwise show up as fake returns and distort the semivariance estimate. Leave cleaning on unless you have a specific reason not to.
Write your choices down before you click, because you will want the same values for every comparison run later:
# Configuration worksheet - the values you enter on the Configuration screen.
# This is a checklist, not a file the application imports.
data_provider: "<the provider you have access to>"
local_currency: EUR # the currency your results should be quoted in
date_range:
start: 2019-01-01 # long enough to cover a real drawdown
end: 2026-10-30
price_cleaning: enabled # adjustments for splits and dividends
local_cache: enabled # reuse downloaded prices across runs
If your candidate list spans several markets, read the Data and currencies page before you continue — it documents the conversion path for portfolios quoted in more than one currency, and getting that wrong is a quiet way to produce a portfolio that looks fine and is not.
Step 2: Build the candidate list
Open Selection and search for symbols one at a time, adding each hit to the candidate list. Keep your intended universe in a plain text file so a second run — or a comparison against equal weight — uses the identical set:
# universe-2026-10.txt - search each symbol in Selection and add it
AAPL
MSFT
JNJ
XOM
PG
KO
UNH
CVX
Two practical notes.
First, the candidate list is a modelling decision. Semivariance rewards assets whose losses do not arrive at the same time as everyone else’s, so a list of ten nearly identical large-cap tech names gives the optimizer almost nothing to work with. That is why correlation screening before this step is worth the effort.
Second, do not silently change the universe between runs. If you drop a badly behaved stock and rerun, you will get a better-looking portfolio and learn nothing.
Step 3: Select minimum semivariance as the objective
In the Recommendation module, choose minimum semi variance as the optimization objective. The full set of objectives the application offers is minimum volatility, maximum Sharpe ratio, minimum semi variance, hierarchical risk parity and conditional value at risk (CVaR).
The objective defines what gets minimized: the dispersion of returns below your target, not the dispersion around the mean. Confirm the selection before moving on — it is easy to leave a previous run’s objective in place, and the resulting weights will look perfectly reasonable while answering the wrong question.
If you are weighing this against CVaR, which also targets the loss tail but asks a different question (average loss beyond a quantile rather than squared downside deviation), What Is Conditional Value at Risk in Portfolio Optimization? covers the distinction.
Step 4: Pick a risk model and set weight constraints
These are two separate settings and they fail in different ways.
Risk model. RSJ Portfolio ships eight risk models, including sample covariance and shrinkage estimators. The sample covariance estimator is the honest default when you have many observations per asset. Shrinkage estimators pull the estimate toward a structured target and tend to behave better when the candidate list is long relative to the length of the history — that is a numerical-stability choice, not a view about the market. The Methods and features page lists all eight, along with the return models and the available weight constraints.
Weight constraints. Set a maximum weight per asset that reflects what you are actually willing to hold. A cap is not a cosmetic preference: it is the difference between a portfolio you can implement and one that puts a third of the capital into whichever stock had the least correlated bad days.
Start with something you would defend in a conversation with a client, then tighten only if the unconstrained result is genuinely unholdable. Over-constrained runs are the most common cause of disappointing output.
Step 5: Run the optimizer
Trigger the run. The application computes the weights that minimize semivariance over your date range, subject to the objective, the risk model and the constraints you set. You do not write a solver loop, download price files by hand, or reconcile a covariance matrix — that is the part the application removes from the workflow.
When it finishes, the Recommendation screen shows the resulting allocation. Read the weights before you read anything else.
Step 6: Review the allocation and export it
Check three things in order:
- Do the weights sum to 1? They should, to within rounding.
- Is every weight inside your cap? Scan for the cap value; if it appears repeatedly, the constraint is doing real work, and you should ask whether the cap or the candidate list is the problem.
- Does the allocation match what you expected from the correlations? A stock you added specifically because it zigged when the rest zagged should carry weight. If it got zero, the optimizer disagreed with your intuition, and the correlation estimate is the place to look.
Then export the allocation. The export gives you the weights in a form you can drop into a trading system or a spreadsheet; keep the file, because the verification section below uses it.
Verifying Your Results
An optimizer will always return weights. Verification is how you find out whether they mean anything.
Check 1: The constraints held
This is a five-line check on the exported file. Adjust the cap to whatever you set in Step 4:
import pandas as pd
weights = pd.read_csv("allocation_2026-10-31.csv", index_col=0)["weight"]
print(weights.round(4).to_string())
print("max weight:", round(weights.max(), 4)) # must be <= your cap
print("sum: ", round(weights.sum(), 6)) # must be ~1.0
Check 2: Downside risk versus a naive benchmark
Compute the semi-deviation of your allocation and of an equal-weight portfolio over the same window and the same universe. If the optimized portfolio is not better on this measure, either the objective was not applied or the constraints have flattened the solution into something close to equal weight.
import numpy as np
import pandas as pd
prices = pd.read_csv("prices.csv", index_col=0, parse_dates=True).sort_index()
returns = prices.pct_change().dropna()
weights = pd.read_csv("allocation_2026-10-31.csv", index_col=0)["weight"]
weights = weights.reindex(returns.columns)
port = returns.mul(weights, axis=1).sum(axis=1)
target = 0.0 # "below zero" as the downside threshold
downside = np.minimum(port - target, 0.0)
semi_dev = np.sqrt((downside ** 2).mean())
print(f"semi-deviation per period: {semi_dev:.6f}")
print(f"annualized (252d): {semi_dev * np.sqrt(252):.6f}")
Run the same block with weights = pd.Series(1 / len(returns.columns), index=returns.columns) for the equal-weight comparison, and with the output of a minimum volatility run if you want the variance-versus-semivariance contrast on your own data.
Check 3: Out-of-sample behaviour
Re-run the optimization with an earlier end date, then evaluate the weights on the period after it. This is the cheapest available test of whether the allocation is capturing structure or fitting noise, and it is worth doing at least once before committing capital.
Troubleshooting Common Issues
The optimizer fails or returns something implausible. Relax the weight constraints first — a cap that is too tight for the number of assets can leave the problem with no comfortable solution. If that does not help, switch to a shrinkage risk model, which is more stable when the candidate list is long relative to the history.
Results are dominated by one or two names. Verify the objective is actually set to minimum semi variance and not to a leftover setting. Then look at the correlation matrix for near-duplicates in your candidate list; two 0.95-correlated stocks behave like one asset and the optimizer will treat them that way.
Weights look like equal weight. This usually means the constraints are binding everywhere, or the universe is too homogeneous for correlation to differentiate. Widen the candidate list before you loosen the caps.
Data gaps or stale prices. Check that the date range covers enough history, that the cleaning pipeline is enabled, and that the local cache holds a complete series for every symbol. A missing day is not a zero return.
Currency mismatches. If the portfolio spans several currencies, confirm the conversion path in the data settings before interpreting any weight. A portfolio quoted in the wrong base currency can rank assets in an order that has nothing to do with risk.
FAQ
What is the difference between minimum variance and minimum semivariance?
Minimum variance minimizes total volatility, treating upside and downside deviations alike. Minimum semivariance only penalizes negative deviations, so it focuses on downside risk. The two can produce materially different allocations, especially when return distributions are asymmetric.
Can I use RSJ Portfolio for other objectives like maximum Sharpe ratio?
Yes. RSJ Portfolio supports multiple objectives, including minimum volatility, maximum Sharpe ratio, minimum semi variance, hierarchical risk parity and conditional value at risk (CVaR). You select the objective per run, so comparing them on the same candidate list is a matter of repeating Steps 3 to 5.
How many risk models are available in RSJ Portfolio?
Eight, including sample covariance and shrinkage estimators. That lets you tailor the risk estimation to the length of your history and the size of your candidate list.
Is there a free trial of RSJ Portfolio?
The product information does not mention a free trial. Refer to the pricing page for licensing details; a single user license is available.
Conclusion
The sequence is short: configure the provider, currency and date range; build a candidate list that is not ten copies of the same trade; select minimum semi variance as the objective; choose a risk model and set caps you would defend; run it; then verify the weights against an equal-weight benchmark and on out-of-sample data. Most of the work is in steps 2 and 4, and most of the value is in the verification.
RSJ Portfolio handles the parts that usually eat the afternoon — price collection, cleaning, the local cache, the covariance estimate and the constrained solve — and leaves you the decisions. If you are ready to run it on your own universe, download the installer and the user guide from the Downloads page, and check the getting started guide for the settings worth fixing before the first run. Licensing is a single user license, purchased through the checkout on the pricing page.
Related posts
- Portfolio Optimization Software for Financial Advisors
- What Is Conditional Value at Risk in Portfolio Optimization?
- How to Verify a SHA-512 Checksum Before Installing Portfolio Software