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.4.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.4-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chronopype-0.2.4.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.0.0

File hashes

Hashes for chronopype-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9c725d372f6d2ee8f4c71cc6c4c94025e2a089a7c5cd58a0f36299ec5b73d450
MD5 284a83a6bca49c047df7f9bc2424a5f5
BLAKE2b-256 18389c131071904fb5380c1e1510d78af6ce238ac75f243bf75b244d2c24330e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chronopype-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.0.0

File hashes

Hashes for chronopype-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 204dc4d5e4a245a2e43004198410931d2554f30da6fd3e5912a26d61c05414b3
MD5 ffb3a0bf366f1850a5875ed92d3ce0c8
BLAKE2b-256 7651ef62e16381682a77897cd041535c560600a26d2b7895fa0863a6d3914316

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