Skip to main content

Chronopype

CI codecov Python 3.13+ PyPI License: MIT Docs

A flexible clock implementation for real-time and backtesting scenarios in Python. Chronopype provides a robust framework for managing time-based operations with support for both real-time processing and historical data backtesting.

Features

  • 🕒 Flexible Clock System: Support for both real-time and backtesting modes
  • 🔄 Processor Framework: Extensible system for implementing time-based operations with retry and timeout support
  • 🌐 Network-Aware: Built-in network processor with automatic reconnection and exponential backoff
  • ⚡ Async Support: Full async/await support for efficient I/O operations
  • 📊 Performance Monitoring: Built-in execution time tracking, percentile statistics, and lagging processor detection
  • 🔒 Type Safe: Fully typed with MyPy strict mode
  • 🧪 Well Tested: Comprehensive test suite with high coverage

Installation

# Using pip
pip install chronopype

# Using uv
uv add chronopype

Quick Start

Here's a simple example of using chronopype:

import asyncio
import time

from chronopype import ClockConfig, ClockMode
from chronopype.clocks import RealtimeClock
from chronopype.processors import TickProcessor


class MyProcessor(TickProcessor):
    async def async_tick(self, timestamp: float) -> None:
        print(f"Processing at {timestamp}")


async def main():
    config = ClockConfig(
        clock_mode=ClockMode.REALTIME,
        start_time=time.time(),
        tick_size=1.0,  # 1 second ticks
    )

    async with RealtimeClock(config) as clock:
        clock.add_processor(MyProcessor())
        await clock.run_til(config.start_time + 10)


if __name__ == "__main__":
    asyncio.run(main())

Core Components

  • Clocks: Base implementations for time management

    • RealtimeClock: For real-time processing with drift compensation
    • BacktestClock: For deterministic historical data simulation
  • Processors: Framework for implementing time-based operations

    • TickProcessor: Base class for all processors
    • NetworkProcessor: Network-aware processor with automatic reconnection

Documentation

Full documentation is available at gianlucapagliara.github.io/chronopype.

Development

Chronopype uses uv for dependency management and packaging:

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run type checks
uv run mypy chronopype

# Run linting
uv run ruff check .

# Run pre-commit hooks
uv run pre-commit run --all-files

Metadata

Release files for chronopype 0.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chronopype 0.8.3
File Size Uploaded Provenance Actions
chronopype-0.8.3.tar.gz 102.1 kB Without provenance Details for chronopype-0.8.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chronopype 0.8.3
File Interpreter ABI Platform Actions
chronopype-0.8.3-py3-none-any.whl Python 3 none any Details for chronopype-0.8.3-py3-none-any.whl

Total release size: 127.6 kB

Release files / chronopype-0.8.3.tar.gz

Download URL chronopype-0.8.3.tar.gz
Size 102.1 kB
Tags Source
SHA-256 checksum
How to use checksums
604c8d0422ba1210efa66e0cbc2e63b18d329f5a089058084d6f147f5e35ec81
BLAKE2b-256 checksum
How to use checksums
142a817e8153bbcccf9c549c625fc33a47c0a1bcbabb3601c3533cc128380c7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / chronopype-0.8.3-py3-none-any.whl

Download URL chronopype-0.8.3-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e2c8069923a6a1692566b72f5d2a240d28e698835ba1cbbb0f8d4c21e100a58
BLAKE2b-256 checksum
How to use checksums
0b666c0726ca650846254cb26cd445f8a2f4470878e248f65368a8fddae1a564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for chronopype 0.8.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page