/algo-trading-skills:broker-api-versioning-migration-playbookfrom algo-trading-skills
Guides migration between broker API versions with shadow reads, deterministic canary routing that survives retries, latched rollback, and a schema translator that refuses to silently alter time-in-force.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integrationInvoke this skill when a live trading system must move from one broker API version to another — a REST v1→v2 cutover, a new FIX session profile, an SDK major bump that changes payload shapes, or a forced migration off an endpoint with a published sunset date. It covers the migration mechanism: which version each request goes to, how read equivalence is proved before writes move, and how the cutover is aborted.
The migration window is the dangerous part, not the destination. During it, two API versions are simultaneously live against the same account, and every ordinary failure — a timeout, a retry, a redeployed replica — can now resolve onto a different version than the one that saw the original request. The three rules below exist because each has a specific way of putting two orders in the market where the strategy intended one:
A retry must reach the same version as the original attempt. A cancel must reach the version that holds the order. A target-version field you have not read in the spec does not exist.
That last one is not hypothetical. A translator emitting a Coinbase order_configuration
key called stop_stop_gtc is inventing one: no such key exists. The published CreateOrder
schema has stop_limit_stop_limit_gtc, and it requires limit_price, stop_price and
stop_direction together. Every stop order translated by such code is rejected by the
venue — or worse, silently reshaped by a permissive gateway.
broker-api-changelog-diffing-tool on the published specs and read the release notes.sec-rule-15c3-5-risk-controls-us and kill-switch-and-drawdown-circuit-breakers.None, meaning
"reconcile", not "route to V1".canary-releases-for-strategy-code-changes or
blue-green-deployment-for-live-strategy-updates.instrument_id → product_id), relocations (top-level size →
order_configuration.base_size) and type changes (numeric price → string price)
are the common shape of a v1→v2 break.V1_ONLY. Without it, "V2 is 5%
slower" has no referent. Percentile gates need volume: a p99 estimated from 200
samples rests on two observations.order-placement-idempotency.webhook-based-order-fill-notifications.Baseline in V1_ONLY. Route everything to V1 and record read latency and order
outcomes. execute_read_shadowing times the V1 call in every phase precisely so this
baseline exists before any comparison is made.
Translate — and fail loudly on anything you cannot express. Build the V2 payload from the version-neutral order, and raise rather than substitute when the target version has no equivalent. The two substitutions that look harmless and are not:
limit_limit_gtc converts an
immediate-or-cancel instruction into a resting order. The strategy believes the
unfilled remainder is gone; it is sitting in the book.str(price) if price else "0" sends a limit price of zero.
Note it also fires when the price is legitimately 0.0 — a falsiness check is not
a null check.SHADOW_MODE: prove read equivalence. Writes stay on V1 by definition. Reads run
on V1 and are replicated to V2 in the background. Three properties are load-bearing:
Treat is_equivalent == True with a non-empty unverified_paths as unproven, not
passed: a null field or an empty list carries no type information, and a shadow
phase that passed because half the payload was null has proved nothing.
CANARY_CUTOVER: move writes by order, not by call. Derive the routing decision
from a stable hash of the client order id, so a retry of a timed-out order returns to
the same version and every replica agrees. A fresh random draw per call gives one
order a new coin flip on every attempt — and the broker's de-duplication namespace on
the other version has never seen the first attempt.
Ramp percentages are fractions in [0, 1]. Reject out-of-range values; never clamp
them. Clamping turns an operator typing 50 for "50%" into an instant 100% cutover
onto the untested version.
Route follow-ups by affinity, not by hash. Determinism alone is not enough:
ramping 5% → 25% re-buckets orders, so a cancel computed from the new percentage can
be aimed at a version that never saw the order. Look the order up in the affinity map
and, when it returns None, query both versions rather than guessing — "unknown
order" from the wrong version is not proof the order is gone
(broker-api-idempotent-cancel-requests).
Gate the ramp on evidence, and abstain when there is none. Compare V2 error rate, schema-drift rate, and latency against thresholds calibrated from your V1 baseline. When there are too few samples to decide, the verdict is "undecided", not "pass" — a gate that returns green on three observations promotes on silence.
Roll back to a latch. ROLLBACK_V1 must not be an ordinary phase that the next
scheduled ramp step can overwrite. Leaving it requires an explicit, logged operator
action, and the migration restarts from the gate sequence rather than resuming at the
percentage that just failed.
V2_ONLY, then decommission. Only after V2 has carried full flow across several
sessions. Keep the V1 code path deployed until then — a rollback you have deleted is
not a rollback.
Full phase procedure and exit criteria: see
references/workflows.md. Schema citations, thresholds, and the statistics behind the latency gate: seereferences/standards.md. Printable sign-off sheet: seeassets/checklist.md.
stop_stop_gtc is not a Coinbase
order_configuration key; stops are stop-limit orders requiring limit_price,
stop_price and stop_direction together. If you have not read the field in the
spec, it does not exist.time_in_force during translation. An IOC or FOK order that arrives as
GTC rests in the book, and the strategy has no idea it holds exposure.str(price) if price else "0". Two bugs in one expression: it defaults a missing
price to zero, and it treats a legitimate 0.0 as missing.str(float). str(1e-05) is '1e-05' and
str(0.1 + 0.2) is '0.30000000000000004'. Format through Decimal with fixed-point
notation.hash() for the routing bucket. String hashing is salted
per process, so replicas and restarts disagree about which orders are in the canary.min(1.0, 50) is 1.0: the operator
asked for half the flow and got all of it, instantly, on the untested version.with ThreadPoolExecutor(...)
block joins its workers on exit; a hung V2 endpoint then stalls live reads for as long
as it hangs.python -m unittest discover -s skills/broker-api-versioning-migration-playbook/scripts
and confirm all tests pass.stop_limit_stop_limit_gtc
with base_size, limit_price, stop_price and stop_direction — and no
stop_stop_gtc. Confirm a stop missing any of those raises instead of translating.limit_price and confirm it raises rather than
emitting "0"; construct one with limit_price=0 and confirm the payload itself is
rejected.limit_limit_fok, not limit_limit_gtc.0.00001 and confirm the payload carries "0.00001", not
"1e-05".set_phase(CANARY_CUTOVER, 50) and confirm it raises; confirm the phase is
unchanged afterwards.V1_ONLY → V2_ONLY and confirm it raises.clear_rollback(operator, reason) is called with both arguments non-empty.route_followup_version still
reports V1.shadow_errors and never reaches
the caller.{"order": {"fills": [{"price": 1.0}]}} against the same structure with
"price": "1.0" and confirm order.fills.[].price appears in type_mismatches.within_tolerance is False; repeat with 3 samples and confirm it
reports None, not True.broker-api-changelog-diffing-toolbroker-api-deprecation-notice-monitoringbroker-api-idempotent-cancel-requestsbroker-agnostic-adapter-interfaceorder-placement-idempotencycanary-releases-for-strategy-code-changesblue-green-deployment-for-live-strategy-updatessandbox-vs-production-endpoint-driftkill-switch-and-drawdown-circuit-breakerssec-rule-15c3-5-risk-controls-usmifid-ii-algo-trading-compliance-euwebhook-based-order-fill-notifications36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging./broker-agnostic-adapter-interfaceUse when strategy code must run across several brokers and should not import kiteconnect, alpaca-py or ibapi directly; defines an adapter contract with Decimal prices, typed exceptions and normalised order status across venues./broker-api-changelog-diffing-toolUse before upgrading a broker SDK or OpenAPI spec, to diff two schema snapshots for removed endpoints, newly required parameters, enum mutations and type changes so CI fails before the change reaches an order path./broker-api-deprecation-notice-monitoringUse when a long-running bot calls REST endpoints a broker may retire; parses RFC 8594 Sunset and RFC 9745 Deprecation headers plus changelog feeds into one dated migration deadline with an escalation tier.Other plugins' skills for the same job