Clock Synchronization Ptp For Trading Hostsのロゴ

Clock Synchronization Ptp For Trading Hosts

コミュニティ
HimanshuJ16
clock-synchronization-ptp-for-trading-hosts

Linuxの取引ホストで時刻同期スタック自体を構築または監査する場合に使用します。NICのハードウェアタイムスタンプ、グランドマスターのプロファイルに合わせたptp4l、システムクロックに同期するphc2sysを設定し、linuxptpのテレメトリを報告どおりに解析します。

概要

公開者HimanshuJ16
リポジトリAlgo-Trading-Skills
スキル名clock-synchronization-ptp-for-trading-hosts
スター
50
フォーク
7
同梱ファイル
5
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 5個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    HimanshuJ16がGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Clock Synchronization Ptp For Trading Hosts」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/clock-synchronization-ptp-for-trading-hosts
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/clock-synchronization-ptp-for-trading-hosts .claude/skills/clock-synchronization-ptp-for-trading-hosts
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでClock Synchronization Ptp For Trading Hostsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にClock Synchronization Ptp For Trading Hostsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Clock Synchronization Ptp For Trading Hostsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

When to Use

Use this skill when standing up or auditing the time-synchronization stack itself on a Linux trading host: NIC hardware timestamping, ptp4l (grandmaster → PTP Hardware Clock), phc2sys (PHC → CLOCK_REALTIME), and the telemetry that evidences all three are working.

PTP (IEEE 1588) exists here because software NTP over UDP carries millisecond-scale OS scheduler jitter and cannot evidence a microsecond-scale bound. Hardware timestamping on a PTP-capable NIC takes the timestamp at the wire, outside the kernel network stack.

PtpClockSyncManager in scripts/ parses ptp4l/phc2sys output and returns a fail-closed sync verdict. It is a telemetry reader, not a controller.

When NOT to Use

  • As the enforcement point. This module reports; it does not halt trading. Threshold escalation, holdover grace and the latched kill-switch belong to clock-drift-monitoring-alerting-thresholds. Do not build a second, divergent set of thresholds here.
  • As proof that timestamps are correct. A perfectly synchronized clock on the wrong timescale reads as green — see the TAI/UTC pitfall below. Offset telemetry measures agreement with the source, never correctness of the source or the timescale.
  • To repair already-written timestamps. That is clock-skew-correction-for-tick-timestamps.
  • As a substitute for the RTS 25 Article 4 traceability system. Article 4 requires a documented, annually reviewed traceability system — design, functioning, specifications, and the exact point at which each timestamp is applied. This is evidence produced inside that system, not the system.
  • On a host without a PTP-capable NIC. Software timestamping (ptp4l -S) degrades accuracy by orders of magnitude and cannot support a 100 µs claim. If the NIC has no PHC, the answer is different hardware, not different flags.
  • Under concurrency, unguarded. PtpClockSyncManager is not thread-safe. Drive it from one reader loop or wrap it in your own lock.

Prerequisites

  • A PTP-capable NIC. Confirm with ethtool -T <iface> — you need SOF_TIMESTAMPING_TX_HARDWARE, SOF_TIMESTAMPING_RX_HARDWARE, SOF_TIMESTAMPING_RAW_HARDWARE and a non-none PTP Hardware Clock index. This is a hardware property; no flag substitutes for it.
  • linuxptp (ptp4l, phc2sys) installed, and the grandmaster's PTP profile documented: transport, domain number, delay mechanism and message rates. Every one of these must match or the port never leaves LISTENING.
  • Physical path to the grandmaster whose asymmetry you can characterise. PTP assumes a symmetric path; every nanosecond of asymmetry becomes half a nanosecond of fixed offset error that the servo cannot see and will never correct.
  • An out-of-band UTC reference for periodic timescale verification (see Pitfalls).
  • The divergence ceiling that binds your activity and jurisdiction — not a default. See references/standards.md.

Workflow

  1. Verify the hardware before writing any config. ethtool -T <iface>. If the PTP Hardware Clock index is none, stop: everything downstream is software timestamping wearing a PTP costume.

  2. Take the transport and domain from the grandmaster, not from a tutorial. linuxptp defaults to network_transport UDPv4; -2 selects IEEE 802.3 (L2). Neither is universally right — the Enterprise Profile (RFC 9760) mandates UDP over IPv4/IPv6, while the ITU-T telecom profile G.8275.1 uses L2 multicast. Choosing -2 because a document said so, against a UDP grandmaster, produces a host that never synchronizes. domainNumber must likewise match; a mismatched domain looks identical to "no grandmaster on the segment".

  3. Run ptp4l client-only with hardware timestamping. -H is already the linuxptp default; state it anyway so a config change cannot silently demote you. -s enables clientOnly (the old slaveOnly spelling is deprecated) and is what stops a trading host from ever advertising itself as a time source to its own venue segment.

  4. Run phc2sys with -w, and understand why. ptp4l keeps the PHC on the PTP timescale (TAI), which has no leap seconds. Per phc2sys(8), -w (absent -O) keeps the sink-to-source offset updated from the currentUtcOffset obtained from ptp4l. Omit both and CLOCK_REALTIME is disciplined onto TAI — a whole number of seconds away from UTC — while every offset reads in the single nanosecond digits.

  5. Confirm the port state transition, not just the offset. A healthy client walks INITIALIZING → LISTENING → UNCALIBRATED → SLAVE, and the servo walks s0 (unlocked) → s1 (clock step) → s2 (locked). An offset printed in s0 is a measurement, not a synchronization; treat it as unlocked no matter how small the number.

  6. Feed both daemons' output to PtpClockSyncManager, and set max_sample_age_s. The manager's state is sticky by construction: with staleness detection off, a daemon that dies leaves the last s2 and the last good offset latched forever and the host keeps reporting compliant with no time synchronization at all. Set the age to your log interval times a tolerance.

  7. Judge on combined_offset_ns, not max_offset_ns. The grandmaster→PHC offset and the PHC→CLOCK_REALTIME offset are serial error terms: an event stamped from CLOCK_REALTIME carries both. 60 µs on each leg is 120 µs on the record while the maximum reads a comfortable 60 µs.

  8. Verify the timescale out of band, on a schedule. Compare CLOCK_REALTIME against an independent UTC source. This is the only check that catches a correct-looking sync to a wrong or spoofed grandmaster, and it is the check the offset telemetry structurally cannot perform.

Full procedure: see references/workflows.md. Standards reference: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • phc2sys without -w or -O: a 37-second error that reports as zero. The PHC is on TAI. Without the UTC offset, CLOCK_REALTIME is disciplined to TAI and every timestamp the firm records is a whole number of seconds from UTC — a gross RTS 25 failure — while ptp4l, phc2sys and this module all report nanosecond agreement. This is the single most dangerous way to pass every green check and be entirely non-compliant.
  • Taking the maximum of the two offsets. They are serial, not alternatives. The maximum is not a bound on the error of the recorded timestamp; the sum of magnitudes is.
  • Treating a silent daemon as a healthy one. The common failure is not a drifting clock, it is a dead ptp4l. A parser with no staleness deadline never notices, because nothing arrives to trigger it.
  • A parser that drops the lines that matter. path delay can be negative in real logs, and a negative path delay is a symptom of bad hardware timestamps. A regex that requires unsigned digits rejects the whole line, so the manager keeps serving the last good sample and the fault is invisible. The same applies to message_tag, which most orchestrated deployments set — it inserts text between the daemon timestamp and the keyword and silently blinds a rigid pattern.
  • Reading rms from a summary line as if it were an offset. summary_interval and phc2sys -u emit rms N max M lines with no servo state. RMS is an average magnitude; the divergence ceiling is a bound on the worst case, so compare max.
  • Running ptp4l without -s/clientOnly. A trading host that wins a BMCA election starts serving time to the segment from its own free-running oscillator.
  • Forgetting phc2sys entirely. ptp4l alone disciplines the NIC's PHC. If the application stamps from CLOCK_REALTIME, that clock is still free-running.
  • Assuming -2 because the document said so. Transport, domain and delay mechanism are properties of the grandmaster's profile. Guessing produces a port stuck in LISTENING, which is at least loud — guessing the domain on a shared segment can instead sync you to the wrong grandmaster, which is not.
  • Ignoring path asymmetry. PTP cannot observe it. A different fibre length or an asymmetric switch path in each direction is a fixed, uncorrectable offset that no amount of servo tuning removes, and it does not appear in the offset telemetry.
  • Assuming 100 µs is "the clock rule". It is one row of one EU table. Non-HFT EU algo flow is bound to 1 ms; a US CAT reporter is bound by FINRA Rule 6820 to 50 ms — 500× looser. Enforcing 100 µs on flow it does not bind manufactures outages, not compliance.

Verification

  • Parse ptp4l[600.1]: [ens1f0] master offset 88 s2 freq -25937 path delay -2391; confirm the sample parses, with path_delay_ns == -2391. A rigid parser drops this line.
  • Feed 61,000 ns from ptp4l and 45,000 ns from phc2sys, both s2; confirm max_offset_ns == 61000, combined_offset_ns == 106000 and mifid_compliant is False.
  • Feed only phc2sys telemetry; confirm is_synced is False and reason no ptp4l telemetry — never a passing verdict on half a stack.
  • With max_sample_age_s=5.0, feed a locked pair, advance the injected clock past the deadline, and confirm the verdict flips to non-compliant with telemetry_stale.
  • Feed port 1: SLAVE to FAULTY on FAULT_DETECTED after a locked pair; confirm the verdict fails on the port state even though the last offsets were small.
  • Run python -m unittest discover -s skills/clock-synchronization-ptp-for-trading-hosts/scripts.

Related Skills

  • clock-drift-monitoring-alerting-thresholds
  • clock-skew-correction-for-tick-timestamps
  • cross-datacenter-clock-sync-validation
  • hardware-timestamping-vs-software-timestamping-accuracy
  • network-interface-level-tick-timestamping
  • mifid-ii-algo-trading-compliance-eu

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Clock Synchronization Ptp For Trading Hosts」では何ができますか?

Linuxの取引ホストで時刻同期スタック自体を構築または監査する場合に使用します。NICのハードウェアタイムスタンプ、グランドマスターのプロファイルに合わせたptp4l、システムクロックに同期するphc2sysを設定し、linuxptpのテレメトリを報告どおりに解析します。

TypingMindでClock Synchronization Ptp For Trading Hostsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Clock Synchronization Ptp For Trading Hostsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにClock Synchronization Ptp For Trading Hostsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/clock-synchronization-ptp-for-trading-hostsを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Clock Synchronization Ptp For Trading Hostsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Clock Synchronization Ptp For Trading Hostsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもClock Synchronization Ptp For Trading Hostsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Clock Synchronization Ptp For Trading Hosts」は無料ですか?

はい。HimanshuJ16がApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇