Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- 'bt_api_py/**'
- 'scripts/generate_exchange_support_docs.py'
- 'scripts/ci/check_docs_contract.py'
- 'scripts/ci/base_source_pin.py'
pull_request:
paths:
- 'docs/**'
Expand All @@ -30,6 +31,7 @@ on:
- 'bt_api_py/**'
- 'scripts/generate_exchange_support_docs.py'
- 'scripts/ci/check_docs_contract.py'
- 'scripts/ci/base_source_pin.py'
workflow_dispatch:

permissions:
Expand All @@ -47,6 +49,9 @@ jobs:
with:
fetch-depth: 0

- name: Checkout pinned base source
run: git submodule update --init --depth 1 -- bt_api/bt_api_base

- uses: actions/setup-python@v6
with:
python-version: '3.11'
Expand All @@ -58,9 +63,17 @@ jobs:
- name: Install doc dependencies
run: python -m pip install --upgrade pip -r docs/requirements.txt

- name: Build and install parent-pinned base wheel
run: >-
python scripts/ci/base_source_pin.py
--wheel-dir "${{ runner.temp }}/bt_api_base_wheelhouse"

- name: Install package (needed by mkdocstrings)
run: python -m pip install -e .

- name: Check installed dependencies
run: python -m pip check

- name: Check generated docs are current
run: python scripts/generate_exchange_support_docs.py --check

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/reusable-compat-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Checkout pinned base source
run: git submodule update --init --depth 1 -- bt_api/bt_api_base

- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Build and install parent-pinned base wheel
run: >-
python scripts/ci/base_source_pin.py
--wheel-dir "${{ runner.temp }}/bt_api_base_wheelhouse"

- name: Install build tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential
Expand All @@ -50,6 +58,9 @@ jobs:
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Check installed dependencies
run: python -m pip check

- name: Run cross-platform compatibility smoke suite
env:
SKIP_LIVE_TESTS: "true"
Expand Down
43 changes: 40 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ jobs:
cache: pip
cache-dependency-path: pyproject.toml

- name: Build and install parent-pinned base wheel
run: >-
python scripts/ci/base_source_pin.py
--wheel-dir "${{ runner.temp }}/bt_api_base_wheelhouse"

- name: Install package + quality tools
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install bandit pip-audit

- name: Check installed dependencies
run: python -m pip check

- name: Ruff lint check
run: ruff check bt_api_py tests --output-format=github

Expand Down Expand Up @@ -159,8 +167,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
needs: quality
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

defaults:
run:
Expand All @@ -177,15 +183,38 @@ jobs:
cache: pip
cache-dependency-path: pyproject.toml

- name: Build and install parent-pinned base wheel
run: >-
python scripts/ci/base_source_pin.py
--wheel-dir "${{ runner.temp }}/bt_api_base_wheelhouse"
--github-env "$GITHUB_ENV"

- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Build and install parent-pinned CTP source wheel
run: >-
python scripts/ci/ctp_source_pin.py
--wheel-dir "${{ runner.temp }}/bt_api_ctp_wheelhouse"
--github-env "$GITHUB_ENV"

- name: Install package + dev deps
run: |
python -m pip install --upgrade pip
# Unmarked contract cases exercise the declared reference adapters.
pip install -e ".[dev,security,core-reference]" -r requirements-ci-core-reference.txt

- name: Verify parent-pinned CTP wheel receipt
run: python scripts/ci/ctp_source_pin.py --verify-installed

- name: Check installed dependencies
run: python -m pip check

- name: Check CTP native extension load
run: >-
python -c "from bt_api_ctp.ctp._ctp_base import get_ctp_import_error,
is_ctp_native_loaded; assert is_ctp_native_loaded(), get_ctp_import_error()"

- name: Run baseline suite with coverage gate
env:
SKIP_LIVE_TESTS: "true"
Expand Down Expand Up @@ -229,8 +258,13 @@ jobs:
test -s htmlcov/index.html

- name: Upload coverage to Codecov
if: always() && env.CODECOV_TOKEN != ''
if: >-
always() &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
uses: codecov/codecov-action@v6
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-full.xml
Expand Down Expand Up @@ -258,6 +292,9 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Checkout parent-pinned base source
run: git submodule update --init --depth 1 -- bt_api/bt_api_base

- uses: actions/setup-python@v6
with:
python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion bt_api/bt_api_ctp
Submodule bt_api_ctp updated 37 files
+2 −2 README.md
+2 −2 docs/index.md
+2 −2 pyproject.toml
+11 −1 src/bt_api_ctp/__init__.py
+789 −0 src/bt_api_ctp/containers/ctp/ctp_native_query_certificate.py
+14 −3 src/bt_api_ctp/containers/ctp/ctp_position_evidence.py
+2,686 −168 src/bt_api_ctp/ctp/client.py
+441 −0 src/bt_api_ctp/ctp/managed_dispatch.py
+382 −0 src/bt_api_ctp/ctp/managed_native_dispatch.py
+415 −0 src/bt_api_ctp/ctp/managed_outbox_pre_dispatch.py
+536 −0 src/bt_api_ctp/ctp/managed_outbox_verification.py
+18 −2 src/bt_api_ctp/ctp_env_selector.py
+51 −2 src/bt_api_ctp/feeds/live_ctp_feed.py
+66 −0 src/bt_api_ctp/order_action.py
+15 −4 src/bt_api_ctp/query.py
+19 −2 tests/test_ctp_feed.py
+365 −0 tests/test_ctp_managed_dispatch_contract.py
+475 −0 tests/test_ctp_managed_native_dispatch.py
+308 −0 tests/test_ctp_managed_outbox_pre_dispatch.py
+461 −0 tests/test_ctp_managed_outbox_verification.py
+35 −0 tests/test_ctp_md_callback_request_id_audit.py
+18 −5 tests/test_ctp_md_disconnect_observability.py
+250 −0 tests/test_ctp_md_login_identity.py
+26 −4 tests/test_ctp_md_subscribe_batched.py
+803 −0 tests/test_ctp_native_query_certificate.py
+119 −0 tests/test_ctp_neutral_front_pair_constructor.py
+327 −0 tests/test_ctp_order_action_evidence.py
+360 −0 tests/test_ctp_order_insert_evidence.py
+32 −20 tests/test_ctp_position_evidence.py
+222 −0 tests/test_ctp_shutdown.py
+458 −0 tests/test_ctp_simnow_execution_guard.py
+838 −0 tests/test_ctp_simnow_managed_write.py
+186 −0 tests/test_ctp_trader_login_identity.py
+407 −0 tests/test_ctp_trader_spi_event_fence.py
+16 −1 tests/test_instrument_queries.py
+112 −56 tests/test_iter22_contracts.py
+7 −1 tests/test_unified_position_contract.py
2 changes: 1 addition & 1 deletion bt_api/bt_api_monitor
Submodule bt_api_monitor updated 1 files
+1 −0 README.md
2 changes: 1 addition & 1 deletion bt_api_py/configs/exchange-bundles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ certification = "experimental"
package = "bt_api_ctp"
plugin = "ctp"
exchange = "CTP___FUTURE"
min_version = "2.0.2"
min_version = "2.0.3"
certification = "experimental"
4 changes: 1 addition & 3 deletions bt_api_py/forwarding/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
_VALID_SIDES = frozenset({"buy", "sell"})
_VALID_ORDER_TYPES = frozenset({"limit", "market"})
_MAX_CACHED_ACKS = 10_000
_TRADING_DISABLED_REASON = (
"forwarding trading is disabled; provider write was not attempted"
)
_TRADING_DISABLED_REASON = "forwarding trading is disabled; provider write was not attempted"


@dataclass(frozen=True)
Expand Down
10 changes: 8 additions & 2 deletions docs/acceptance/2026-09-19-quality-ratchet.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schema_version": 1,
"generated_at": "2026-09-19T17:21:53.591707+00:00",
"generated_at": "2026-09-28T14:02:47.687472+00:00",
"ruff_version": "ruff 0.16.2",
"scope": [
"bt_api_py",
Expand All @@ -15,13 +15,16 @@
"bt_api/bt_api_ctp/src",
"bt_api/bt_api_dydx/src",
"bt_api/bt_api_gateio/src",
"bt_api/bt_api_gateway/src",
"bt_api/bt_api_htx/src",
"bt_api/bt_api_hyperliquid/src",
"bt_api/bt_api_ib_web/src",
"bt_api/bt_api_kraken/src",
"bt_api/bt_api_mexc/src",
"bt_api/bt_api_monitor/src",
"bt_api/bt_api_mt5/src",
"bt_api/bt_api_okx/src",
"bt_api/bt_api_risk/src",
"bt_api/bt_api_base/tests",
"bt_api/bt_api_binance/tests",
"bt_api/bt_api_bitget/tests",
Expand All @@ -30,13 +33,16 @@
"bt_api/bt_api_ctp/tests",
"bt_api/bt_api_dydx/tests",
"bt_api/bt_api_gateio/tests",
"bt_api/bt_api_gateway/tests",
"bt_api/bt_api_htx/tests",
"bt_api/bt_api_hyperliquid/tests",
"bt_api/bt_api_ib_web/tests",
"bt_api/bt_api_kraken/tests",
"bt_api/bt_api_mexc/tests",
"bt_api/bt_api_monitor/tests",
"bt_api/bt_api_mt5/tests",
"bt_api/bt_api_okx/tests"
"bt_api/bt_api_okx/tests",
"bt_api/bt_api_risk/tests"
],
"ruff": {
"total": 10,
Expand Down
12 changes: 10 additions & 2 deletions docs/acceptance/2026-09-20-format-ratchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
"bt_api_coinbase",
"bt_api_ctp",
"bt_api_dydx",
"bt_api_execution",
"bt_api_gateio",
"bt_api_gateway",
"bt_api_htx",
"bt_api_hyperliquid",
"bt_api_ib_web",
"bt_api_kraken",
"bt_api_mexc",
"bt_api_monitor",
"bt_api_mt5",
"bt_api_okx"
"bt_api_okx",
"bt_api_risk"
],
"format": {
"total": 451,
Expand All @@ -33,14 +37,18 @@
"bt_api_coinbase": 23,
"bt_api_ctp": 25,
"bt_api_dydx": 20,
"bt_api_execution": 0,
"bt_api_gateio": 25,
"bt_api_gateway": 0,
"bt_api_htx": 23,
"bt_api_hyperliquid": 23,
"bt_api_ib_web": 40,
"bt_api_kraken": 7,
"bt_api_mexc": 12,
"bt_api_monitor": 0,
"bt_api_mt5": 7,
"bt_api_okx": 85
"bt_api_okx": 85,
"bt_api_risk": 0
}
},
"notes": "Submodule format ratchet baseline. Per-module counts may only decrease; use --update after improvements or --force-update for an intentional rebaseline."
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ authors = [
{name = "cloudQuant", email = "yunjinqi@gmail.com"},
]
dependencies = [
"bt_api_base>=0.15.4",
"bt_api_base>=0.15.5",
"numpy>=1.26.0",
"python-dotenv>=1.0.0",
"requests>=2.31.0",
Expand Down Expand Up @@ -303,5 +303,5 @@ all = [
]
core-reference = [
"bt_api_binance>=2.0.0",
"bt_api_ctp>=2.0.2,<3.0",
"bt_api_ctp>=2.0.3,<3.0",
]
Loading
Loading