Skip to main content

A flexible clock implementation for real-time and backtesting scenarios

Project description

Chrono Pypeline

CI codecov Python 3.13+

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
  • 🌐 Network-Aware: Built-in network processor with retry and backoff capabilities
  • Async Support: Full async/await support for efficient I/O operations
  • 🛠️ Easy to Use: Simple API for managing time-based operations
  • 📊 Performance Monitoring: Built-in performance tracking and statistics
  • 🔒 Type Safe: Fully typed with MyPy strict mode
  • 🧪 Well Tested: Comprehensive test suite with high coverage

Installation

# Using pip
pip install chronopype

# Using poetry
poetry add chronopype

Quick Start

Here's a simple example of using chronopype:

import asyncio
from chronopype import ClockConfig
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():
    # Configure the clock
    config = ClockConfig(
        start_time=time.time(),
        tick_size=1.0  # 1 second ticks
    )

    # Create and configure the clock
    async with RealtimeClock(config) as clock:
        # Add your processor
        clock.add_processor(MyProcessor())

        # Run for 10 seconds
        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
    • BacktestClock: For historical data processing
  • Processors: Framework for implementing time-based operations

    • TickProcessor: Base class for all processors
    • NetworkProcessor: Network-aware processor with retry capabilities

Development

chronopype uses Poetry for dependency management and packaging:

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run type checks
poetry run mypy .

# Run linting
poetry run pre-commit run --all-files

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

chronopype-0.2.9.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.

chronopype-0.2.9-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file chronopype-0.2.9.tar.gz.

File metadata

  • Download URL: chronopype-0.2.9.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for chronopype-0.2.9.tar.gz
Algorithm Hash digest
SHA256 2b0ea239e15e2f43556f887281b7a2c15d0dbfa0aa6e6b76f3eb4ccd89fe7dc0
MD5 d47cd8b55b34551bbcdfee148e4b6a63
BLAKE2b-256 99023139bc6edae0d620d90c5d25532af4eff649c82bb17c7c4c8270cb05b0d4

See more details on using hashes here.

File details

Details for the file chronopype-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: chronopype-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for chronopype-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca12678b24413f2c4dd65f9fada5699bec2f6c182ba31c5d3c289fac9e0e65f
MD5 cac27683bea685a487b4dbfe7470fd73
BLAKE2b-256 bd8b39e37c3cd7ef252eea05e5736238f6e3ba9ce54b298890ae89314516b0e2

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