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.1.tar.gz (14.0 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.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chronopype-0.2.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.1.0

File hashes

Hashes for chronopype-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9a6dfe45583c50e49ba52eb8b9ac64d5563eaec8d0eb3a8622003442445fecd8
MD5 da5a314bf94deb04324d02dcad61d621
BLAKE2b-256 314953d3e459beec7a50ee07153ccfe8aae7bc61025e2b000a364a327e48c784

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chronopype-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.1.0

File hashes

Hashes for chronopype-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e81fea37cd080dd2defaada4177960d3585a810c5ad4ba8c331ffb68450ed587
MD5 44b94ade35b5a26e4ba98688ea6f2f66
BLAKE2b-256 4bbf3d48aa6b2fa6a272e64494dc3f56a4b1ef11cc3e54eb1acad050d03b3ae9

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