Skip to main content

johnnybt-trading

CI PyPI Python License: MIT

Runtime foundation for the johnnybt trading systems.

Four capabilities over one Tokio runtime, so a Python trading process gets concurrency without Python threads and without Python subprocesses: a timer, an embedded RESP server, an HTTP server, and async SQLite with a SQLAlchemy dialect. Everything asynchronous returns an ordinary awaitable, so it composes with asyncio like any other library.

There are no Python dependencies. Every capability is compiled into the extension module — a foundation that dragged a web framework and a database driver in behind it would not be a foundation.

pip install johnnybt-trading
# the SQLAlchemy dialect is optional
pip install "johnnybt-trading[sqlalchemy]"

Requires Python 3.14. That is the only version this is built against and tested on; the extension is compiled abi3, but nothing below 3.14 is claimed or supported.

Prebuilt wheels: Linux (x86_64, aarch64, musl x86_64), macOS (x86_64, arm64), Windows (x64) — one wheel per platform.

Timer

every ticks in Rust. A callback that runs long is a measured skip, not a silent drift, and never an overlapping run — the counters say which happened.

import johnnybt_trading as jbt

handle = jbt.every(0.2, tick, on_error=report, fire_immediately=True)
...
print(handle.fired, handle.skipped, handle.failed)
handle.cancel()

RESP server

RedisServer speaks enough Redis to be a real one to a client that cannot install anything to speak something else — which is the situation when the process on the far side is a broker terminal.

server = jbt.RedisServer(bind="127.0.0.1:6381", password=None, databases=16)
address = await server.start()
...
await server.stop()

Pub/sub is on the same object: server.publish(channel, payload) and server.subscribe(channel). A slow subscriber loses its oldest message rather than stalling the publisher.

HTTP server

Axum routing into Python coroutine handlers, plus a static directory served straight off disk.

server = jbt.HttpServer(bind="127.0.0.1:8080", on_error=report)
server.route("GET", "/healthz", lambda request: jbt.Response(b"ok"))
# Big files never enter Python: Range, conditional GET and compression for free.
server.static_dir("/assets", "dist/assets", cache_seconds=31536000, immutable=True)
address = await server.start()

SQLite

One connection per actor thread, ?-style parameters, and an event log that lives in the same database — which is what lets an event and the fact it describes commit together.

db = await jbt.connect("trades.db")
await db.execute("CREATE TABLE fills (id INTEGER PRIMARY KEY, code TEXT)")
await db.execute("INSERT INTO fills (code) VALUES (?)", ["002105.SZ"])

await db.create_event_schema()
await db.append_event("orders", "filled", b'{"code": "002105.SZ"}')
for event in await db.read_events("orders", after=0):
    ...

The SQLAlchemy async dialect registers itself, so sqlite+jbt:// resolves without an explicit call:

from sqlalchemy.ext.asyncio import create_async_engine

engine = create_async_engine("sqlite+jbt:///trades.db")

Pub/sub or event log?

Both ship, and they answer different questions. Pub/sub tells whoever is listening now — nothing is kept, a subscriber that was not there missed it. The event log tells whoever reads later — appended in order, read from a cursor, and durable in the same transaction as the change it describes.

Development

uv sync --all-extras --dev
uv run maturin develop --uv
uv run pytest
cargo test --lib

License

MIT

Metadata

Release files for johnnybt-trading 0.1.1

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

Source distribution (sdist)

Source distribution for johnnybt-trading 0.1.1
File Size Uploaded Provenance Actions
johnnybt_trading-0.1.1.tar.gz 130.4 kB Without provenance Details for johnnybt_trading-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for johnnybt-trading 0.1.1
File Actions
johnnybt_trading-0.1.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for johnnybt_trading-0.1.1-cp311-abi3-win_amd64.whl
johnnybt_trading-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for johnnybt_trading-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
johnnybt_trading-0.1.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for johnnybt_trading-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
johnnybt_trading-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for johnnybt_trading-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 17.2 MB

Release files / johnnybt_trading-0.1.1.tar.gz

Download URL johnnybt_trading-0.1.1.tar.gz
Size 130.4 kB
Tags Source
SHA-256 checksum
How to use checksums
abf321a57365f173ec4137853ea888bd82f4cd79f32b6336fd3709d28a54a1a1
BLAKE2b-256 checksum
How to use checksums
64a83a5d9eefc7813d5a841143422fc0da8019ff9e1b7d6ba70300a317a65b16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-win_amd64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-win_amd64.whl
Size 2.8 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f940fbcd3b86955fb85fa2e9db37355bbb349a36deed6bff0e2fcb05c82faca7
BLAKE2b-256 checksum
How to use checksums
f97b36879afaef26136ea90b775e143aa4f552ee5a2519120017e6eed9499e60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
Size 3.2 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a11649bec57a14c83ca842845af1080de5bd488c8dbda5bcde43ddd5d92f55c5
BLAKE2b-256 checksum
How to use checksums
2b527cb1a3d7a00f1b919657d9acb39040497c0fa7097c25fd6a173964049c32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3711beebeb87e9aaebc8df3137092580f958b66821defaeaca6d65a480fce0e6
BLAKE2b-256 checksum
How to use checksums
471d0737250f14ffe666a14c85d979ae2ab4af981e1ec30aca4cc0f0e757ef49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.8 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
1b341094a2f8dde06f6871e60c590db43b3e4c8ef36591c5d8ffc278272831de
BLAKE2b-256 checksum
How to use checksums
4f629c84a28549ea8e118830546e94190ae82e112a28cba2996b20d42f20be92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Size 2.7 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3b5d570cd7714b8311024e478a1d7810d0d4f4df8b5fa267bafc97bc4a8feaa4
BLAKE2b-256 checksum
How to use checksums
dca8b411ca8616f34ec12de1542aa052d9e3466512294107d3bc3339b0477a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / johnnybt_trading-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL johnnybt_trading-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 2.8 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
af4ec5673206daabc2907278e2fc63d73df31a434ba962c64e21959e2df3f4ab
BLAKE2b-256 checksum
How to use checksums
0b6f0a509f2e9ced9f7973403056edbe79cbcc1f1b4e4f75786671c4f75fd0ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for johnnybt-trading 0.1.1

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.1 This release

7 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