Clock Synchronization and PTP
Accurate clocks are vital for timestamps, latency measurement and regulation. Learn how NTP and PTP work, MiFID II and CAT clock rules and how to check your clocks.
Every timestamp a trading system records is only as good as the clock that produced it. Computer clocks drift, gaining or losing time every day. Without synchronisation, two servers can disagree by many milliseconds, making events appear in the wrong order, latency measurements meaningless and audit records unreliable. Regulators require firms to keep clocks within set limits of official time. The two main tools are NTP for everyday accuracy and PTP for precision measured in microseconds or better.
Why clock accuracy matters#
| Use | Problem with a bad clock |
|---|---|
| Ordering events across servers | Fills appear before the orders that caused them |
| Latency measurement | Negative or wildly wrong latencies. See Exchange vs Receive Timestamps and Latency Measurement |
| Audit trails | Records fail regulatory standards. See Logging, Audit Trails and Incident Response |
| Signed API requests | Brokers and exchanges reject requests with timestamps too far off |
| Scheduled actions | Jobs run at the wrong moment |
NTP versus PTP#
| NTP (Network Time Protocol) | PTP (Precision Time Protocol, IEEE 1588) | |
|---|---|---|
| Typical accuracy | Around a millisecond on a good network; worse over the internet | Sub microsecond with suitable hardware |
| Hardware needs | None special | Network cards and switches with hardware timestamping |
| Time source | Public or private NTP servers | Grandmaster clock, often GPS disciplined |
| Typical users | Most servers, retail systems | Exchanges, high frequency firms, regulated firms with strict requirements |
Regulatory requirements#
| Regulation | Requirement (summary) |
|---|---|
| EU MiFID II (RTS 25) | Clocks synchronised to UTC; for high frequency algorithmic trading, maximum divergence of 100 microseconds with 1 microsecond timestamp granularity; looser limits for other activity |
| US Consolidated Audit Trail | Industry member clocks synchronised within 50 milliseconds of NIST time for most systems, with tighter rules for exchanges |
Firms must also document their synchronisation and be able to show traceability to UTC.
How PTP achieves precision#
- A grandmaster clock, usually locked to GPS or another reference, provides the time.
- Messages are timestamped in hardware by network cards as they leave and arrive, removing software delays.
- Switches correct for their own delays (boundary or transparent clocks).
- Clients calculate the offset and network delay from exchanged messages and adjust.
Checking your clocks on Linux#
| Command | Shows |
|---|---|
timedatectl status | Whether synchronisation is active |
chronyc tracking | Current offset and stability with chrony |
chronyc sources -v | Which time servers are used |
ptp4l and phc2sys logs | PTP synchronisation state |
Chrony is a common modern NTP implementation and generally keeps time more accurately than older tools. Monitor the offset as a metric and alert if it exceeds your tolerance. See Monitoring and Logging Systems.
Best practices#
- Use nearby, reliable time sources, several of them.
- Never let clocks jump during trading: slew (gradually adjust) instead of stepping.
- Monitor offsets continuously and record them.
- Use monotonic clocks for durations and synchronised wall clocks for timestamps.
- Store timestamps in UTC. See Timestamps, Time Zones and Daylight Saving.
Frequently asked questions#
What is PTP in trading?#
The Precision Time Protocol, which synchronises clocks across a network to sub microsecond accuracy using hardware timestamping, used by exchanges and latency sensitive firms.
Is NTP accurate enough for trading?#
For most retail and many institutional uses, yes; strict regulatory requirements for high frequency trading typically call for PTP.
What are the MiFID II clock synchronisation rules?#
Firms must synchronise to UTC within set limits, with the strictest being 100 microseconds divergence and 1 microsecond granularity for high frequency algorithmic trading.
You have finished the Infrastructure track. Continue with machine learning in Machine Learning in Trading.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Where this leads
- Machine Learning in TradingMachine Learning
Mentioned in
- VPS, Cloud and Bare-Metal ServersTrading Infrastructure
- FPGAs and Hardware AccelerationTrading Infrastructure
- Binary ProtocolsTrading Infrastructure
- Latency in TradingOrders and Execution