Skip to content

feat(forex): add ForexContext for the currency-exchange channel (all layers) - #602

Open
hogan-yuan wants to merge 10 commits into
mainfrom
feat/forex-openapi
Open

hogan-yuan wants to merge 10 commits into
mainfrom
feat/forex-openapi

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Summary

New ForexContext for the currency-exchange (forex) channel — 3 endpoints
(quote / submit / query) — across all six SDK layers: Rust core (async +
blocking), C, C++, Java, Node.js, Python. Mirrors RFC-2026-0012 Appendix A.

Flow is three-step and asynchronous:

  1. quote (POST /v1/forex/quote) → rate + quote_id
  2. submit_order (POST /v1/forex/order) → accepted only (returns nothing)
  3. order (GET /v1/forex/order) → poll by client_order_id to a terminal state

Design notes

  • ForexOrderStatus is an integer-coded enum (Processing=0 / Success=1 /
    Failed=2), following the repo's existing num_enum + manual Serialize/Deserialize
    pattern; unknown values default to Processing.
  • Money fields use Decimal (matching the trade channel). The query response's
    rate / from_amount / to_amount are nullable — they arrive as empty
    strings until the order is filled, decoded via the existing
    serde_utils::decimal_opt_empty_is_none helper.
  • rate convention: standard currency pair (1 BASE = rate QUOTE), independent
    of the request's from/to direction; ccy_pair names the pair, expire_at is Unix ms.
  • submit_order returns () — acceptance ≠ settlement; the idempotency contract
    (reuse same client_order_id on retry; each quote_id usable once → 603006) is
    documented on the method.
  • No dedicated error-code enum (603001–603010 surface as the standard OpenApiError),
    consistent with the rest of the repo.
  • C++ uses the real cbindgen header types directly (trade-style), no ffi mirror.
  • Node.js/Python accept the quote amounts as decimal strings (fund-style), since
    async napi/PyO3 can't take a Decimal input directly; Python's from arg is from_.

Related (follow-ups, separate repos)

CLI / MCP / Docs are tracked separately, as with FundContext (#598).

This branch has not been deployed

No deployments
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.

1 participant