Async execution layer for futures trading built on a broker SDK.
Project description
async-execution-da
Async execution layer for futures trading, built on top of a broker-provided Python SDK.
This project provides an async-first, production-oriented wrapper around a proprietary futures trading API, focusing on order execution, account queries, and event-driven workflows.
🚦 Project Status
- Status: Active development
- Stability: Used in live / paper trading environments by the author
- Python: 3.10 (tested)
- License: MIT
✨ What This Project Is
async-execution-da is an asynchronous execution layer designed for:
- Futures / derivatives trading systems
- Quantitative trading infrastructure
- Event-driven execution engines
- Developers who need non-blocking broker interactions
It wraps a broker-provided synchronous SDK and adds:
- Async connection & login flows
- Deterministic account mapping
- Structured capital queries
- Robust order helpers (market / limit / stop)
- Local
OrderBookfor order ID reconciliation - Async event queue for broker callbacks
🚫 What This Project Is NOT
- ❌ A trading strategy or signal generator
- ❌ A backtesting framework
- ❌ A broker SDK
- ❌ A replacement for risk management
This project focuses strictly on execution and broker interaction.
⚠️ Important Notice (Proprietary Dependency)
This project does NOT include or redistribute any proprietary broker SDKs.
You must obtain and install the broker-provided Python package (pyda) separately.
Reasons:
- The broker SDK is not open-source
- It is not published on PyPI
- Redistribution may violate broker licensing terms
This repository only contains original open-source code written by the author.
📦 Requirements
-
Python 3.10+ (3.11 not yet supported)
-
Broker SDK providing:
pyda.apipyda.api.td_constant
ℹ️ If
pydais not installed, importing execution APIs will raise a clearImportErrorexplaining the missing dependency.
📥 Installation
Option 1: Editable install (recommended for development)
pip install -e .
Option 2: Install directly from GitHub
pip install git+https://github.com/Reece-Lu/async-execution-da.git
⚠️ Ensure the broker SDK is installed before running the code.
🚀 Quickstart
import asyncio
from async_execution_da.api_layer.future_api import EnhancedFutureApi
async def main():
api = EnhancedFutureApi(
userid="YOUR_USER",
password="YOUR_PASS",
author_code="YOUR_AUTH",
computer_name="M3Server",
software_name="M3Algo",
software_version="1.0",
tag50="TAG",
address="HOST:PORT",
heartbeat=180,
symbol="ES2603",
exchange="CME",
)
await api.connect_and_login_with_accounts()
account_no = api.getAccountNo("USD")
print("Account No:", account_no)
usd_info = await api.query_account("USD")
if usd_info:
print("Available Funds:", usd_info.TodayTradableFund)
asyncio.run(main())
🧩 Core Usage
Connect & Login
await api.connect_and_login_with_accounts()
Query Account / Capital
usd_info = await api.query_account("USD")
if usd_info:
print(usd_info.FundAccountNo, usd_info.TodayRealtimeBalance)
Place Orders
Limit Order
result = await api.limit_order(
local_no="11080745123456_entry",
side="buy",
price=4510.25,
volume=2,
)
Market Order
result = await api.market_order(
local_no="11080745123456_market",
side="sell",
volume=2,
)
Stop-Limit Order
result = await api.stop_limit_order(
local_no="11080745123456_stoplimit",
side="buy",
trigger_price=4500.0,
price=4501.0,
volume=2,
)
Stop-Market Order
result = await api.stop_market_order(
local_no="11080745123456_stopmarket",
side="sell",
trigger_price=4515.0,
volume=2,
)
Query & Manage Orders
orders = await api.query_order()
active = await api.query_active_orders()
Cancel Orders
await api.cancel_order_async("LOCAL_NO")
await api.cancel_all_active("USD")
Modify Orders
await api.modify_order_async(
local_id="LOCAL_NO",
side="buy",
new_volume=3,
orig_volume=2,
order_type=4,
new_trigger_price=5805.25,
orig_trigger_price=5900.25,
)
Close Open Positions
await api.check_and_close_positions()
📡 Events & Callbacks
Broker callbacks are converted into async events and published to event_queue.
async def event_listener(api):
while True:
evt = await api.event_queue.get()
print("EVENT:", evt)
This allows non-blocking, event-driven execution logic.
📘 OrderBook
OrderBook maintains a local mapping between:
local_nosystem_noorder_no
This is critical for:
- Reliable order cancellation
- Order state reconciliation
- Handling async broker callbacks
🗺️ Roadmap
- Better type hints and dataclasses
- Explicit order state machine
- Retry & reconnect policies
- Structured logging hooks
- Unit tests with mocked broker SDK
⚖️ License
MIT License
⚠️ Disclaimer
This project is an independent open-source wrapper.
It is not affiliated with, endorsed by, or supported by any broker or trading venue.
All proprietary SDKs, APIs, and trademarks remain the property of their respective owners.
Project details
Release history Release notifications | RSS feed
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 async_execution_da-0.1.0.tar.gz.
File metadata
- Download URL: async_execution_da-0.1.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dbf0a9f6d8cef36bdd341f572d21cfa169142310cd45d05e87f3d4b75164df6
|
|
| MD5 |
5b5544b489f05a8be5d804af02bd0b28
|
|
| BLAKE2b-256 |
88a919e9207d0312f5ea6de766c1419001f20e9680c644f7501f4477b9550dfb
|
Provenance
The following attestation bundles were made for async_execution_da-0.1.0.tar.gz:
Publisher:
publish.yml on Reece-Lu/async-execution-da
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_execution_da-0.1.0.tar.gz -
Subject digest:
0dbf0a9f6d8cef36bdd341f572d21cfa169142310cd45d05e87f3d4b75164df6 - Sigstore transparency entry: 804474086
- Sigstore integration time:
-
Permalink:
Reece-Lu/async-execution-da@f801af590cb160ff175fd055fbbc982569e86add -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Reece-Lu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f801af590cb160ff175fd055fbbc982569e86add -
Trigger Event:
release
-
Statement type:
File details
Details for the file async_execution_da-0.1.0-py3-none-any.whl.
File metadata
- Download URL: async_execution_da-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da17bf1026be96f55dc34d4cefff49005fe03888a2ed6d2b1d2a7f0e2e885059
|
|
| MD5 |
7c39b8c0a43631007d083b36730920a8
|
|
| BLAKE2b-256 |
2fd1f405b2084f6c145a0c55dc02f1b6fd40d3a3121d252cb6c64160d21e9958
|
Provenance
The following attestation bundles were made for async_execution_da-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Reece-Lu/async-execution-da
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_execution_da-0.1.0-py3-none-any.whl -
Subject digest:
da17bf1026be96f55dc34d4cefff49005fe03888a2ed6d2b1d2a7f0e2e885059 - Sigstore transparency entry: 804474106
- Sigstore integration time:
-
Permalink:
Reece-Lu/async-execution-da@f801af590cb160ff175fd055fbbc982569e86add -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Reece-Lu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f801af590cb160ff175fd055fbbc982569e86add -
Trigger Event:
release
-
Statement type: