Skip to main content

A fast, pure Python reader for MetaTrader 5 .tkc tick history files

Project description

pytkc

PyPI version Python versions License: MIT Tests

Pure Python reader for MetaTrader 5 .tkc tick history files.

Features

  • Pure Python, no compiled dependencies required
  • Streaming iterator for memory-efficient processing
  • Dataset API for multi-file access
  • Export to CSV, Pandas, NumPy, Apache Arrow, Parquet, and Feather
  • Custom exceptions for clear error handling
  • Validated against MT5 for XAUUSD, GBPUSD, EURUSD

Installation

pip install pytkc

For optional export formats:

pip install pytkc[pandas]    # Pandas support
pip install pytkc[numpy]     # NumPy support
pip install pytkc[arrow]     # Arrow/Parquet/Feather support
pip install pytkc[all]       # All export formats

Quick Start

from pytkc import TKCFile

tkc = TKCFile("201901.tkc")

# Iterate over ticks
for tick in tkc:
    print(tick.timestamp, tick.bid, tick.ask)

# Export to Pandas
df = tkc.to_pandas()

Dataset API

from pytkc import Dataset
from datetime import datetime, timezone

ds = Dataset("D:/MT5/Samples")

# List symbols
print(ds.symbols())

# Iterate over ticks
for tick in ds.ticks("XAUUSD"):
    print(tick.timestamp, tick.bid)

# Date range
start = datetime(2019, 1, 1, tzinfo=timezone.utc)
end = datetime(2019, 12, 31, tzinfo=timezone.utc)
ticks = ds.between("XAUUSD", start, end)

Command Line

# Show file info
pytkc 201901.tkc --info

# Show first 20 ticks
pytkc 201901.tkc --head 20

# Export to CSV
pytkc 201901.tkc -o output.csv

Supported Python Versions

  • Python 3.10+
  • Tested on 3.10, 3.11, 3.12, 3.13

Validated Against MT5

Symbol Tick Count Prices Status
XAUUSD 45,021 Exact match
GBPUSD 46,262 Exact match
EURUSD 41,940 Exact match

License

MIT License - see LICENSE for details.

Disclaimer

pytkc is an independent implementation for reading .tkc files. It is not affiliated with, endorsed by, or supported by MetaQuotes Ltd. MetaTrader is a trademark of MetaQuotes Ltd.

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

pytkc-0.3.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

pytkc-0.3.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file pytkc-0.3.0.tar.gz.

File metadata

  • Download URL: pytkc-0.3.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pytkc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 aaa692c57fb4261dbc99108d0b4fb56b4c328f603f92308c17353c2cafaafd7a
MD5 f78314566960991503541eabc0c21821
BLAKE2b-256 3126728a998a2fdb9a557454640cfe97f2da7a831d3011ac41037c0fb502349d

See more details on using hashes here.

File details

Details for the file pytkc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytkc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pytkc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e7dd4daa75360ead940ad3a149af54d919fbf5a77614951d11d4f04201f90d8
MD5 c7acb4ec901451a0eccec45c891d4173
BLAKE2b-256 2717ce1124d99f8fd0df6728266c0c1ea354fd3c67ddce317a67f71c82cf873b

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