Skip to main content

An all-in-one tool to assess the latency of crypto exchange APIs.

Project description

ticktracer

ticktracer is a simple Python application that allows you to trace your latency to crypto exchanges, and was developed to analyze the shortest latency for exchanges hosted on Alibaba Cloud. Because the machine running ticktracer and the target exchange leverage the same NTP Provider, we can safely assume that the any clock skew between the two providers is negligible. You can verify the time synchronization status of your current machine through the command chronyc sources.

Currently only websocket data feeds are supported. It works by establishing a websocket connection to a crypto exchange api endpoint, decrypting the session with Wireshark under the hood, and comparing the timestamp of packets with those provided by the exchange. Packet timestamps are received by libpcap from the kernel and are not generated by ticktracer itself, unlike other open source projects. See here for more information.

Architecture overview

Supported Exchanges

  • Binance
  • Bybit
  • OKX

Requirements

Ticktracer has been tested on the following operating systems:

  • macOS >= 14.0
  • Debian >= 12.0
  • Ubuntu >= 22.0

In addition, the following external dependencies are required:

  • wireshark or tshark >= 4.0.7
  • libssh-dev for Debian-based systems or openssl for MacOS

Installation

MacOS

Install with Homebrew.

brew install wireshark openssl
python3 -m pip install ticktracer

Linux

Install with apt.

apt update && apt install wireshark libssh-dev
python3 -m pip install ticktracer

Usage

usage: ticktracer [-h] [-e EXCHANGE}] -p PAIR -d DURATION [-i INTERFACE]

options:
  -h, --help            show this help message and exit
  -e, --exchange_id {okx,binance,bybit}
                        The exchange to connect with.
  -p, --pair PAIR       The trading pair to monitor. Look up the specific format on the exchange's API documentation
  -d, --duration DURATION
                        Duration in seconds to monitor.
  -i, --interface INTERFACE
                        The network interface to listen on. Default is eth0 for Linux or en0 for macOS.

After the monitoring duration has elapsed, the script will output the average latency in milliseconds:

Total samples taken: 11567
Latency report:
+------------+-------------------------+
| Percentile | Latency in milliseconds |
+------------+-------------------------+
|    MIN     |          3.104          |
|    25%     |          9.151          |
|    50%     |          10.401         |
|    75%     |          11.762         |
|    90%     |          13.08          |
|    95%     |          14.102         |
|    99%     |          19.474         |
|   99.9%    |          32.975         |
|    MAX     |          48.023         |
+------------+-------------------------+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ticktracer-0.0.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ticktracer-0.0.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file ticktracer-0.0.1.tar.gz.

File metadata

  • Download URL: ticktracer-0.0.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ticktracer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0a494104d8057143dbd9a8446f764269236bf0f925af2f8bb4a6b75f37059fe2
MD5 f4137965916ae8a6564537e1ed175b5d
BLAKE2b-256 72b4a1155793346e50e7bb8119cb2b2a2bbf2ed764b2408e4b49b5cfd4919b83

See more details on using hashes here.

File details

Details for the file ticktracer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ticktracer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ticktracer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e404984844be9b2cc7d481d039410c179707e87b2739ceb616fa6b16e2d3a2a
MD5 972d472e6ac99bb966b9a8862bcb502e
BLAKE2b-256 05f092e4e3e58b57352b51552874eed9cf90dde81f1739686d113f859f8262ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page