A fast, pure Python reader for MetaTrader 5 .tkc tick history files
Project description
pytkc
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa692c57fb4261dbc99108d0b4fb56b4c328f603f92308c17353c2cafaafd7a
|
|
| MD5 |
f78314566960991503541eabc0c21821
|
|
| BLAKE2b-256 |
3126728a998a2fdb9a557454640cfe97f2da7a831d3011ac41037c0fb502349d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e7dd4daa75360ead940ad3a149af54d919fbf5a77614951d11d4f04201f90d8
|
|
| MD5 |
c7acb4ec901451a0eccec45c891d4173
|
|
| BLAKE2b-256 |
2717ce1124d99f8fd0df6728266c0c1ea354fd3c67ddce317a67f71c82cf873b
|