Thin broker-agnostic execution layer for trading: order submission, status, and fills
Project description
pyactuator
Thin broker-agnostic execution layer for trading systems: submit orders, poll status, cancel, and (optionally) subscribe to fills. Designed to sit between your FSM/OMS (e.g. pystator) and broker APIs (Alpaca, future IB/crypto).
Features
- Normalized types:
OrderRequest,OrderResponse,OrderStatus,Fill— your stack stays broker-agnostic. - ExecutionClient protocol: One interface (
submit,get_status,cancel, optionalsubscribe_fills) implemented per broker. - Adapters: Alpaca (via alpaca-py), Mock (in-memory for tests and paper).
- Optional helpers: Retry policy, idempotency key handling, timeout wrapper.
Installation
# Core only (types, protocol, mock adapter)
pip install pyactuator
# With Alpaca broker support
pip install pyactuator[alpaca]
# Development
pip install -e ".[dev]"
Quick start
from decimal import Decimal
from pyactuator import ExecutionClient, OrderRequest, Side, OrderType, TimeInForce
from pyactuator.adapters.mock import MockExecutionClient
# Use mock for tests or paper
client: ExecutionClient = MockExecutionClient()
order = OrderRequest(
client_order_id="my-order-001",
symbol="AAPL",
side=Side.BUY,
quantity=Decimal("10"),
order_type=OrderType.MARKET,
time_in_force=TimeInForce.DAY,
)
response = await client.submit(order)
print(response.success, response.external_order_id)
status = await client.get_status(response.external_order_id)
await client.close()
With Alpaca (requires pip install pyactuator[alpaca]):
from pyactuator.adapters.alpaca import AlpacaExecutionClient
client = AlpacaExecutionClient(
api_key="...",
api_secret="...",
paper=True,
)
# Same OrderRequest / submit / get_status / cancel
Optional retry wrapper and idempotency helpers:
from pyactuator.helpers import RetryExecutionClient, generate_client_order_id
from pyactuator.adapters.alpaca import AlpacaExecutionClient
client = AlpacaExecutionClient(api_key="...", api_secret="...", paper=True)
client = RetryExecutionClient(client, max_attempts=3)
order_id = generate_client_order_id(prefix="pa", order_id="my-internal-id")
order = OrderRequest(client_order_id=order_id, symbol="AAPL", side=Side.BUY, quantity=Decimal("10"), ...)
Integration with pystator
Your FSM or OrderManager receives an ExecutionClient (injected or constructed). When the FSM triggers "submit" (e.g. after risk approval via pyfortis), call await client.submit(order_request). pystator stays broker-agnostic; execution is behind this single interface.
License
MIT.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyactuator-0.0.5.tar.gz.
File metadata
- Download URL: pyactuator-0.0.5.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f67cd274b6fcd35dd8cf4f3e1818ebe49b975b910d4834acaddaa8531cf85a
|
|
| MD5 |
acc0b46a79be8c9d7f7a518dc1ac1b9e
|
|
| BLAKE2b-256 |
bcabd7896497acf3316bb4b7309a62d996b5b250a7a427ef67bef6cd4b54fefe
|
File details
Details for the file pyactuator-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pyactuator-0.0.5-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56db9ce80338d99552785441f38cb139dadba0fefc4e8770382dc9c505db3b7a
|
|
| MD5 |
ded585c2753ce7af38a0bbb3d8587d71
|
|
| BLAKE2b-256 |
a8616ecf9054d88d01865d5fded06a6dd29eb3571705e59d0d16266c138dc2ab
|