Skip to content

Limit orders, activity rules, and full-portfolio NAV - #3

Merged
angelraph merged 1 commit into
masterfrom
feature/rules-orders-nav
Sep 21, 2026
Merged

angelraph merged 1 commit into
masterfrom
feature/rules-orders-nav

Conversation

@angelraph

Copy link
Copy Markdown
Owner

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.

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.
@angelraph
angelraph merged commit 47d56e0 into master Sep 21, 2026
1 check passed
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