Skip to content

feat(ibkr): CP API v1 order write-path wire layer#136

Merged
NotAProfDev merged 14 commits into
mainfrom
feat/ibkr-cpapi-writepath
Jul 11, 2026
Merged

feat(ibkr): CP API v1 order write-path wire layer#136
NotAProfDev merged 14 commits into
mainfrom
feat/ibkr-cpapi-writepath

Conversation

@NotAProfDev

@NotAProfDev NotAProfDev commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Closes #135.

The second oath-adapter-ibkr slice: the Client Portal API v1 (cpapi) order write path as a pure, transport-agnostic wire layer — following the read path (#127/#129/#131).

What's in it

  • Request DTOs (the crate's first Serialize direction): OrderRequest, PlaceOrderRequest, ReplyConfirm.
  • Response DTOs: OrderPlaceReply (the place/reply union — one all-optional struct, not a serde untagged enum), CancelResponse, OrderStatus, LiveOrders/LiveOrder.
  • Endpoint descriptors: place / reply-confirm / cancel / order-status / live-orders (adds Method::Delete).
  • Harness: just ibkr-capture extended to drive the real place → confirm → cancel dance and capture sanitized fixtures.
  • Gated #[ignore] live round-trip test (place → confirm → cancel), built via the request DTOs + Endpoint constructors, with a Drop-guard best-effort cancel.

Boundary (unchanged from the read path)

No transport, no auth, no OATH-domain translation, no order-safety semantics — ADR-0022 / ADR-0026 stay untouched. Order modify deferred (YAGNI).

Faithful-mirror splits (reconciled against a real paper gateway)

  • place/reply confirmation order_id is a string; status/live/cancel order_id is an integer.
  • order/status is snake_case-native (limit_price/sizes are strings); account/orders is camelCase-native (orderId/orderType/totalSize renamed, price a string).
  • /iserver/account/orders returns an empty snapshot on the first call (snapshot warming) → the capture polls until populated.
  • a plain far-below-market LIMIT raises no reply warning (place → confirmation directly).

Fixtures are real, sanitized paper captures (account DU0000000, ids placeholdered). just ci green; the gated live round-trip was verified against the real gateway (no resting order).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for IBKR order placement, reply confirmation, cancellation, status checks, and live-order retrieval.
    • Added serialization and decoding for order requests and responses, including confirmation prompts and acknowledgements.
    • Expanded documentation to cover order write operations.
  • Tests

    • Added fixture-based coverage and a gated end-to-end paper-order workflow that places, confirms, and cancels an order.
  • Documentation

    • Updated capture instructions, including required sanitization of order identifiers.

NotAProfDev and others added 13 commits July 11, 2026 08:07
Design for the second oath-adapter-ibkr slice: the CP API v1 order
write path (place / reply-confirm / cancel / status / live-orders) as a
pure wire layer — request-body serde DTOs, the order/reply union response,
and Endpoint descriptors mirroring IBKR JSON. No transport/auth/domain
translation; ADR-0022/0026 untouched. Fixtures live-captured in-slice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Task-by-task TDD plan for the CP API v1 order write path: Endpoint
constructors + Method::Delete, request DTOs (first serialize direction),
the OrderPlaceReply union, cancel/status/live-orders response DTOs,
capture.sh order-dance extension, live-capture reconcile, gated live
round-trip test, and README/CHANGELOG. Derived from the approved spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reviewer-approved polish across the cpapi write-path branch:
- order.rs: drop stale "(added in later tasks)" from the module doc,
  since the response DTOs are now all present.
- tests/order.rs: extend the two OrderPlaceReply union decode tests
  to assert the full opposite shape is absent, not just 4 of 6 fields.
- spec §3.1: sync the OrderPlaceReply/CancelResponse snippet to the
  implementation's (correct) field spellings so Task 6 reconciliation
  starts from the right shape.
Live-captured (paper DUP…, sanitized) fixtures + DTO/capture.sh fixes from a
real place→confirm→cancel dance. Live-wire truths:

- place/reply confirmation `order_id` is a STRING; status/live/cancel `order_id`
  is an INTEGER (confirms the faithful-mirror split).
- `order/status` limit price is `limit_price` (string), not `price`; sizes are
  strings ("1.0"); adds `account`.
- `account/orders` price is a STRING ("1.00") not a number; `orderType` value is
  "Limit"; first call returns an EMPTY snapshot (warming) → capture.sh now polls.
- a plain far-below-market LIMIT raises no reply warning (place → confirmation
  directly) → capture.sh saves that confirmation; questions fixture stays a
  documented representative.
- cancel returns conid:-1, account:null.

Gated live round-trip test passes against the real gateway.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- arm the live-test CancelGuard as soon as an order id is known (initial
  confirmation or each confirmed reply), closing the question-flow window
  where a mid-round-trip panic could strand a resting order;
- scrub ephemeral gateway ids/timestamps (request_id/server_id/order_time/
  lastExecutionTime) from the order_status/live_orders fixtures for consistency
  with the account/order-id sanitization;
- clarify the capture.sh no-question log line.

Live round-trip re-verified against the paper gateway; no resting order.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b16789b-c12d-4d43-9af9-9814d917a9ba

📥 Commits

Reviewing files that changed from the base of the PR and between 71265c7 and 384e090.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • README.md
  • crates/adapter/ibkr/src/cpapi/endpoint.rs
  • crates/adapter/ibkr/src/cpapi/mod.rs
  • crates/adapter/ibkr/src/cpapi/order.rs
  • crates/adapter/ibkr/tests/endpoint.rs
  • crates/adapter/ibkr/tests/fixtures/cpapi/live_orders.json
  • crates/adapter/ibkr/tests/fixtures/cpapi/order_cancel.json
  • crates/adapter/ibkr/tests/fixtures/cpapi/order_place_questions.json
  • crates/adapter/ibkr/tests/fixtures/cpapi/order_reply_confirmed.json
  • crates/adapter/ibkr/tests/fixtures/cpapi/order_status.json
  • crates/adapter/ibkr/tests/live.rs
  • crates/adapter/ibkr/tests/order.rs
  • docker/cpapi/README.md
  • docker/cpapi/capture.sh
  • docs/superpowers/plans/2026-07-11-ibkr-cpapi-writepath-wire.md
  • docs/superpowers/specs/2026-07-11-ibkr-cpapi-writepath-wire-design.md

📝 Walkthrough

Walkthrough

The IBKR CPAPI adapter now includes order placement, reply confirmation, cancellation, status, and live-order wire DTOs and endpoints. It adds fixture-based serialization/decoding tests, paper capture automation, an ignored live round-trip test, documentation, and changelog entries.

Changes

IBKR CPAPI order write path

Layer / File(s) Summary
Wire-layer design and validation contract
docs/superpowers/specs/..., docs/superpowers/plans/...
Documents define DTO shapes, endpoint paths, capture behavior, fixture rules, and test coverage for the pure wire layer.
Endpoint descriptors and module exports
crates/adapter/ibkr/src/cpapi/..., crates/adapter/ibkr/tests/endpoint.rs
Adds order-related HTTP methods and paths, exports the new DTOs, and tests endpoint construction.
Order wire DTOs and fixture decoding
crates/adapter/ibkr/src/cpapi/order.rs, crates/adapter/ibkr/tests/order.rs, crates/adapter/ibkr/tests/fixtures/cpapi/*
Adds request and response serde types and validates field renames, optional omission, union shapes, and captured payload decoding.
Paper capture and live round trip
docker/cpapi/*, crates/adapter/ibkr/tests/live.rs
Extends capture through placement, confirmation, status, live-orders polling, and cancellation, with cleanup in the ignored live test.
Repository scope and release notes
README.md, CHANGELOG.md
Updates project documentation and the unreleased changelog for the read and order-write wire layers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • NotAProfDev/oath#127: Earlier CPAPI endpoint-layer work extended by these order write-path descriptors.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses Conventional Commits and accurately summarizes the IBKR order write-path wire layer change.
Linked Issues check ✅ Passed The changes match issue #135: request/response DTOs, endpoint descriptors, capture harness, and gated live test are all present.
Out of Scope Changes check ✅ Passed The visible changes stay within the pure-wire IBKR order write-path scope and do not add transport, auth, or order-safety logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ibkr-cpapi-writepath

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NotAProfDev NotAProfDev merged commit a4ccee2 into main Jul 11, 2026
5 checks passed
@NotAProfDev NotAProfDev deleted the feat/ibkr-cpapi-writepath branch July 11, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IBKR cpapi order write-path wire layer (place / reply-confirm / cancel / status / live-orders)

1 participant