Systems and executionIntermediate25 min read

Slippage: the reference price changes what you are measuring

Define a slippage reference, reconstruct partial fills and separate timing, spread, quantities and costs through a complete Forex example.

One report says a purchase experienced 1.8 pips of slippage. Another, built from the same fills, shows 3.8. Neither necessarily contains an arithmetic error. The first may compare with the ask when the order was sent; the second, with the midpoint observed when the decision was made.

The discrepancy matters because both numbers appear to answer “what happened during execution”, but cover different parts of the process. One reference may include movement before submission, another may incorporate the distance between bid and ask, and another may focus on what happened after the trade was requested.

This article proposes an original teaching investigation of a Forex order. Prices, times, quantities, costs and records are invented. They describe neither Atlas trades nor an intermediary’s execution quality. The goal is to turn the word slippage into an explicit comparison you can reproduce from rules and records.

We will follow a hypothetical purchase of 50,000 EUR of EUR/USD and several bounded variants. We will not send orders or infer profitability. Whenever data associated with a demo is mentioned, the CSV reference applies only to that demo; the exercise’s numbers are constructed here so they can be checked by hand.

A slippage figure needs a reference price, time, side and quantity. Without those elements, two different results may appear contradictory when they are actually measuring different things.

Write the question before the formula

Before calculating, write down what you want to compare. You may be interested in the difference from when a rule decides to trade, from when the program sends a request or from when a recipient confirms receipt. Those moments are not necessarily identical and do not support the same interpretation.

You must also decide which price represents each moment. A midpoint summarises bid and ask, but is not by itself a promise of execution. For a purchase, the ask is a different reference. An external quote adds another perspective, whose source and conditions must be preserved.

The reference is part of the metric’s definition. It is not a cosmetic option you can change afterwards to make a result look better. You can show several references if each answers a declared question and remains identified in the report.

IBKR’s transaction cost analysis documentation distinguishes, among other comparisons, arrival price and improvement relative to the corresponding side of a quote. Its sign convention treats a positive value as favourable; we will explicitly define a different one. Its references to NBBO belong to its context and do not transfer into a universal Forex price. TCA report definitions.

For our case, we will preserve three references: decision midpoint, submission midpoint and submission ask. We will compare the same fills against all three. This will reveal what changes when the start of the comparison moves or a different side of the quote is chosen.

A useful name includes the scope: “price cost against the submission ask” explains more than “slippage”. If you use a short label in a table, preserve its definition or a link to the exact procedure alongside it. An abbreviation should not erase the question.

Also establish what is excluded. A difference between executed prices and a reference does not automatically include a separately charged commission. Nor does it summarise the strategy’s subsequent result. We can study those components, but should avoid attributing them to the same subtraction without explaining the extension.

The first deliverable from this review is a verifiable sentence: for each purchase or sale, I will compare specified fills with an identified quote, selected under a declared time rule, and express the difference using a stated sign convention and unit. That contract guides everything that follows.

Preserve the moments in an order

Our fictional decision occurs at 10:00:00.000. At that instant, we record a bid of 1.0998 and an ask of 1.1000; their midpoint is 1.0999. The request is sent at 10:00:00.100. For that moment, we use a bid of 1.0999 and an ask of 1.1001, with a midpoint of 1.1000.

The first fill occurs at 10:00:00.140: 30,000 EUR at 1.1002. The second occurs at 10:00:00.180: 20,000 EUR at 1.1004. We assume those timestamps belong to a comparable clock and describe the stated events. Later, we will examine what changes if that assumption fails.

Hypothetical event Time Relevant information
Decision 10:00:00.000 Bid 1.0998; ask 1.1000
Submission 10:00:00.100 Bid 1.0999; ask 1.1001
Fill F1 10:00:00.140 30,000 EUR at 1.1002
Fill F2 10:00:00.180 20,000 EUR at 1.1004

The table does not claim that our order caused the price movement. It only organises fictional observations. Attributing causality would require a different design. A correct chronology is necessary for measurement, but does not by itself identify the origin of a change.

Decision, submission and execution times are separate fields. If the record preserves only a column called “time”, determine which event it represents. Millisecond precision is unhelpful when a timestamp’s meaning is ambiguous.

A hypothetical sequence with a decision, submission and two separate fills, showing each event's quantities and prices.
The chronology preserves distinct events. It does not attribute movement to a particular cause.

In a real implementation, there may be a timestamp generated by the provider, another for local receipt and another for processing. A quote created before submission may reach your program afterwards. To represent information available for the decision, you need local availability, rather than just the source timestamp.

If you want to study an external market’s state at a particular instant retrospectively, you can use another reference, but must say so. That retrospective analysis does not turn the quote into information the robot knew when deciding. These questions are compatible as long as they are not confused.

Lack of synchronisation must remain visible. If two clocks cannot be compared at the required precision, reduce the conclusion’s precision or mark the case as unresolved. Shifting timestamps until the difference looks small replaces measurement with an unjustified adjustment.

Define signs, pips and currency

We will use a cost convention: a positive number indicates execution less favourable than the reference, and a negative number indicates more favourable execution. For purchases, subtract the reference from the executed price. For sales, subtract the executed price from the reference. Direction is applied exactly once.

In a separate example, a sale of 10,000 EUR with a reference of 1.2000 and execution at 1.1997 has an adverse difference of 0.0003 USD per EUR: three pips and 3 USD. If it executed at 1.2001, the difference would be minus one pip and minus 1 USD under our convention.

A negative sign can represent price improvement. It should not automatically be removed as though it were invalid data. Before interpreting a sign, check the report’s definition: other tools may use the opposite sign for the same economic comparison.

We adopt an EUR/USD pip of 0.0001. To turn a price difference into pips, divide by that increment. To turn it into dollars, multiply by the quantity in euros. Units provide a simple check: USD per EUR multiplied by EUR leaves USD.

Basis points describe another scale. A price difference is divided by the reference price and multiplied by 10,000. They are not equivalent to pips by definition. In our case, a difference of 0.00028 relative to a reference of 1.1000 equals approximately 2.5455 basis points.

Pips, basis points and money have different relationships with price and quantity. Pips normalise by an instrument increment. Basis points normalise by the reference level. The monetary amount incorporates executed size. Choosing a unit requires knowing which comparison you want to make.

You should also declare whether the result currency matches the account currency. Here we express price cost in USD because EUR/USD quotes dollars per euro. If the account uses another currency, an additional conversion can change the reported amount without changing the price difference.

To detect errors, preserve a purchase case and a sale case with the same absolute adverse deviation. Both should produce a positive cost of equal magnitude under the same sizes and units. That check prevents an average from mixing adverse purchases and adverse sales as though they offset one another.

Aggregate fills without losing quantities

The main order has two fills of different sizes. The weighted average price is the sum of each price multiplied by its quantity, divided by total quantity. Thirty thousand euros at 1.1002 and twenty thousand at 1.1004 produce 1.10028.

The simple mean of the two prices would be 1.1003. That number would give equal weight to unequal quantities. The difference looks small, but applied to 50,000 EUR it represents 1 USD. Early rounding can hide precisely the error you are trying to investigate.

Weighting uses executed quantities, not requested quantities. If part of the order is unfilled, it should not enter the average price’s denominator as though it had received a price. Pending or cancelled quantity belongs in another record.

OANDA’s transaction documentation distinguishes prices and information for trades opened, reduced and closed, alongside other aggregate fields. Some fields are conditional or deprecated. Before choosing one as the official price, its specific definition must be read. Transaction and fill schema.

To check our average, also calculate the total amount: 30,000 times 1.1002 is 33,006 USD; 20,000 times 1.1004 is 22,008. The sum is 55,014 USD. Dividing by 50,000 EUR gives the same price of 1.10028 USD per EUR.

Two fills of thirty thousand and twenty thousand euros produce a weighted price of 1.10028, different from the simple average of 1.1003.
Reconciliation through amounts and through average price should reach the same result.

Each fill needs an identifier to avoid counting a repeated message twice. Its relationship to the parent order should also be preserved. If a request is split into several child orders, aggregation must follow an explicit hierarchy, without adding both the parent total and its parts.

A later reduction or correction requires the record to be updated with traceability. Do not silently overwrite an old fill while preserving an average calculated with the earlier version. The report should identify which set of events produced each figure.

Keeping details allows other groupings to be chosen later without reconstructing lost data. You can analyse the whole order or each fill, but must specify the unit of observation and avoid presenting two dependent analyses as though they were independent evidence.

Compare one execution with three references

We now compare the weighted price of 1.10028 with the decision midpoint of 1.0999. The purchase difference is 0.00038: 3.8 pips. Multiplied by 50,000 EUR, it represents 19 USD of price cost relative to that reference.

Against the submission midpoint of 1.1000, the difference is 0.00028: 2.8 pips and 14 USD. Against the submission ask of 1.1001, it is 0.00018: 1.8 pips and 9 USD. Every calculation uses the same fills.

Reference Price Adverse difference Amount on 50,000 EUR
Decision midpoint 1.0999 3.8 pips 19 USD
Submission midpoint 1.1000 2.8 pips 14 USD
Submission ask 1.1001 1.8 pips 9 USD

We are not deciding which number is the true slippage. Each has a defined interpretation. The first covers the change since the decision; the second starts at submission; the third uses the purchase side of the quote available at that moment.

Execution does not improve because you change its comparison. Moving from 19 to 9 USD in a report can be a legitimate choice of measure, but does not represent an improvement achieved. To compare system versions, preserve the reference or explicitly show the definition change.

The midpoint is useful as an analytical reference even though it is not a guaranteed purchase price. That is precisely why a difference against the midpoint can incorporate the distance to the execution side. Interpreting it as a failure after submission would attribute too much to that stage.

The ask does not guarantee that the entire quantity will execute at that level either. It may represent limited available quantity, an inaccessible quote or information that changes before action. Its relevance depends on the data and comparison conditions.

A report can preserve all three columns with a brief explanation. That presentation retains useful information without forcing a single number that mixes everything together. The conclusion should name the reference: “nine dollars against the submission ask” is more checkable than “execution cost nine dollars”.

If a data source lacks bid and ask, do not invent both from a single close without declaring a model. You can study a comparison against that close, but its name and limits should correspond to what you actually observed.

Decompose the difference without double counting

The price cost of 19 USD against the decision midpoint can be decomposed arithmetically into three segments. From the decision midpoint to the submission midpoint, the difference is 0.0001, equivalent to 5 USD. From the submission midpoint to the ask, there is another 0.0001, equivalent to 5 USD. From the ask to the average executed price, 9 USD remain.

The sum is 5 plus 5 plus 9: 19 USD. It is an identity between selected prices. The first segment shows movement between time references. The second shows half the bid–ask distance of that quote. The third is the residual against the submission ask under our definition.

An accounting decomposition does not automatically identify causes. The residual 9 USD may combine market movement, liquidity conditions and other effects. We cannot attribute it entirely to latency, own-order impact or an intermediary’s actions from these four rows.

The nineteen dollars against the decision midpoint are decomposed into five for movement until submission, five to the ask and nine to execution.
The segments add up to the total difference. Their labels do not turn the arithmetic identity into causal attribution.

Let us add a hypothetical commission of 2 USD for the complete order. If it is not incorporated in the prices, the combined cost against the decision midpoint would be 21 USD. It must appear as an identified additional item, with its currency and scope.

An item already included in prices is not deducted again. If you compare an executed purchase with a midpoint, part of the distance between sides already appears in that difference. Adding a full spread afterwards as though it were absent can duplicate components.

Reconciliation should distinguish explicit charges, price differences and conversions. An aggregate provider field may include some of them. Before adding it to your estimate, inspect its definition. Two columns having different names does not guarantee that they contain different items.

There may also be improvement in one segment and deterioration in another. Favourable movement before submission does not eliminate a subsequent adverse difference. Preserving components reveals offsets that a small total can conceal.

The review question is concrete: can you work back from the total to the quotes, fills and charges without any quantity appearing twice? If not, the problem still concerns definition or traceability, even if the total appears plausible.

Choose a valid quote

A quote needs more than a price. OANDA’s public pricing documentation distinguishes creation time, tradeable status and lists of prices with liquidity on each side. It is a reminder that an isolated number does not describe the full available reference. Price definitions.

For a reference available to the program at submission, you can define a search for the latest received quote no later than submission, with a declared maximum age. If no quote satisfies the rule, the case has no valid reference; it is not replaced with the next future observation.

In a teaching variant, a quote created at 10:00:00.095 arrives at 10:00:00.098 and submission occurs at 10:00:00.100. That quote was locally available. Another, created at 10:00:00.099 but received at 10:00:00.120, was not yet available.

Time selection depends on the measurement question. The second quote could form part of a retrospective reconstruction of the source market if its timestamps are reliable. It cannot be presented as information known by the robot at the instant of submission.

A join based on “nearest time” can choose a later row because it is fewer milliseconds away. That statistical convenience changes the procedure. For a causal availability comparison, preserve the search’s time direction and explicitly test a nearby future observation.

The source matters too. An external price can provide a comparison, but does not establish that it was executable for that account, quantity and moment. The BIS report on execution algorithms examines a fragmented Forex market and the information challenges it creates. Not every screen should be treated as a universally accessible quote. FX execution algorithms and market functioning.

Record instruments, pair orientation and precision. An inverse price, an indicative quote and an executable quote can look similar after rounding, but require different interpretations. Normalisation must preserve the relevant differences.

When information is missing, show its effect on coverage: how many orders have a valid reference and how many do not. An average calculated only over the easiest cases to match may describe a different selection from the set you thought you were analysing.

Preserve what was not executed

Return to a variant of the main order: only 30,000 EUR execute at 1.1002 and the remaining 20,000 are cancelled. Against the submission ask of 1.1001, executed price cost is 3 USD. The fill rate by quantity is sixty percent.

You should not compare those 3 USD directly with the previous complete order’s 9 USD as though the entire difference were improved execution. You received less quantity. The comparison needs to preserve price, completed quantity and the remainder’s status simultaneously.

An unfilled order does not have an executed price of zero. Nor should it disappear from the overall record when the execution process is being evaluated. It may lack a fill-based slippage measure while remaining relevant to the study of rejections, cancellations or pending quantity.

As a separate counterfactual exercise, suppose the ask is 1.1006 at the end of the chosen window. Comparing the unfilled 20,000 EUR with the initial ask of 1.1001 produces a hypothetical difference of 10 USD. That amount was not necessarily charged or realised; it depends on the scenario you defined for completing the quantity.

The cost of unfilled quantity needs a declared counterfactual. You must specify when you would have traded, against which reference and under which condition. Do not add that amount to the statement as though it were a real commission.

An order variant: thirty thousand euros filled with a three-dollar difference and twenty thousand cancelled, with a separate counterfactual scenario.
Separating executed from pending quantity avoids artificially rewarding a comparison that completed less size.

Limit orders illustrate that tension. A price condition can restrict fills and leave part of the intention incomplete. The analysis should preserve the original condition and its outcome, without assuming every absence of execution is a failure or every price improvement is sufficient.

To compare procedures, define whether the unit is an intention, an order or a fill. One intention can produce several attempts and cancellations. Looking only at the last fill can conceal what happened beforehand. Links between identifiers make that chain reconstructable without inventing executions.

The case’s conclusion can be mixed: lower cost on the executed portion and less quantity completed. Presenting both dimensions is more informative than forcing a single ranking without declaring the objective that was intended.

Aggregate orders with explicit weights

Imagine two hypothetical purchases of the same pair using the same reference: one for 1,000 EUR has ten adverse pips; another for 99,000 EUR has one adverse pip. The simple average per order is 5.5 pips. The quantity-weighted average is 1.09 pips.

The monetary amounts are 1 USD for the first and 9.90 for the second, totalling 10.90 USD. Dividing that total by 100,000 EUR and then by pip size reproduces 1.09. Reconciliation checks that the weighting corresponds to the monetary question.

The weight defines what the average represents. An order-level average describes an order selected with equal weight among those observed. The quantity-weighted average describes another distribution. Neither can replace the other without changing the interpretation.

If you mix pairs, currencies or pip sizes, adding pips directly ceases to be a coherent monetary comparison. You can convert amounts to a common currency under an explicit convention, or use normalised units appropriate to the question. Always preserve the original components.

You also need measures of dispersion. An average may be small because improvements and deteriorations offset one another. Showing quantiles, reviewed extremes and observation counts helps identify whether a few episodes dominate the result. Those statistics describe the sample; they do not guarantee its future repetition.

Child fills from a single order must not be confused with independent orders. If one order is divided into a hundred fills, giving it a hundred times another order’s weight merely because it produces more records changes the analysis unit. Group according to the contract you declared.

Compare coverage across groups. If references are missing for many sales while almost every purchase has data, the combined average may be dominated by a recording problem. The table of included and excluded cases is part of the interpretation.

Before publishing a result, check that you can move from the aggregate amount to its contributing orders and add them back together. A discrepancy in that process is usually more useful to investigate than adding another visualisation of a figure that has not yet been reconciled.

Compare procedures without attributing too much

A robot may show a larger difference against submission during periods of rapid movement. That does not by itself establish that its implementation is worse. It may trade at different moments, with different quantities or another order type. The comparison needs to preserve those conditions.

A useful review groups cases by relevant variables declared before examining the result: instrument, side, size, order type and observable characteristics of the moment. There is no need to create hundreds of tiny groups; the goal is to prevent the case mix from explaining a difference attributed to the procedure.

An observed difference does not by itself identify a cause. If one version operates after a provider change or during another period, several explanations are possible. The report should distinguish a description of outcomes from attribution to the code change.

You can construct paired comparisons when a common reference and a compatible question exist. However, simulating two executions on the same stream does not guarantee both would have received the same real conditions. The shared scenario controls certain inputs and leaves others outside its scope.

Latency deserves specific treatment. The duration between submission and confirmation is not necessarily the duration between submission and execution. Some time may belong to subsequent communication. If you only have the time a message was received, label that measure precisely.

Nor should all adverse movement be attributed to your order’s impact. The market may have moved for other reasons. Studying impact would require additional design and data. The example’s arithmetic decomposition locates stages; it does not assign responsibility.

A defensible comparison can conclude that the data cannot separate the explanations. That conclusion guides the next recording effort: receipt time, available quantity or reference identification may be missing. Improving the record can contribute more than adjusting a formula using insufficient information.

The indirect commercial value of understanding these differences lies in being able to ask about specific rules, code and assumptions. Readable robot code allows you to study how execution is represented; it does not turn a simulation into evidence of conditions that were never observed.

Bring the measure into a reviewable simulation

If you want to incorporate slippage into a backtest, first decide what its base price represents. If the simulator already buys at the ask and sells at the bid, adding an estimate measured against the midpoint may include part of the distance between sides again.

The model should preserve the same boundary as the measurement. You can estimate a difference against the submission ask and apply it to an equivalent simulator price, provided the conditions are comparable. Applying it to a candle close without specifying its side and time changes the adjustment’s meaning.

The cost model must correspond to the price it is applied to. An isolated figure of “two pips” does not establish that correspondence. You need the reference, direction, quantity, observation period and treatment of unfilled cases.

A constant can serve as a sensitivity scenario, but should not be presented as an observed distribution. An estimated distribution requires its sample, filters and method to be preserved. If you condition it on size or market state, check which information would be available when the simulator uses it.

Time separation matters when estimating those parameters too. Do not silently calibrate the model using fills from the future relative to the period being evaluated. You can perform an exploratory retrospective analysis, but its interpretation must reflect that you used that information to construct the assumptions.

Test favourable and adverse movements, missing values and partial fills. A model that always produces a complete fill may suit a limited exercise, but does not study the quantity that remains pending. That limit should remain visible in every subsequent comparison.

The simulation should produce a record that lets the measurement be repeated. Save the base price, applied adjustment, quantity and final price. Then run the same difference formula used in the manual examples on that record. This checks consistency between the model and its report.

The article on position size and sensitivity helps convert differences into money. The article on independent tests for AI-generated code provides cases for verifying that functions do not repeat the same reference error.

Deliver a comparison that can be audited

The final document can begin with a brief measurement contract: observation unit, order side, reference, instant, source, matching rule, sign and currency. Add the treatment of partial fills, explicit costs and cases without a valid reference.

Then present the complete example. For our order, the average executed price is 1.10028; price costs are 19, 14 and 9 USD according to the three references. The decomposition of 5 plus 5 plus 9 reconciles to 19. The hypothetical commission of 2 USD raises the defined total against the decision midpoint to 21.

Preserving several references can improve the explanation without changing execution. What matters is that the reader recognises which part of the process each column includes. If you change the measurement contract, version that change and avoid mixing its values with earlier ones without recalculation.

A measurement contract covering the event, reference, sign, quantity, costs and missing-data policy.
The contract turns an ambiguous label into a reproducible comparison.

Include a small set of checks: a purchase, a sale, a price improvement, two unequal fills and a partial cancellation. Also verify that a future quote does not enter the reference available at submission and that a repeated identifier does not increase quantity.

The report should preserve coverage and exclusions. If some orders lack valid references, show them as such. A clean result from an incomplete sample can be useful, provided it is not presented as a description of every trade.

Reviewing the sources completes the contract. External documentation can define a field or convention; your records should demonstrate how you used it. No link replaces preserving the quotes, quantities and events that produce the specific number.

The purpose is not to find the reference that makes a curve look best, but to explain which comparison makes sense for each question in the process. If another report showed different slippage tomorrow using the same fills, could you identify exactly which price, instant or weighting explains the difference?

The same average execution price is compared with three reference prices, producing differences of 3.8, 2.8 and 1.8 pips.
Changing the reference changes the measure, even when the fills are identical.
Back to the Blog