Skip to main content
Methodology · “Pandora” algorithm

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 ra,c be the rank of stock a for criterion c. N is the number of stocks in the investment universe and n the number of criteria selected by investor k; the rank matrix R for all stocks is written:

R=[r1,1…r1,n⋮⋱⋮rN,1…rN,n]

If pc,k is the preference of investor k for criterion c, the column vector P of their preferences over all criteria is written:

P=[p1,kp2,k⋮pn,k]

The column vector S of the sum of weighted ranks for each stock, sa,k, is then computed as follows:

S=[s1,ks2,k⋮sN,k]=R×P

This step is decisive because it takes individuals' cardinal preferences into account. Sorting the column vector S 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 N stocks. The weight of stock a in the portfolio before revision is denoted pao. Its new weight, resulting from the revision, is pan. M is the total amount of the portfolio before revision, M′ the amount of the portfolio invested after the revision excluding transaction costs, and C the total amount of transaction costs. We can therefore write:

M′=M−C

To determine the amount man invested in any stock a after revision, we need to know M′ and therefore C. Indeed:

man=pan×(M−C)

With c the cost of a transaction as a percentage, C can be calculated as follows:

C=∑a|pan×(M−C)−pao×M|×cC=M·c×∑a|pan−pao|1+c×∑apan·pan−pao|pan−pao|

Knowing C, we can deduce the total amount of the invested portfolio, M′, and the amount invested in each stock, man.

Put it into practice

Create my portfolio — it's free

Design your portfolio in 5 minutes and get your full diagnosis.

  • No credit card

  • Results in 5 minutes