From b7b15349ab7b7f3b30c7c1a8b998f178d7e060a9 Mon Sep 17 00:00:00 2001 From: Elmehdi Aitbrahim Date: Tue, 1 Sep 2026 08:18:26 -0400 Subject: [PATCH] chore(release): 0.13.2 -- the venue boundary, closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0.13.1 shipped the desktop legs. This one ships what #669-#672 built on top of it: the long-only ruling is now enforced at the venue boundary and not only at the decision layer. WHAT REACHES THE DEPLOYMENT. Until now a SELL was sized from keel's own ledger, and the ledger runs high -- a venue that takes its taker fee out of the received base leaves less than the order said, a partial fill leaves less still, and an out-of-band transfer tells keel nothing. Ask a venue for base that is not there and a cash account rejects it; a margin-enabled one fills the difference by opening a short. Three mechanisms now stand in the way: * `_clamp_to_held` reduces a SELL to what the venue reports holding -- down only, never up, unchanged when the balance is unreadable (#667); * rail 21 refuses an order against a holding the venue affirmatively reports as empty, which is the one case the clamp deliberately will not touch (#667); * `sweep_orphan_brackets` cancels a resting SELL whose position has left the account, which no position-driven sweep could reach (#668). All three read `Balance.total`, never `Balance.available`: a resting bracket holds the base it commits, so `available` reads ~0 for exactly the products keel is protecting, and any of the three built on it would have refused every exit and cancelled every bracket on its first cycle. `keel doctor` gains `balance.drift` and `bracket.orphan`, both WARN -- every cause is legitimate and every one leaves the books and the account disagreeing until a human decides which it was. The live deployment has neither finding today; they exist so the next divergence is not found by asking an unrelated question. `docs/fiqh-basis.md` records rail 21 as the SECOND fiqh rail, anchored in *bay' ma la yamlik* (§65.4/§65.11) rather than in riba -- the oversell is impermissible before any interest is charged, so a riba-framed defence never reached it. The rail count moves from nineteen to twenty across guards.py and five documents. What stays open is #666: all three mechanisms fail OPEN on an unreadable balance, deliberately, which is survivable only while the account cannot go short -- and `verify_cash_account` exists on the Alpaca adapter alone. No migration: schema stays at v16. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NzuKAe2RVrPt9acVAWjRyL --- packages/keel-broker-alpaca/pyproject.toml | 4 ++-- packages/keel-broker-api/pyproject.toml | 4 ++-- packages/keel-broker-coinbase/pyproject.toml | 4 ++-- packages/keel-broker-fake/pyproject.toml | 4 ++-- packages/keel-broker-kraken/pyproject.toml | 4 ++-- packages/keel-broker-robinhood/pyproject.toml | 4 ++-- packages/keel-core/pyproject.toml | 2 +- pyproject.toml | 8 ++++---- uv.lock | 16 ++++++++-------- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/keel-broker-alpaca/pyproject.toml b/packages/keel-broker-alpaca/pyproject.toml index 6a2cb8e..1206b4a 100644 --- a/packages/keel-broker-alpaca/pyproject.toml +++ b/packages/keel-broker-alpaca/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "keel-broker-alpaca" -version = "0.13.1" +version = "0.13.2" description = "Alpaca Trading API adapter for keel (US equities, cash account)" license = "Apache-2.0" requires-python = ">=3.14" @@ -9,7 +9,7 @@ requires-python = ">=3.14" # deliberately NO `alpaca-py` SDK: Alpaca's Trading + Market Data APIs are plain # JSON-over-HTTPS with two header credentials, so the SDK would add a version-churning # dependency for nothing the port needs. -dependencies = ["keel-core==0.13.1", "keel-broker-api==0.13.1", "requests>=2.32.0"] +dependencies = ["keel-core==0.13.2", "keel-broker-api==0.13.2", "requests>=2.32.0"] [project.entry-points."keel.brokers"] alpaca = "keel_broker_alpaca:AlpacaAdapter" diff --git a/packages/keel-broker-api/pyproject.toml b/packages/keel-broker-api/pyproject.toml index fccae69..6bf71b4 100644 --- a/packages/keel-broker-api/pyproject.toml +++ b/packages/keel-broker-api/pyproject.toml @@ -1,12 +1,12 @@ [project] name = "keel-broker-api" -version = "0.13.1" +version = "0.13.2" description = "Broker port, domain types, capability model, and conformance suite for keel" license = "Apache-2.0" requires-python = ">=3.14" # Pinned `==`: see the note in the root `pyproject.toml`. An unpinned sibling is satisfied by # whatever is already installed, which is how a deployment ends up running mixed versions. -dependencies = ["keel-core==0.13.1"] +dependencies = ["keel-core==0.13.2"] [project.optional-dependencies] conformance = ["pytest>=9.1.1"] diff --git a/packages/keel-broker-coinbase/pyproject.toml b/packages/keel-broker-coinbase/pyproject.toml index d288694..5845ac7 100644 --- a/packages/keel-broker-coinbase/pyproject.toml +++ b/packages/keel-broker-coinbase/pyproject.toml @@ -1,12 +1,12 @@ [project] name = "keel-broker-coinbase" -version = "0.13.1" +version = "0.13.2" description = "Coinbase Advanced Trade adapter for keel" license = "Apache-2.0" requires-python = ">=3.14" # Siblings pinned `==` (see the root `pyproject.toml`); the third-party SDK is not, because it # has its own release cycle and is not cut from this repo. -dependencies = ["keel-core==0.13.1", "keel-broker-api==0.13.1", "coinbase-advanced-py>=1.8.4"] +dependencies = ["keel-core==0.13.2", "keel-broker-api==0.13.2", "coinbase-advanced-py>=1.8.4"] [project.entry-points."keel.brokers"] coinbase = "keel_broker_coinbase:CoinbaseAdapter" diff --git a/packages/keel-broker-fake/pyproject.toml b/packages/keel-broker-fake/pyproject.toml index 63a5617..5416e9b 100644 --- a/packages/keel-broker-fake/pyproject.toml +++ b/packages/keel-broker-fake/pyproject.toml @@ -1,11 +1,11 @@ [project] name = "keel-broker-fake" -version = "0.13.1" +version = "0.13.2" description = "A deliberately divergent second broker adapter, to keep the port honest" license = "Apache-2.0" requires-python = ">=3.14" # Pinned `==`: see the note in the root `pyproject.toml`. -dependencies = ["keel-core==0.13.1", "keel-broker-api==0.13.1"] +dependencies = ["keel-core==0.13.2", "keel-broker-api==0.13.2"] [project.entry-points."keel.brokers"] fake = "keel_broker_fake:FakeAdapter" diff --git a/packages/keel-broker-kraken/pyproject.toml b/packages/keel-broker-kraken/pyproject.toml index e78ebe2..b0d4b64 100644 --- a/packages/keel-broker-kraken/pyproject.toml +++ b/packages/keel-broker-kraken/pyproject.toml @@ -1,13 +1,13 @@ [project] name = "keel-broker-kraken" -version = "0.13.1" +version = "0.13.2" description = "Kraken adapter for keel (port-complete stub; every data/market method raises)" license = "Apache-2.0" requires-python = ">=3.14" # Siblings pinned `==` (see the root `pyproject.toml`). There is deliberately NO third-party # dependency: this package is a stub (#313) that handles no keys and makes no network calls, # so a Kraken SDK (and its credentials) arrive with the real implementation, not before it. -dependencies = ["keel-core==0.13.1", "keel-broker-api==0.13.1"] +dependencies = ["keel-core==0.13.2", "keel-broker-api==0.13.2"] [project.entry-points."keel.brokers"] kraken = "keel_broker_kraken:KrakenAdapter" diff --git a/packages/keel-broker-robinhood/pyproject.toml b/packages/keel-broker-robinhood/pyproject.toml index 273c653..8d72da0 100644 --- a/packages/keel-broker-robinhood/pyproject.toml +++ b/packages/keel-broker-robinhood/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "keel-broker-robinhood" -version = "0.13.1" +version = "0.13.2" description = "Robinhood Crypto Trading API v2 adapter for keel" license = "Apache-2.0" requires-python = ">=3.14" @@ -8,7 +8,7 @@ requires-python = ">=3.14" # Ed25519 key, which no other venue keel talks to requires. Keeping it a dependency of this # package alone means an engine that never installs this adapter never installs the crypto stack # either -- the whole point of adapters being separate distributions. -dependencies = ["keel-core==0.13.1", "keel-broker-api==0.13.1", "pynacl>=1.5.0", "requests>=2.32.0"] +dependencies = ["keel-core==0.13.2", "keel-broker-api==0.13.2", "pynacl>=1.5.0", "requests>=2.32.0"] [project.entry-points."keel.brokers"] robinhood = "keel_broker_robinhood:RobinhoodAdapter" diff --git a/packages/keel-core/pyproject.toml b/packages/keel-core/pyproject.toml index bb42e93..64cb467 100644 --- a/packages/keel-core/pyproject.toml +++ b/packages/keel-core/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "keel-core" -version = "0.13.1" +version = "0.13.2" description = "Shared domain types, configuration, and logging for keel" license = "Apache-2.0" requires-python = ">=3.14" diff --git a/pyproject.toml b/pyproject.toml index 6003636..9733357 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "keel-trader" -version = "0.13.1" +version = "0.13.2" description = "Offline-first, broker-agnostic, rule-based spot-trading agent (halal policy by default)" license = "Apache-2.0" readme = "README.md" @@ -23,15 +23,15 @@ dependencies = [ # in one build, so `==` states a fact rather than guessing at compatibility. The cost is that # a version bump must move these numbers too -- the bump already edits every package's # `version`, and `tests/test_packaging.py` fails the build if a pin is left behind. - "keel-core==0.13.1", - "keel-broker-api==0.13.1", + "keel-core==0.13.2", + "keel-broker-api==0.13.2", # The default venue resolves through the keel.brokers entry points (#524), so the adapter # is a hard runtime dependency, not a convenience: without it installed, every config -- # including one with no `broker:` section -- fails at broker construction. The CLI also # imports the SDK directly to build the adapter's RESTClient transport # (`keel/commands/_common.py`); moving that construction into the adapter package is # Phase B's, with cb_client.py's deletion. - "keel-broker-coinbase==0.13.1", + "keel-broker-coinbase==0.13.2", ] [project.scripts] diff --git a/uv.lock b/uv.lock index 49b197f..d6b5173 100644 --- a/uv.lock +++ b/uv.lock @@ -454,7 +454,7 @@ wheels = [ [[package]] name = "keel-broker-alpaca" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-alpaca" } dependencies = [ { name = "keel-broker-api" }, @@ -471,7 +471,7 @@ requires-dist = [ [[package]] name = "keel-broker-api" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-api" } dependencies = [ { name = "keel-core" }, @@ -491,7 +491,7 @@ provides-extras = ["conformance"] [[package]] name = "keel-broker-coinbase" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-coinbase" } dependencies = [ { name = "coinbase-advanced-py" }, @@ -508,7 +508,7 @@ requires-dist = [ [[package]] name = "keel-broker-fake" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-fake" } dependencies = [ { name = "keel-broker-api" }, @@ -523,7 +523,7 @@ requires-dist = [ [[package]] name = "keel-broker-kraken" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-kraken" } dependencies = [ { name = "keel-broker-api" }, @@ -538,7 +538,7 @@ requires-dist = [ [[package]] name = "keel-broker-robinhood" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-broker-robinhood" } dependencies = [ { name = "keel-broker-api" }, @@ -557,7 +557,7 @@ requires-dist = [ [[package]] name = "keel-core" -version = "0.13.1" +version = "0.13.2" source = { editable = "packages/keel-core" } dependencies = [ { name = "keyring" }, @@ -574,7 +574,7 @@ requires-dist = [ [[package]] name = "keel-trader" -version = "0.13.1" +version = "0.13.2" source = { editable = "." } dependencies = [ { name = "click" },