

A few conceptual elements of the werin algorithm.
Patrick Sentis, founder — 23/04/2026 · Reviewed on 18/10/2026
Here is a glimpse into the Pandora* universe of the werin code. Two core innovations at the heart of the algorithm are revealed here in a minimal version.
* So named by our developers.
1. How does our algorithm select the stocks matching users' preference criteria?
Users select one or more criteria and give each a grade from 1 to 4 according to how important it is to them. For example, if a user gives a preference of 2 to criterion 1 and a preference of 4 to criterion 3, it means they consider criterion 3 twice as important as criterion 1. These are called cardinal preferences.
This grading is used to weight the criteria ranks of each stock. Since the selection is “best in class”, stocks are ordered by the sum of their weighted ranks.
A little mathematics
Let be the rank of stock for criterion . is the number of stocks in the investment universe and the number of criteria selected by investor ; the rank matrix for all stocks is written:
If is the preference of investor for criterion , the column vector of their preferences over all criteria is written:
The column vector of the sum of weighted ranks for each stock, , is then computed as follows:
This step is decisive because it takes individuals' cardinal preferences into account. Sorting the column vector in descending order identifies the stocks matching the user's criteria.
2. Another werin innovation: stock weights and portfolio performance, transaction costs included, when a portfolio is revised.
When transaction costs are included in measuring portfolio performance, the problem is to determine properly the amounts invested in each stock while respecting their predefined weights. Take an example. Suppose an investor has 10,000 euros to build a portfolio. If transaction costs are 1% of the amounts invested, the invested value of the portfolio excluding transaction costs is 9,901 euros (10,000 / 1.01). If the invested sum grows by 6% over a year, its value will be 10,495 euros. The investor’s performance, transaction costs included, is therefore not 6% but 4.95%. The calculation is fairly simple and presents no particular difficulty.
The problem becomes more complex, however, when a revision of the portfolio is triggered during its life. Stock weights are then increased or decreased, some stocks leave the portfolio and others join it. The value of the invested portfolio, excluding transaction costs, must be calculated so that the total amount (transaction costs included) equals the value of the portfolio before the revision. Surprisingly, to our knowledge, the specialised literature does not address this question in any way. The problem may seem trivial and could not justify a scientific publication on its own. It is nonetheless of crucial practical importance when one wants to measure portfolio performance rigorously.
A little mathematics
Consider a set of stocks. The weight of stock in the portfolio before revision is denoted . Its new weight, resulting from the revision, is . is the total amount of the portfolio before revision, the amount of the portfolio invested after the revision excluding transaction costs, and the total amount of transaction costs. We can therefore write:
To determine the amount invested in any stock after revision, we need to know and therefore . Indeed:
With the cost of a transaction as a percentage, can be calculated as follows:
Knowing , we can deduce the total amount of the invested portfolio, , and the amount invested in each stock, .
Create my portfolio — it's free
Design your portfolio in 5 minutes and get your full diagnosis.
No credit card
Results in 5 minutes