FoundationsIntroductory24 min read

The robot arrived an hour early: what a price timestamp really means

Understand time zones, candle boundaries and receipt times so a Forex robot uses only information that was available when it decided.

The robot buys at nine. On the chart, the entry looks reasonable: a strong candle has just finished and the rule is clearly written. Then you open the file and discover that “09:00” names the beginning of that candle. Its closing price will not be known until ten. The program has not found an extraordinary opportunity. It has received an hour of information that did not yet exist.

Another researcher converts the same rows to UTC and believes the problem is solved. The dates now end in Z, the columns are sorted, and the report looks professional. Yet the label still describes the start of the interval. Changing the clock’s representation does not change when its contents become known.

This article follows the temporal journey of a Forex observation: which instant it represents, which zone describes it, which interval it summarizes, and when a rule may use it. Every numerical record and outcome is hypothetical and educational; none describes trades or capabilities of TradeAndRoll. The aim is to learn how to question a file before allowing it to govern a decision.

You do not need to memorize every exception in the world’s calendars. You need to distinguish a few questions that often get mixed together. Once separated, they help you inspect a demo CSV, examine a robot’s rules, and ask an AI assistant for an implementation that respects the experiment’s timeline.

1. One row can contain several valid times

Imagine a quotation timestamped by its provider at 09:00:00.100 UTC. Your connection receives it at 09:00:00.145, the cleaning process finishes at 09:00:00.170, and the strategy decides at 09:00:00.200. These are not four incompatible versions of the time. They are four different events that should remain separate when the study’s resolution requires it.

Event time answers when something occurred according to the system recording it. Receipt time describes when it reached your environment. Processing time indicates when a derived observation became ready. Decision time fixes the point at which the robot must justify its information. The first field’s exact meaning depends on the provider: do not assume that it always comes from an exchange or a universal market clock.

In this example, forty-five milliseconds pass between the provider’s timestamp and receipt, and fifty-five between receipt and the decision. The total difference is one hundred milliseconds. These calculations represent interpretable latency only if the clocks are sufficiently synchronized and the timestamps mean what we have assumed. Subtracting two numbers does not establish that they measure compatible endpoints of a process.

Availability belongs to a particular decision. An observation may be stored in a historical file today but have arrived too late for an entry yesterday. It may also have been corrected later. If the file retains only the final version, it cannot independently reconstruct everything the robot saw in real time.

For a strategy acting at a daily close, a few milliseconds might not change the main research question. For another deciding immediately after an announcement, they can be decisive. The necessary resolution follows from the rule, rather than from however many decimal places make a table look sophisticated. Recording invented nanoseconds does not add information.

Start by writing a sentence for each time field you receive. “Start of the provider’s price interval, expressed in UTC” is useful. “Date” is not enough. If the documentation cannot answer, retain the uncertainty and limit the experiment. Do not complete the meaning with an assumption that later disappears from the report.

2. UTC compares instants; it does not explain sessions

Consider two descriptions: 09:30 with a positive two-hour offset, and 07:30 UTC. They describe the same instant. To obtain UTC, subtract the offset from local clock time: half past nine minus two hours gives half past seven. By contrast, 09:30 without an offset or a zone does not uniquely identify an instant.

RFC 3339 provides a date-and-time representation with an offset from UTC; its Z suffix represents UTC. It does not turn an incomplete date into a documented observation or define what a financial candle means. The distinction between format and semantics remains our responsibility. RFC 3339, timestamp representation.

Normalizing a copy to UTC makes it easier to order events from different sources, calculate differences, and compare records. Keep the original timestamp and the conversion rule too. If a problem appears, you will need to know whether the error came from the file, its interpretation, or its transformation. Overwriting the only time column removes precisely that evidence.

A shared instant does not imply a shared calendar. A strategy may be defined around a session’s local time, a provider’s operational close, or an announcement. Converting every observation to UTC does not authorize replacing that condition with a fixed UTC hour throughout the year. The trading rule and its technical representation solve different problems.

Suppose the design says “evaluate at nine in the chosen zone.” If that zone alternates between one-hour and two-hour offsets, the evaluation corresponds to eight or seven UTC respectively. Programming eight throughout the year changes the robot’s relationship to that session for part of the calendar. You may want to investigate that variant, but it needs its own name and an explicit explanation.

Also avoid sorting strings with mixed formats and concluding that you have sorted instants. A string with a positive offset may appear earlier alphabetically while representing a later moment. First interpret valid dates with their zones; then sort the resulting instants. Local display can remain available for human reading without controlling the logic.

Nine thirty with a two-hour positive offset equals seven thirty UTC.
Converting a time changes its representation, not the instant it describes.

3. A time zone contains history; an offset does not

An offset says how far a clock is from UTC at one moment. A geographically identified zone incorporates rules that may vary with the date. The difference looks small but becomes substantial when processing several years. Applying today’s observed offset to an entire history can move some decisions without producing any arithmetic error.

IANA’s time zone database maintains historical rules and offsets for representative locations and is updated when those rules change. Record both the zone and the data version used in a reproducible transformation. An informal abbreviation should not be treated as an adequate contract. IANA, time zone database.

Imagine a file labelled “server time.” You do not yet know whether the server uses UTC, a particular civil zone, or a provider-specific calendar. Its agreement with your clock for one week does not establish historical equivalence. You need its specification or bounded evidence for the affected dates. Guessing from the appearance of closing times may generate a diagnostic hypothesis, but it cannot replace provenance.

Assign a zone only when you know the original interpretation. Assigning explains which instant an unzoned local clock represented. Converting shows an already identified instant on another clock. Confusing these actions can shift an entire history while leaving all its intervals apparently regular.

A useful review selects dates from different parts of the year and compares events with documented time references. If the discrepancy changes, investigate the calendar before introducing a manual correction by month. A customized repair may match the observed points and still fail in earlier years, at a transition, or after a rule change.

The research record should preserve the transformation and its justification. State which source defines the zone, which dates it covers, and what uncertainty remains. If a new export arrives with a different configuration, do not automatically reuse the previous interpretation. The instrument and provider names can stay unchanged while an export preference changes.

4. The repeated hour and the hour that never happened

When a transition moves clocks backward, the same local time can occur twice. Imagine the clock moving from 03:00 to 02:00: the label 02:30 then corresponds to two instants, one with the previous offset and another with the new offset. Removing a row as a duplicate before resolving the zone can delete a legitimate event.

In the opposite transition, an interval of local times may not exist. If the clock jumps from 02:00 to 03:00, the label 02:30 does not identify a valid instant under that rule. Automatically shifting it to half past three may be a repair policy for some applications, but it changes the record. It should not be silently applied to prices without understanding their origin.

Python’s documentation demonstrates how an IANA zone and the fold attribute distinguish the two occurrences of an ambiguous time. The tool can represent the problem; source information is still needed to choose the correct occurrence. Python, handling transitions with zoneinfo.

An ambiguous date is unresolved information, not an invitation to guess. If the file includes each row’s offset, the ambiguity may be resolved. A reliable sequence counter or an independent UTC timestamp can also help. If there is only an isolated local time, a unique reconstruction may be impossible, requiring exclusion or a restriction on that segment.

Testing a transformation requires more than a normal date. Include cases immediately before and after a clock change, two repeated local times with different offsets, and a nonexistent label. Check that each case produces the intended decision: unambiguous conversion, explicit rejection, or documented repair. A test result should state which meaning it verifies, rather than merely reporting that the program finished.

Forex trading interruptions can make a particular transition less visible in one provider’s data. That does not remove the problem from calendars, announcements, auxiliary series, or daily aggregates. The absence of trades in one sample does not prove that the clock can be ignored throughout the system.

Two local labels of two thirty with different offsets correspond to different UTC instants.
A repeated local hour can contain two different events rather than a duplicated row.

5. A candle’s timestamp is not necessarily its close

A candle summarizes an interval. We need its boundaries, which endpoints it includes, and which instant it uses as a label. Suppose an hourly candle collects events from nine inclusive to ten exclusive and is labelled nine. Its high and closing value are not complete at nine. They are outcomes of what happens during the following hour.

OANDA’s official candle definition describes its time field as the candle’s start and includes a completeness flag. This is a concrete example of why the column name is insufficient; other formats need their own documentation, without extrapolating this convention to everyone. OANDA, Candlestick definition.

A candle’s close can inform only decisions after it becomes available. In an idealized exercise, we can allow a decision at the boundary of ten once the interval is finished. In an actual implementation, we may need to wait for the provider to publish the observation and for the system to process it. The temporal condition depends on the experimental contract.

Imagine that the file contains open 100, high 104, low 99, and close 103 for the row labelled nine. A rule buying when the close exceeds 102 cannot evaluate that condition at the start. If the simulator uses the same candle’s opening value of 100 as its entry price, it combines an outcome known at the end with an earlier opportunity. A correct time zone does not repair that anticipation.

Nor is it enough to shift every signal by one row without examining gaps and granularity. The next row might begin two hours later because data are missing. “One row later” and “at the first executable price after the decision” coincide only under particular assumptions. Formulate the temporal rule first, then verify its implementation.

When a provider supplies a still-open candle, its extremes and provisional closing value can change. Decide whether the strategy uses intrabar updates or completed candles alone. Both investigations are possible, but they need different data and simulations. Saving the final candle at the end of a day does not reconstruct all the provisional versions a robot would have seen while it formed.

A candle labelled nine extends to ten, and its close becomes known when that interval ends.
The interval label and the time its content becomes known perform different jobs.

6. Aggregating prices also chooses boundaries

Building hourly candles from more frequent observations looks like a neutral operation. Yet choosing the intervals’ origin, boundaries, and labels determines which observations share a candle. A strategy based on highs, ranges, or closing values can change even though none of the original prices has been modified.

Take four hypothetical observations: 09:00 with value 100, 09:30 with 104, 10:00 with 101, and 10:30 with 103. With windows beginning at nine and excluding their right endpoints, the first candle contains 100 and 104; the second contains 101 and 103. If the event exactly at ten belongs to the previous window instead, that candle’s close and range can change.

Libraries provide controls such as which side of an interval is closed, its label, and its aggregation origin. The pandas resample documentation distinguishes these explicitly. The name “one hour” does not determine those choices on its own. pandas, resampling parameters.

A practical convention expresses each window as including its beginning and excluding its end. This is not a universal law; it is a choice that prevents an event exactly on a boundary from being assigned twice. If your source uses another convention, preserve it or convert explicitly. What matters is consistency between how candles are constructed and how they are used.

The time boundary is part of the rule being tested. A robot using a day that closes at midnight UTC is not necessarily the same robot as one using a day defined by another operational close. Their averages, ranges, and signals can differ. Such disagreement does not prove that a source is wrong; it may mean they summarize different windows.

Before comparing results across platforms, reconstruct two or three candles around a boundary by hand. List the observations belonging to each and verify the open, high, low, and close. This small exercise often reveals more than comparing thousands of rows without explaining their intervals. You can then extend the reconciliation to the complete sample.

7. The trading day needs its own definition

The word “day” can mean twenty-four elapsed hours, a local calendar date, a provider’s aggregation window, or an operational session. These concepts are related but not identical. A rule limiting entries to two per day must choose among them; otherwise, two reasonable implementations may open different numbers of trades.

Suppose one strategy resets its counter at midnight UTC. Another resets at the start of a session defined in a local zone. A trade near that boundary may consume the previous day’s allowance in one implementation and the following day’s allowance in the other. The problem does not appear in the signal formula, but in an operational state that also changes the strategy.

Calendars govern more than charts. They affect time filters, risk limits, order expiry, performance records, and holding periods. If daily profit is calculated with one calendar while a daily limit uses another, the report can appear inconsistent even when each isolated calculation is correct.

Describe the reset as an identifiable event: zone, local hour, treatment of non-trading days, and behavior when the expected event is missed. If the program remains disconnected across the boundary, it must know whether the counter resets on reconnection or preserves a state that no longer applies. This is a design question, rather than a detail best left to a default function.

An introductory investigation can choose a simple calendar while recognizing its scope. What it should not do is present that simplification as equivalent to every schedule used by an intermediary. Verifying specific execution conditions belongs to a later phase and may require revisiting the experiment.

It is also useful to distinguish attribution date from duration. A position opened before a boundary and closed afterward may be assigned by entry date, exit date, or results valued within each segment. No label automatically resolves the accounting. Choose a convention suited to the question and retain the original instants so alternative views can be reconstructed without changing the trades.

8. Combining two sources means comparing availability

Now add an external variable to the candles: an observation published at 10:00:00 and received at 10:00:02. The robot decides at 10:00:01. Although publication and decision share the same minute, that version of the observation was not yet available in its environment. Joining tables after rounding both timestamps to ten can introduce future information.

The comparison must use the time relevant to the question. If you study an ideal with instantaneous public availability, define it that way. If you intend to reconstruct your system’s operation, you need to approximate receipt and processing. Do not combine the most favorable timestamp from each source to manufacture a speed that no complete process achieved.

The date of a phenomenon and the date of knowledge are not interchangeable. An observation can describe the previous month and be published today. A correction can refer to that same month and arrive tomorrow. Linking it to every decision in the described month introduces a version that did not exist then. The observation’s economic calendar is not permission to use it at that time.

For a simple exercise, retain versions with availability timestamps and select, for each decision, the latest version already available. Add an age tolerance where relevant: a known value is not necessarily still useful. Also define what happens when no valid earlier version exists, rather than automatically filling from the future.

A small example makes the logic reviewable. At 10:00:01, only the previous value, 7, exists for the robot. At 10:00:02, the new value, 9, arrives. If the rule requires exceeding 8, the first decision cannot activate because of that update. A later decision might, provided the remaining conditions hold. We have not demonstrated a market advantage, only a coherent causal sequence.

The reasoning is developed further in future information and imputation. For now, retain that a correct temporal join needs more than sorted columns: it needs a definition of which version each decision could have known.

The decision at ten and one second precedes receipt of an update at ten and two seconds.
A published update may still not have reached the system making the decision.

9. Duplicates, gaps, and precision tell different stories

Two rows sharing a timestamp may be export duplicates, distinct events sharing the clock’s resolution, or revisions of an observation. Deleting all but one collapses three different problems into a single policy. Before deduplicating, identify what defines the record’s identity and which fields can distinguish its versions.

Imagine a file rounded to seconds that contains three quotations received within one second. Their written times match, but arrival order may matter to a rule. If the provider preserves a sequence, use it according to its meaning. If none exists, acknowledge that the within-second order is lost. Sorting by price to reconstruct a path would invent information.

A gap does not automatically mean the price remained constant either. It may represent an operational closure, no quotations, a connection interruption, or export loss. Filling it with the last known price can serve a visualization or a particular calculation, but it creates synthetic observations that must be identified. They do not show that the robot could trade at that price throughout the gap.

Written precision does not guarantee timing accuracy. A timestamp with six decimal places may come from a poorly synchronized clock or a conversion that appended zeros. Another with whole seconds may be adequate for a slow strategy. Assess uncertainty against the decision horizon and preserve original resolution to avoid a false sense of precision.

A useful audit classifies cases before repairing them. Count repeated timestamps, backward movements, unexpected intervals, and records outside the intended calendar. Then inspect representative examples and connect each category to a possible explanation. An aggregate percentage of valid rows cannot replace this investigation: a few events near entries may matter more than thousands of irrelevant gaps.

If you exclude a segment because of uncertainty, apply the criterion without looking at whether its trades win or lose. Retain the original segment and the reason for exclusion. Temporal cleaning can itself become opportunistic selection when its rules change after the robot’s results are observed.

A numeric time field also requires a unit and an origin. A counter expressed in milliseconds cannot be interpreted as seconds without radically changing the resulting date. Do not infer its unit solely from the number’s length: confirm the specification and verify an observation against a recognizable date. The program should reject ranges incompatible with the declared period instead of accepting any date its library manages to construct.

If an export transforms those numbers into text through a spreadsheet, also check what happened to precision. A rounded display may conceal that the saved file lost fractions or changed format. Retain a sample of original values and verify the conversion by reading the exported file again. This check does not establish clock synchronization, but it distinguishes a loss caused by the export from a limitation already present in the source. Both problems matter, yet they require different remedies and should remain separate in the audit record.

10. A small audit you can solve by hand

Let us construct a deliberately awkward sample. File A contains two hourly candles labelled by their starts: 09:00 and 10:00, both in a zone with a positive two-hour offset on those dates. File B records an external update at 08:00:02 UTC. We want to decide just after the first candle closes, at 08:00:01 UTC.

First convert the boundaries, not just the labels. The first candle covers 07:00 to 08:00 UTC; the second covers 08:00 to 09:00 UTC. At 08:00:01, the first can be complete under the ideal assumption of immediate publication; the second is still forming. The external update arrives one second after the decision and cannot participate.

Now add a three-second publication delay for candles. The first candle’s close does not become available until 08:00:03 UTC. The intended decision at 08:00:01 can no longer use it. The design must wait, abstain, or use another previously permitted information set. Choosing among those options is an explicit change to the procedure.

Record UTC interval or event Available for the 08:00:01 decision
First candle, immediate publication 07:00 to 08:00 Yes, under that assumption
Completed second candle 08:00 to 09:00 No
External update Received at 08:00:02 No
First candle, three-second delay Received at 08:00:03 No

This exercise shows why a test must include its publication assumption. The same row can be admissible in an idealized simulation and inadmissible in a delayed reconstruction. There is no need to debate the “correct time” in the abstract. We need to ask which process is being represented.

As an additional check, express every instant in the original zone again and confirm that the admissibility decisions do not change. The display may show ten instead of eight. The temporal relationship must remain unchanged. This invariance is a concrete test you can request from an AI coding assistant without asking it to guess what the file means.

11. Tests that seek errors, not merely well-formed files

A file can pass format validation and remain temporally incorrect. To look for interpretation errors, you need examples whose expected answers are known before the program runs. Begin with simple conversions, candle boundaries, and a decision between publication and receipt; then add ambiguous cases relevant to your sources.

A round-trip test checks that converting an instant to another zone and back preserves the original instant. Another verifies that a candle is not used before completion. A third deliberately introduces a future observation and requires rejection. These tests cover different properties; none can replace the others.

The best test case may be a decision the robot must reject. If every sample ends in a valid trade, the boundaries may never be tested. Include an incomplete candle, an unzoned timestamp, an observation that is too old, and receipt after the cutoff. The correct outcome can be abstention with a readable reason.

Do not compare only final profit across two implementations. Errors can cancel or accidentally produce the same total. Compare a sample of decisions: instant, observations used, version, condition evaluated, and first permitted execution. If they disagree, resolve the discrepancy before interpreting aggregate curves.

It is also useful to separate transformation tests from strategy tests. The first family asks whether the clock is interpreted correctly. The second asks whether the rule uses permitted instants. A library can convert zones flawlessly while the signal code reads a future candle’s closing value. Passing infrastructure tests does not absolve the model.

When working with an AI assistant, provide small cases and expected answers alongside the verbal description. Ask it to explain which information is missing in ambiguous cases. An answer acknowledging indeterminacy can be more useful than a program that always produces a date, especially when an invented date may eventually govern actual entries.

Four controls distinguish data format, time zone, interval and availability.
Timing controls should examine different meanings instead of repeatedly validating one format.

12. The temporal contract accompanying a robot

When reviewing rules and source code, look for a compact description of the system’s clock. It should explain which date each input represents, which zone it uses, when an observation ends, when it becomes knowable, and how the strategy behaves when information is missing. This need not become an endless document, but another person must be able to reproduce its decisions.

Preserving the source lets you question a transformation without rewriting history. Keep the received file, the applied interpretation, and the transformed version as distinguishable objects. Record corrections, excluded segments, and calendar settings. If only the final table remains, a later discrepancy may be impossible to investigate.

In TradeAndRoll’s context, the initial scope is Forex, and market CSV data belong exclusively to the demo. A sample file can help investigate these questions, but it does not establish compatibility with every provider or reconstruct live receipt events it never recorded. Rules and code need interpretation under the specific conditions of the environment where they are tested.

The next review can be practical. Choose a hypothetical entry, mark its decision instant, and list every observation it needs. For each one, write the earliest time it would have been available. If anything arrives later, you have found a dependency to correct or acknowledge. If you cannot determine availability, you have identified a material limitation, not permission to assume perfect access.

Then examine how the candle being used was constructed. The article on OHLC candle limits addresses the path information lost when prices are summarized. Timing and path are separate problems: a candle can be timestamped correctly while still failing to reveal which level was reached first.

A robot does not demonstrate predictive ability because its file is sorted or every date ends in Z. But an investigation can hardly stand if we do not know what it could have known at each decision. Clarifying that temporal contract turns an attractive chart into a sequence that can be discussed, reproduced, and, when appropriate, rejected for precise reasons.

Three clocks distinguish the original timestamp, the UTC instant and availability for a decision.
A readable date still needs a temporal interpretation.
Back to the Blog