Skip to main content

actchain: Asynchronous Crypto Trading Chain

pytest

Installation

pip install actchain

Requires Python 3.11 or higher.

Usage

# An example of using actchain to compute the weighted mid price of the order book

from typing import AsyncGenerator

import asyncio
import actchain
import ccxt.pro as ccxt_pro


async def loop_binance_orderbook() -> AsyncGenerator[dict, None]:
    exchange = ccxt_pro.binance()
    while True:
        yield await exchange.watch_order_book("BTC/USDT")


async def order_book_feature_computation(event: actchain.Event) -> dict:
    best_ask = event.data["asks"][0]
    best_bid = event.data["bids"][0]

    w_mid = (best_ask[0] * best_ask[1] + best_bid[0] * best_bid[1]) / (
        best_ask[1] + best_bid[1]
    )
    mid = (event.data["asks"][0][0] + event.data["bids"][0][0]) / 2
    return {"w_mid": w_mid, "mid": mid}


async def main() -> None:
    flow = (
        actchain.Flow("main")
        .add(actchain.Loop(loop_binance_orderbook).as_chain())
        .add(actchain.Function(order_book_feature_computation).as_chain())
        .add(actchain.Function(lambda event: print(event.data)).as_chain())
    )

    await flow.run()


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

Metadata

Release files for actchain 0.1.2

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

Source distribution (sdist)

Source distribution for actchain 0.1.2
File Size Uploaded Provenance
actchain-0.1.2.tar.gz 25.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 38.8 kB

Release files / actchain-0.1.2.tar.gz

Download URL actchain-0.1.2.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ea65504914a6f66d55654af3f727e9489ced5c1f5e7a71e17b4e570e22f56e71
BLAKE2b-256 checksum
How to use checksums
f2360c313dda898e1fc7b61795d47bdaf83b18a901c1623798b06ced60b3b100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.0 Darwin/23.0.0

Release files / actchain-0.1.2-py3-none-any.whl

Download URL actchain-0.1.2-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d078c3d62731409ecd0b4f8897e1814c1140442eace6521af74d177668f67da5
BLAKE2b-256 checksum
How to use checksums
26f44f81d6d2aadef2f6667aa441263b68a814301b02b173b9737f47613bd043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.0 Darwin/23.0.0

Security for actchain 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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