Artificial intelligenceIntermediate27 min read

An agent has not tested the decision missing from its data

Understand offline policy evaluation through action coverage, logged probabilities, worked importance weights and the limits of historical trading records.

A mountain trail forks in light snow, with footprints on one branch and untouched snow on the other
Conceptual photograph: a record of the path taken does not reveal what happened on every alternative path.

The spreadsheet has trades, but the question has alternatives

Nora opens a hypothetical archive containing thousands of trading decisions. A new agent proposes holding positions longer, entering during a previously avoided session and sometimes remaining flat where the old system entered. The file looks rich enough to support almost any experiment. Then she asks a less comfortable question: which outcomes in the file actually tell her what would happen under those new choices?

A record of an executed action usually contains the outcome of that action. It does not automatically contain the outcome of every action that could have been chosen instead. A historical price series can support a simulation of alternatives under declared execution assumptions, but that is another source of evidence. Observed decisions, reconstructed alternatives and model predictions must remain distinguishable. Combining them in one column called reward does not make their evidential status equal.

This article uses invented examples to explain that distinction. None of the numerical rewards, action frequencies or policy estimates below are measured TradeAndRoll returns. Nora’s objective is to decide what an archive can support before fitting an ambitious agent. She wants a coverage report and an auditable evaluation plan, not an impressive policy-value number whose assumptions disappear when it reaches a presentation.

The offline reinforcement learning review by Levine and colleagues describes learning from previously collected data without further online interaction. That setting makes the available data a central constraint. In our trading exercise, the constraint is concrete: the archive may contain only one policy’s decisions, limited position sizes, selected market conditions and incomplete records of choices that were rejected before execution.

Define a decision row before counting experience

Nora first asks whether a row represents a candidate decision, an order, a fill, a completed trade or an account snapshot. These are not interchangeable units. One decision can produce several fills; one position can contain several entry decisions; a rejected candidate can produce no order at all. Counting rows without identifying the unit can make an archive appear far more informative than it is.

For a simple one-step teaching exercise, a row contains the context available before a decision, the available actions, the selected action, the probability of selecting it under the logging policy, and the resulting reward under a declared observation window. The term logging policy means the procedure that generated the recorded actions. A rule-based robot, a human operator or a randomized research policy can each generate records, but they provide different information about how actions were selected.

In a sequential task, the row also needs connections to prior and subsequent states, episode identifiers and termination conventions. An end-of-file boundary is not necessarily a meaningful end of an economic episode. If a position remains open when collection stops, the record must state how its outcome is treated. Otherwise a policy may appear attractive simply because unfavorable unfinished positions vanish from the reward calculation.

Coverage starts with a data dictionary. Nora records units, timestamps, account state, order state and reward construction before discussing algorithms. She also preserves reasons for rejected decisions and missing observations where available. An empty field cannot safely be interpreted as a zero reward or an intentional choice to do nothing. Those meanings require evidence from the recording procedure.

The available action set is part of the context

Imagine a hypothetical decision with three conceptual actions: stay flat, enter small or enter large. If the account lacks sufficient margin for the large entry, that action may not be available. If an instrument is temporarily non-tradable, even a small entry may be impossible. A policy evaluation should not count an unavailable action as an ordinary alternative merely because the software’s action enumeration includes it.

Nora records the feasible action set at each decision time. She distinguishes “not selected” from “not allowed” and “not recorded.” These states lead to different conclusions. A rarely selected feasible action might have limited support. A prohibited action cannot be evaluated as an available historical choice without changing the environment definition. An unrecorded action leaves a documentation gap that a learning algorithm cannot resolve by itself.

Action meaning also needs stable units. “Increase position” could mean one lot, one fixed currency notional or a percentage of current equity. A historical action code of one may therefore describe very different exposures across records. Nora translates codes into explicit economic and execution quantities before comparing policies. She retains the original code as well, so the transformation can be reviewed and reproduced.

The same action label does not guarantee the same action. A new agent using different sizing, order types or holding rules may be proposing choices outside the original archive’s scope even if its interface uses familiar names. The coverage audit examines those details before treating a large number of similarly named records as direct evidence for the candidate policy.

A one-step example with known logging probabilities

Consider one hundred hypothetical independent decision opportunities with identical context. The logging policy chooses trade with probability 0.5 and stay flat with probability 0.5. In this invented realized sample, fifty opportunities contain trades and fifty contain flat decisions. Among the trades, thirty rewards are +4 units and twenty are −3 units. Flat decisions have zero reward. Total observed reward is therefore 120 minus 60, or 60 units.

The average reward under the recorded sample is 60 divided by one hundred, or 0.6 units per opportunity. Now consider a target policy that always trades. Under the deliberately simplified assumptions of this example, a trade observation receives an importance weight equal to target action probability divided by logging action probability: 1 divided by 0.5, or two. A flat observation receives weight zero.

The weighted reward total is two times sixty, or 120. Dividing by all one hundred opportunities gives an estimate of 1.2 units per opportunity for the always-trade target. This is arithmetic under a known randomized logging mechanism, identical contexts, compatible rewards and the usual identification conditions. It is not a forecast of trading profitability, and it is not permission to apply the calculation to an arbitrary executed-trades spreadsheet.

The denominator is the decision population, not just the selected trades. The fifty flat decisions matter even though their rewards are zero and their target weights are zero. If Nora discards them, she changes the representation of the logging process. In this balanced toy example the conditional mean of trade rewards happens to equal 1.2, but that coincidence should not obscure the definition of the estimator.

One hundred hypothetical decisions contain fifty trades and fifty flat actions; always-trade weights are two and zero, producing estimated reward 1.2 units
Illustrative one-step arithmetic with known randomized logging. These units are invented rewards, not measured financial returns.

A different target changes the weights

Keep the same one hundred observations and consider a target that trades with probability 0.8 and stays flat with probability 0.2. Trade observations now receive weight 0.8 divided by 0.5, or 1.6. Flat observations receive 0.2 divided by 0.5, or 0.4. The weighted reward total is 1.6 times sixty, or 96, because the flat rewards remain zero. Dividing by one hundred gives 0.96 units per opportunity.

The target policy is different even though the archive is unchanged. Nora therefore stores the target’s action probabilities with its version rather than treating importance weights as a permanent property of the dataset. A weight belongs to a comparison between a target and a logging process at a particular observed context. Changing either policy can change the weight.

The original paper on doubly robust policy evaluation by Dudík, Langford and Li discusses the contextual-bandit setting, where outcomes are observed for chosen actions, and contrasts reward-model and propensity-based approaches. That motivates a useful distinction for Nora: estimating how actions were selected and estimating what rewards actions produce are separate modeling tasks. Combining them does not eliminate the need to examine both.

She verifies the simple example by hand before asking software to evaluate a larger archive. The original reward sum must be sixty; the weights must match the declared policies; the reported population must remain one hundred. These checks are deliberately mundane. A sophisticated estimator cannot rescue a misidentified decision population, and a plausible final number is not evidence that the underlying rows represent the intended comparison.

Zero support is not a small-probability problem

Suppose the logging policy never entered during a specified session. For those contexts, the probability of trade was zero. A target that proposes trading there assigns positive probability to an action with no logging support. The importance ratio requires division by zero. This is not a numerical inconvenience to be repaired by adding a tiny constant and continuing as though the archive contained the missing experience.

Nora marks the context-action region as unsupported. She can investigate it through another evidence source: a carefully specified simulator, additional suitably collected observations or a model whose extrapolation is explicitly acknowledged. Each route introduces assumptions and a separate evaluation problem. None turns the absent historical action into an observed outcome. The report should show exactly which part of the candidate policy depends on such additional assumptions.

A practical coverage map groups contexts coarsely enough to inspect while preserving relevant distinctions. For example, it might list action counts by session and exposure band. This map is a diagnostic summary, not proof that all continuous states within a cell are interchangeable. A cell containing trades at tiny exposure does not automatically support a much larger action simply because both are coded trade.

No amount of repeated fitting creates an unobserved action outcome. More training epochs can change how a model extrapolates, but they do not add direct evidence to the missing region. Nora’s first policy revision may therefore be a constraint: restrict the candidate to choices that the archive can meaningfully support, then state clearly what opportunities remain outside the scope of the evaluation.

Hypothetical coverage grid shows observed small and flat actions in two contexts, with large actions and one context's trades unsupported
Counts diagnose observed coverage. A zero cell requires a different evidence plan, not a more confident interpretation of the same archive.

Rare actions can dominate the estimate

Now imagine a second hypothetical archive of one hundred opportunities. The known logging probability of trade is 0.2. The realized sample contains twenty trades and eighty flat decisions. The trade rewards sum to 24 units. An always-trade target assigns weight five to each trade and zero to each flat observation. Weighted total reward is 120, so the estimated value is again 1.2 units per opportunity.

The matching point estimate does not mean the second archive contains the same evidence as the first. Only twenty observed trade outcomes carry nonzero weight, compared with fifty before. A single unusual trade reward has a larger influence. Nora reports the distribution of weights, the number of contributing observations and their temporal concentration rather than allowing identical final estimates to imply identical reliability.

A common descriptive weight diagnostic is effective sample size, computed as the squared sum of weights divided by the sum of squared weights. Here the weights sum to one hundred and their squares sum to five hundred, giving twenty. In the first always-trade example, the same calculation gives fifty. This diagnostic describes weight concentration; it does not certify twenty or fifty independent market episodes, especially when real observations are temporally dependent.

Weight concentration and time dependence are separate limitations. Twenty weighted trades all from one market event can provide less varied evidence than twenty trades spread across distinct conditions. Nora preserves episode structure and reports both concentration measures. She avoids presenting an effective sample size as a universal confidence score, and she does not invent an uncertainty interval without an appropriate sampling and dependence model.

Two hypothetical archives estimate the same 1.2 reward units, but fifty trades with weight two give effective sample size fifty while twenty trades with weight five give twenty
Same point estimate, different concentration of evidence. Effective sample size here is a weight diagnostic, not a count of independent market episodes.

Logging probabilities cannot be guessed from action frequencies alone

The simple examples deliberately used known probabilities and identical contexts. A real robot often selects actions deterministically from its inputs. Seeing trades in twenty percent of all rows does not imply a twenty-percent trade probability at every context. The robot may trade with certainty in one region and never trade elsewhere. Replacing that context-dependent mechanism with the overall frequency invents overlap that may not exist.

Nora requests the logging rule, its version and the information it used. If a human operator intervened using information absent from the archive, the recorded context may not explain action selection sufficiently for the proposed evaluation. A propensity model fitted to incomplete records can produce smooth probabilities without resolving that missing-information problem. Numerical output from a classifier is not proof that the required selection assumptions hold.

She distinguishes known probabilities recorded at decision time from estimated probabilities reconstructed later. If estimation is necessary, she documents the features, fitting interval, checks and uncertainty of that model. She also tests whether the estimates contradict known deterministic constraints. Assigning positive probability to an action that the original software prohibited is a warning about the reconstruction, not evidence that the action was historically possible.

A logging-policy audit precedes an importance-weight calculation. If the archive lacks the necessary selection information, the honest result may be that this estimator is not supported by the available records. That conclusion still advances the project. It identifies which additional logging fields or alternative experimental design are required before the agent’s proposed choices can be assessed credibly.

Sequential decisions multiply the support problem

A one-step decision ends after its reward is observed. A trading agent that enters, holds, adds, reduces and exits creates a sequence. Earlier actions change later positions, margin, available actions and possibly execution conditions. Evaluating a new sequence cannot generally be reduced to averaging independent rows from the old policy. The relationship between actions and future states is part of the task.

For a deliberately simple arithmetic illustration, suppose the target-to-logging probability ratio along a particular observed trajectory is two at each of ten steps. The product is 2 to the power ten, or 1,024. This does not describe any real trading dataset. It shows how repeated probability ratios can become extreme across a sequence, even when each individual ratio looks modest.

Nora inspects trajectory coverage and termination rules before choosing a sequential estimator. A new policy that holds longer may reach account states absent from the old policy’s archive. An action can appear in the data individually while the particular sequence and resulting state remain unsupported. Counting buy, hold and sell labels separately would miss that gap.

Observed actions do not guarantee observed trajectories. The task definition must state which parts of the environment are assumed unaffected by the agent and which state variables depend on its actions. A small research position may be modeled as not affecting market prices, but its own inventory and costs still depend on its choices. Those dependencies cannot be removed by calling the data historical.

Illustrative repeated probability ratios of two grow from two at one step to thirty-two at five and 1024 at ten steps
Arithmetic illustration of trajectory weighting. It explains a concentration mechanism, not the behavior of a particular estimator on real trading data.

A simulator answers a different evidence question

Historical quotes can allow Nora to simulate a candidate action that was not executed in the archive. That is valuable, but she labels the result as simulated. The outcome depends on assumptions about order timing, bid and ask, fills, slippage, commissions, financing and position handling. A price path alone does not determine every execution outcome. The simulator supplies the missing connection between the proposed action and the hypothetical fill.

She keeps an evidence field identifying whether each reward was observed, reconstructed by deterministic rules or predicted by a learned model. If several sources are combined, she records the combination explicitly. Otherwise an evaluator may treat modeled rewards as additional independent observations and report unwarranted precision. Repeating a deterministic simulation many times with the same assumptions does not create new historical experience.

A useful small exercise compares the simulator with a subset of recorded actions whose outcomes are known. Discrepancies reveal where its conventions differ from the archive. Agreement on those actions is helpful but does not validate every unobserved action, especially larger sizes or different order types. Nora states the tested scope rather than extending a narrow reconciliation into a universal execution claim.

A simulator can broaden a research question while adding model risk. The tradeoff should be visible. An agent that looks strong only under optimistic fills may be exploiting the simulator’s assumptions. The next step is to challenge those assumptions with explicit alternative cases, not to describe the simulated policy as if it had already experienced its proposed decisions in a real account.

Conservative constraints should name what they restrict

Nora may constrain the candidate policy to actions similar to those represented in the archive. Such a restriction can reduce unsupported extrapolation, but “conservative” is not a complete specification. Does it limit action probability changes, position size, holding time, state novelty or distance from the logging policy? Each choice restricts a different aspect of behavior and can exclude different opportunities.

She writes the constraint in operational terms. For example, a research candidate might be limited to the recorded size range and prohibited from entering in context-action regions with no observed support. These are illustrative design choices, not recommended thresholds or guarantees. The resulting evaluation concerns the constrained candidate, not an unconstrained version that may later behave very differently.

She also documents what happens when the constraint is activated. Does the agent stay flat, defer to a fixed rule or stop generating decisions? The fallback has its own costs and consequences. A report that evaluates only the agent’s accepted actions but ignores every fallback decision can overstate the usefulness of the constrained policy. Coverage and resulting behavior must be assessed together.

A constraint is part of the policy being evaluated. Removing it after obtaining a favorable result creates a different policy. Nora preserves the constraint configuration with the model artifact and includes boundary cases in its tests. The practical benefit is clarity: another researcher can identify exactly which behavior the available evidence covered and which behavior would require a new investigation.

Selection can contaminate an evaluator without changing its formula

Suppose Nora evaluates many candidate agents on the same historical archive and retains the one with the highest estimated value. Even if each calculation follows its stated formula, the winning estimate has participated in selection. Reusing the same archive to describe the winner as independently confirmed ignores how the candidate was chosen. The evaluator is now part of the development loop.

She separates candidate construction, evaluator development and later assessment as far as the available material permits. The split must respect chronology and trajectory structure. Cutting one trajectory into rows and scattering them between sets can preserve information links that the split was meant to separate. Likewise, tuning the reward model after inspecting evaluation outcomes changes the procedure even if the target policy is frozen.

The empirical study of off-policy evaluation by Voloshin and colleagues uses diverse experimental designs to examine evaluation methods. For Nora, its practical relevance is methodological: an evaluator should be challenged across conditions rather than accepted because one demonstration looks successful. Our article does not transfer that paper’s benchmark results into trading-performance claims.

She records every material change to the evaluation procedure and the reason for it. A correction to a genuine implementation error is necessary, but it should not erase the fact that the previous result was inspected. The audit trail belongs to the evaluator as well as the agent. That makes it possible to distinguish a repaired computation from an adaptive search for a favorable estimate.

Report what remains unidentified

A useful final report can contain an explicit unsupported region. Nora states which contexts, actions, sizes and trajectories lack adequate evidence under the chosen method. She estimates the candidate’s tendency to request those choices on the inspected contexts, while avoiding the claim that historical frequency guarantees future coverage. The reader can then see how much of the proposal lies outside the evaluated scope.

She separates a point estimate from its assumptions, weight diagnostics and sensitivity results. If clipping weights or changing a reward model materially changes the conclusion, that dependence belongs near the headline result. Clipping can reduce concentration while changing the estimator’s properties; it should not be presented as a harmless cosmetic adjustment. The report names the rule and retains the unmodified calculation where feasible.

Some questions may remain unanswered because the data do not contain the relevant information. Nora does not fill those gaps with a precise-looking confidence interval. She identifies the missing field or coverage region and proposes a proportionate next step: improve logging, validate a simulator convention, narrow the policy or design an additional research collection. The next step follows from the gap rather than from enthusiasm for a particular algorithm.

An honest boundary is a useful research result. It prevents the project from treating a large archive as universal experience. It also makes collaboration easier: a developer knows which logging change is needed, a reviewer knows which assumption to challenge and a user knows which behavior has not yet been assessed. That specificity is more valuable than a broad assurance that the agent learned from lots of data.

Reconcile the reward ledger before evaluating another policy

Even perfect action coverage is insufficient if the reward ledger mixes incompatible conventions. Nora checks whether a reward is measured per decision, per completed position or per unit of elapsed time. A policy that holds longer changes the relationship between those units. Averaging reward per completed trade can make two policies difficult to compare when one produces many short trades and the other produces a few long exposures. The evaluation objective must specify the population and horizon before choosing its denominator.

Consider a separate hypothetical accounting example. A position has an unrealized gain of eight units at one observation, then closes with a total realized gain of ten units at the next. If the first reward records the eight-unit mark-to-market change, the second incremental reward should record the remaining two units under that convention. Recording ten again would produce eighteen units and double-count the earlier gain. Alternatively, a terminal-only convention could record zero followed by ten. Both can describe the same total under appropriate definitions; mixing them cannot.

Costs need the same attention. If a simulated trade reward already deducts an entry cost of one unit, an evaluator that subtracts the same cost again changes the reward definition. If exit costs are missing entirely, the comparison has another bias. Nora traces a small number of actions through price, exposure, cash movement and reward, preserving each deduction. She does not rely on a field called net profit without checking what net includes in that particular file.

Currency conversion can create further differences. A reward recorded in the instrument’s quote currency is not automatically comparable with an account-currency reward. The conversion time and rate convention must be specified. Likewise, a fixed notional action and a percentage-of-equity action can experience different sizing paths. Nora keeps the teaching example’s abstract reward units separate from any financial ledger until those conventions are reconciled.

The audit includes flat decisions. A zero position does not necessarily mean every reward component is zero: a broader account objective might include operating costs or constraints, while a narrow trading-return objective might not. The appropriate definition follows the research question. What matters is that the same declared convention applies to the logging and target policies, and that any policy-dependent cost is modeled where the evaluation requires it.

Nora then checks aggregation across episodes. If an episode is truncated while a position is open, she records the chosen terminal treatment and tests a concrete example. If a simulator automatically closes at the last available quote, the reward includes an artificial exit imposed by the experiment. That may be acceptable for a defined finite-horizon task, but it should not be confused with the behavior of an indefinitely running policy.

Accounting consistency is a prerequisite for policy comparison. It does not solve selection bias, missing action support or market nonstationarity. It prevents those difficult problems from being layered on top of a simpler arithmetic mismatch. The resulting reconciliation becomes part of the evaluation packet, alongside action coverage and logging probabilities, so a second reviewer can reproduce both the evidence assumptions and the reward totals.

One useful completion criterion is that every row in the tiny fixture can be explained in ordinary language. The reviewer should be able to say which action occurred, which exposure existed afterward, what changed before the next observation and which costs entered the reward. If that explanation requires guessing a hidden convention, Nora keeps the evaluator in development. A larger archive will multiply the ambiguity rather than resolve it.

A prompt that starts with coverage, not optimization

Before testing a different target, Nora includes an identity check. If target and logging policies are identical and their recorded action probabilities are positive, each observed importance ratio should be one. In the first toy archive, the estimate should then return the original average of 0.6 units per opportunity. A different result signals a mismatch in probabilities, rewards, denominators or filtering. Passing this check does not validate the assumptions needed for another target, but failing it invalidates the implementation of this simple comparison. Nora saves the identity case alongside the unsupported-action case so later changes cannot quietly break either behavior.

Nora’s first AI request is an inventory: “Identify the unit of observation, available actions, logging policy, action probabilities, reward definitions and episode boundaries in these files. Separate known fields from inferred fields. Produce a context-action coverage report. Do not invent missing probabilities or treat simulated rewards as observed. State which proposed target-policy actions cannot be evaluated from this archive.” That request can be useful before any agent is trained.

Her second request supplies a tiny known example and asks the assistant to reproduce the arithmetic. It should recover observed reward sixty, always-trade estimate 1.2 and stochastic-target estimate 0.96 under the declared one-step assumptions. It should also reject division by zero in an unsupported action region. A tool that produces plausible numbers for every input, including impossible cases, is less useful than one that identifies where the calculation is undefined.

Only after those checks does she ask about a richer estimator or a constrained learning procedure. Reward design remains a separate topic; the article on reinforcement-learning trading rewards examines what the agent is asked to optimize. Here the central question is whether the evidence can support evaluation of the actions it proposes.

The free TradeAndRoll demo contains ten Forex systems, rules, source code, demo CSV data and research ideas. Those materials can support careful inspection and simulation under explicit assumptions. Begin by identifying what each file actually records. A transparent account of observed decisions and reconstructed alternatives provides a stronger starting point for agent research than treating every historical row as experience of a choice that was never made.

Back to the Blog