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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chronopype-0.2.5.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.3.0

File hashes

Hashes for chronopype-0.2.5.tar.gz
Algorithm Hash digest
SHA256 bbf8c498a7d780386a951ffcd0a18fa44f8051e68b2ad2414c4adc6332f17210
MD5 09f490b34f14e47ccbea312902544669
BLAKE2b-256 3e636d8abd10afe2b2831b8c77146e09d20beb2ca16eaf291f34f6d524020007

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chronopype-0.2.5-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.3.0

File hashes

Hashes for chronopype-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5672ec5ab971cf875f23d0a69b5beb979885255210a08f3495bb02c045b14a63
MD5 db1b7472bb3579e4ff0beb74fd1a84a3
BLAKE2b-256 b7c5aabd8bc8a899c5fa65e4693aca761d176084a81efd7985c66b7bd1343563

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