Pricing engine for an e-commerce retailer

Deloitte, Advanced Analytics, 2026. The client is confidential, so this page describes the method and not the client’s data.

The problem

An e-commerce retailer wanted its prices to reflect how demand responds to price. I designed and built the engine that turns demand estimates into price recommendations, and I built the measurement that checked the pilot. I also co-designed the demand model, which others in the team implemented. The engine is a proof of concept, and it was piloted.

From elasticities to prices

The demand model gives each product a price elasticity \(\varepsilon\). With a constant elasticity, the demand at price \(P\) is

\[Q(P) = Q_0 \left(\frac{P}{P_0}\right)^{\varepsilon},\]

where \(Q_0\) is the demand at the current price \(P_0\). If a unit costs \(c\), the margin is \((P - c)\,Q(P)\). For products with \(\varepsilon < -1\) it has a single maximum, at

\[P^{*} = c\,\frac{\varepsilon}{1 + \varepsilon}.\]

This is the well-known markup rule: the margin per unit is a fraction \(-1/\varepsilon\) of the price.

There are two things to comment about this formula. First, an estimated elasticity carries error, and as \(\varepsilon\) approaches \(-1\) the formula sends the price to infinity. Secondly, for products with \(\varepsilon > -1\) there is no maximum at all: the model says that every price increase pays. So the engine keeps each price inside a range set by what competitors charge for comparable products. For inelastic products it goes no further than the top of that range, or it takes a small step up as a test.

Margin against price for three elasticities, with the range set by competitor prices and the price the engine keeps for each one

Margin against price for three elasticities, with a unit cost of \(0.75\,P_0\). The engine keeps each price inside the shaded range.

Finally, the prices of the products are chosen jointly, in a single optimisation that maximises the total margin. The competitor range is one of its constraints. The others make the prices consistent with each other: variants of the same product share a price, related products keep their price order, and the commercial rules of the retailer apply, such as a minimum margin. Note that the demand of each product depends only on its own price.

Stock

Stock also changes the best price. Indeed, when the units in the warehouse cannot cover the demand until the next delivery, there is nothing to gain from a price that would sell more units than exist. So I extended the engine to take the stock into account. Let \(S\) be the units in stock, and let \(Q(P)\) now be the demand until the next delivery. The margin is then

\[(P - c)\,\min\{Q(P),\,S\}.\]

For \(\varepsilon < -1\) its maximum is at the larger of two prices:

\[\max\{P^{*},\,P_S\}, \qquad P_S = P_0 \left(\frac{S}{Q_0}\right)^{1/\varepsilon}.\]

Here \(P_S\) is the price at which the demand equals the stock. So a product that is short of stock gets a price at least as high as the formula alone gives.

Now consider several markets that sell from one stock, with an elasticity \(\varepsilon_m < -1\) in each market \(m\). Their prices have to be chosen jointly: we maximise the sum of the margins of the markets, and the units sold in all of them cannot exceed \(S\). The solution is

\[P_m = (c + \lambda)\,\frac{\varepsilon_m}{1 + \varepsilon_m}\]

in each market, where \(\lambda \geq 0\) is the Lagrange multiplier of the stock constraint, also called the shadow price of the stock. So the shared stock adds an extra cost per unit, the same in every market. This cost is zero when the stock covers the demand, and otherwise it takes the value at which the markets sell exactly the stock.

Measuring the pilot

A pricing model can fit history well and still recommend prices that do not work, so we had to pilot it. The prices of the pilot maximised the total margin under the consistency and commercial rules. Each price was limited by a cap on its change from the current price.

The analysis uses time-based regression (Kerman, Wang and Vaver, 2017). Before the test, we fit a regression that predicts the treated series from a control, made of series that did not receive the new prices. Here it was fitted on more than a year and a half of weekly data, leaving out the peak-season weeks. During the test, that regression gives the counterfactual. The gap between the counterfactual and what happened is the estimated effect, and the error of the regression gives an interval around it.

The control series have to follow the treated series closely before the test, and the new prices should not affect them.

Illustration with synthetic data: a treated weekly series and its counterfactual from the control series with a 95% interval, and the lift after each week of the test, whose interval narrows as the weeks add up but still includes zero

An illustration of the method with synthetic data, not the client’s series.

After four weeks the estimated effect on margin was positive, but its 95% interval included zero. So the effect was not significant. At this size of effect, the test would have needed another month to be significant. A larger pilot, or a control more correlated with the treated series, would also narrow the interval.