Repository navigation
Limit orders, activity rules, and full-portfolio NAV - #3
Merged
Merged
Conversation
Rules - perSymbolDailyCapUsd, maxTradesPerHour, cooldownSeconds: read from the audit log, so they cannot drift from the record. - maxLimitDeviationPct (default 5) refuses a limit price far from the market as a likely typo. maxOpenOrders caps resting orders. - sellWithinHoldings: a SELL must be covered by what the account holds. Rules that need information they could not get refuse the trade instead of assuming it is fine. - Removed maxOpenPositions from the mandate schema. It was accepted but never enforced anywhere, which is worse than not offering it. Order types - LIMIT orders end to end: CLI (--type LIMIT --qty --limit-price), API, simulator, and execution. A resting order is logged as placed, not filled, and counts toward the spend caps because it can still fill. - Quantity and price are rounded down to the exchange's step and tick sizes, and an order below the minimum is refused before it is sent. - charter orders / cancel, and halt --cancel-open. CHARTER only lists or cancels orders it placed itself. NAV - Values the whole account instead of a hand-picked list of eight assets: USDT pair, then BTC/ETH/BNB bridges, then inverse pairs for fiat. Unpriceable holdings are reported, not guessed. On the testnet account the old method counted $138K of $437K. A baseline recorded under an older method is ignored, so two methods are never compared. Found and fixed while testing - The simulator walked a LIMIT order with a dollar budget, so a limit BUY in a book cheaper than its limit could buy more units than requested. Limit orders are now walked in units. - Signed requests failed intermittently with -1021 (timestamp outside recvWindow). The client now syncs to the exchange clock and retries once. - A libuv assertion on Windows when the CLI exited with an error, from calling process.exit while handles were closing. The mandate compiler and the Skill Hub skill know the new limits and order types. The skill still described the old ESCALATE confirmation in one place; corrected. 109 new tests (237 total). Verified live on Binance Spot Testnet: cooldown, trade rate, per-symbol cap, covered and uncovered sells, a real resting limit order, the open-order cap, the fat-finger guard, cancel, and halt --cancel-open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
More rules, LIMIT orders, and a NAV that values the whole account.
Rules: per-symbol daily cap, per-agent trade rate, per-symbol cooldown, limit-price sanity, open-order cap, and a check that a SELL is covered by holdings. A rule that lacks information it needs refuses the trade rather than assuming it is fine. Removed maxOpenPositions from the schema: it was accepted and never enforced.
Orders: LIMIT end to end (CLI, API, simulator, execution). A resting order is logged as placed and counts toward the caps. Quantity and price are rounded down to the exchange's step and tick sizes. Adds orders, cancel, and halt --cancel-open, touching only orders CHARTER placed.
NAV: values the whole account. On the testnet account the old hand-picked list counted 138K of 437K.
Found and fixed while testing: the simulator let a limit BUY buy more units than requested in a cheap book, signed requests failed intermittently on clock drift (-1021), and the CLI could trip a libuv assertion on Windows on exit.
109 new tests (237 total). Verified live on Binance Spot Testnet, including a real resting limit order, cancel, and halt --cancel-open.