RSJ Portfolio Portfolio Optimization

← All posts

2026-10-02

How to Import End-of-Day Stock Prices Into a Portfolio Optimizer

How to Import End-of-Day Stock Prices Into a Portfolio Optimizer
portfolio optimization modern portfolio theory portfolio correlation portfolio optimization hierachical risk parity minimize volatility minimize semivariance maximize sharpe

How to Import End-of-Day Stock Prices Into a Portfolio Optimizer

You have a list of tickers. You want the optimizer to turn that list into a portfolio that doesn’t move as one block. Before any of that can happen, one unglamorous task has to be done properly: getting reliable end-of-day (EOD) price history into the tool, in a shape it can actually consume.

Most home-grown setups break here, not at the optimization step. A price matrix stitched together from a few sources usually has split artifacts, a currency column that quietly mixes EUR and USD, and a handful of symbols with gaps exactly where the tempting drawdowns are. The optimizer doesn’t complain — it just returns weights based on bad inputs.

The goal of this walkthrough is a clean, analysis-ready price matrix: one row per trading day, one column per symbol, corporate actions already adjusted, cached locally, and ready to feed an allocation step that spreads capital across weakly correlated stocks.

RSJ Portfolio is a Windows desktop application that handles the import and cleaning pipeline end to end, so you can spend your attention on allocation decisions rather than on data plumbing. This guide follows its managed workflow, not raw API scripting. You can write a provider client and assemble the matrix yourself — that’s the hard way, and it’s a different article.

Prerequisites

Before you start, make sure you have:

  • A Windows environment. RSJ Portfolio is a Windows desktop application.
  • A candidate list of symbols. Even a rough one — 10 to 40 tickers is enough to begin. You’ll refine it in the Selection view.
  • Access to a supported data provider. The product supports multiple providers; the current list lives on the Data and currencies page.
  • RSJ Portfolio installed and licensed. Installation steps and what the license covers are in the installation chapter of the user guide and on the downloads page, where the Windows installer is published with a versioned filename and its SHA-512 hash.
  • A basic grasp of the output you’re aiming for. If correlation and volatility are fuzzy concepts for you, read Correlation and Volatility: A Long-Term Investor’s Guide first. If you already know you want the lowest-variance portfolio and not the best risk-adjusted return, Minimum Volatility vs Maximum Sharpe Ratio will save you a re-run later.

Optional but useful: keep your tickers in a plain text file so your candidate list is reproducible across sessions.

# candidates.txt
AAPL
MSFT
JNJ
PG
KO
NESN.SW
SAP.DE
...

That file is for you, not for the app — the app has its own selection workflow — but it keeps the universe stable when you compare two optimization runs.

Step-by-Step: Importing End-of-Day Prices with RSJ Portfolio

Step 1 — Configure the data provider and local currency

Open the Configuration section and set the data provider and your local currency. This is the step people skip, and it’s the one that produces the strange results later. The local currency setting determines the base your portfolio is expressed in; RSJ Portfolio supports portfolios quoted in several currencies and includes a conversion path for them.

The configuration chapter of the guide (Configuration) documents the data provider, cache, local currency, date range and cleaning settings in detail.

Step 2 — Set the date range

Choose the historical window for the EOD prices you need. Two practical notes:

  • Longer windows give the correlation estimates more to work with, but they also mix market regimes. For a first run, the Getting started page lists recommended starting parameters — use those before you tune anything.
  • The range must contain actual trading days for every symbol you select. A range that starts on a market holiday for half your universe is a common source of “missing data” complaints.

Step 3 — Build your candidate list

Switch to the Selection view and search for symbols one by one, adding each to the candidate list. The selection chapter covers symbol search and list building.

Keep the list slightly larger than the number of positions you want in the final portfolio. The optimizer’s job is to choose — if you pre-select ten names and ask for ten positions, you’ve replaced the statistics with your own judgment.

Step 4 — Run the import

Start the import. RSJ Portfolio fetches the EOD series and runs them through its price cleaning pipeline, which adjusts for corporate actions such as splits and dividends and handles missing values. The cleaned data is stored in a local cache, so subsequent runs and re-optimizations don’t have to refetch everything.

This is the part that replaces most of a hand-rolled ingestion script — no per-provider parsing, no manual split adjustment, no bespoke gap-filling logic.

Step 5 — Verify the imported data

Before optimizing anything, look at what arrived. The app shows price series and summary statistics. Check that:

  • The date range matches what you configured.
  • The number of symbols matches your candidate list.
  • The price charts look like the instruments you expect — no factor-of-ten jumps, no flat lines through a period when the stock clearly traded.

If something looks wrong here, fix it here. Downstream, a bad column is invisible.

Step 6 — Choose the objective and risk model

Now pick how the allocation should be computed. The selectable objectives include:

  • Minimum volatility
  • Maximum Sharpe ratio
  • Minimum semi variance (downside risk)
  • Hierarchical risk parity
  • Conditional value at risk

Alongside the objective you select a risk estimator — the product ships eight risk models — plus return models and weight constraints. If you’re new to hierarchical risk parity, the plain-language explanation is worth ten minutes.

The relevant point for this article is that all of these consume the same cleaned price matrix you just imported. Changing the objective later does not require re-importing.

Step 7 — Run the optimizer

Run the optimizer. It analyses the return correlation between your candidates and allocates capital toward those that correlate weakly — or whose downside correlates weakly, depending on the objective and risk estimator — which is what reduces the volatility of the resulting portfolio. The resulting allocation is shown in the Recommendation view, whose parameters and outputs are documented in the recommendation chapter.

How to Confirm the Import Worked

Four checks, in order:

  1. Candidate list sanity. The list shows the expected number of symbols and the date range you configured.
  2. Price series inspection. Open a few charts and look for gaps and outliers — specifically around known split dates and dividend events.
  3. Correlation matrix. Review it and confirm it reflects the universe you intended. If two symbols you thought were different show a correlation near 1, you may have imported two share classes of the same company, or the same instrument under two identifiers.
  4. Optimizer output. The run completes without errors and the allocation weights sum to 100%.

If you export the weights, a two-line check is enough to confirm the last point:

import pandas as pd

w = pd.read_csv("weights.csv", index_col=0)["weight"]
assert abs(w.sum() - 1.0) < 1e-6, f"weights sum to {w.sum()}"
assert (w >= 0).all(), "negative weights without a short constraint"
print(f"{len(w)} positions, sum = {w.sum():.4f}")

That assumes an export with a weight column — adapt the column name to whatever your export produces. The point is that “sums to 100%” is a verification step, not an assumption.

Troubleshooting Common Import Issues

Missing data for certain symbols. Check whether the symbol is covered by your configured data provider, and whether the date range actually includes trading days for that listing. Foreign tickers with a suffix and a different exchange calendar are the usual culprits.

Currency mismatches. Make sure the local currency setting matches your portfolio’s base currency. RSJ Portfolio handles conversion for multi-currency portfolios, but the setting has to reflect what you actually want to measure.

Stale cache. If prices look outdated, refresh the cache or adjust the date range so the cache is rebuilt for the window you care about. The Data and currencies page describes how the cache behaves.

Optimizer fails to converge. Try a different risk model or objective — the eight risk estimators behave differently on short or noisy windows — and check whether you have enough historical data for the number of symbols. A 40-symbol universe on a six-month window is asking a lot of a covariance estimate.

FAQ

Do I need to write code to import end-of-day prices into RSJ Portfolio?

No. RSJ Portfolio provides a managed workflow: you configure the data provider, set the date range, build a candidate list, and the application handles the import and cleaning automatically. There is no need to write scripts or call APIs directly.

Can I import prices for stocks quoted in different currencies?

Yes. RSJ Portfolio supports portfolios quoted in several currencies and includes a conversion path. You set the local currency in the configuration, and the application handles the rest.

What data providers does RSJ Portfolio support for end-of-day prices?

The product supports multiple data providers. For the current list, see the Data and currencies page on the RSJ Portfolio website.

How does RSJ Portfolio clean the imported price data?

The application includes a price cleaning pipeline that adjusts for corporate actions, handles missing values, and caches the cleaned data locally for consistent analysis.

From Import to Optimized Allocation

The import is a short sequence: configure the provider and local currency, set the date range, build the candidate list, run the import, verify, choose an objective and risk model, run the optimizer. What you get on the other side is a portfolio built by modern portfolio theory from cleaned, locally cached EOD prices — with capital allocated toward weakly correlated candidates, which is the mechanism that brings volatility down.

The statistical background behind that mechanism is documented in the concept chapter if you want to check the assumptions your allocation rests on — and if you’re worried about whether your result is a genuine signal or a coincidence of the sample window, work through Is Your Optimized Allocation Overfit? before you commit capital.

Start with your own candidate list and the recommended starting parameters. RSJ Portfolio is available under a single user license; see Pricing and license for what it includes and Downloads for the Windows installer and the user guide. If you’d rather see the workflow before installing, the product overview walks through it end to end.

Related posts

EU label: AI-generated content