Skip to content

fix(backtests): size a pipeline risk action as asked and refuse an ambiguous size_pct - #691

Merged
FlyM1ss merged 4 commits into
mainfrom
fix/size-pct-comment
Oct 31, 2026
Merged

FlyM1ss merged 4 commits into
mainfrom
fix/size-pct-comment

Conversation

@FlyM1ss

@FlyM1ss FlyM1ss commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

This PR started as a comment fix. A /code-review of it found five more ways the code under that comment was wrong, and the PR now fixes them all.

What changes (pipeline_output_to_decision, requested_sell_shares, the gate's refusal record)

Versioning

  • TAPE_VERSION goes from 2 to 3. The gate now reads a recorded size_fraction of 25 differently, and the intent records more than before.
  • LLM_SELL_SIZING stays unchanged, on purpose. Only a pipeline's risk branch sends size_fraction, and neither of the marker's readers (leaderboard pools, Live month resume) runs a pipeline. Changing it would make the Live board replay its month (billable) with no change to any of its trades.

Also updated: the Per-order size (SELL) and Action count rows of SECURITY.md, and the tape design spec.

Tests: new cases in test_pipeline_runner.py, test_llm_sell_sizing.py (including gate-level pipeline runs for the double sell and the stop beside a buy) and test_decision_tape.py. Full backend suite: 7583 passed. The 12 failures are local-environment only (no reportlab for test_report_pdf.py, mcp 1.28 vs the 1.30 pin for test_robinhood_mcp_transport.py) and fail on clean main too.

Closes #690. Closes #700. Closes #701. Closes #702. Closes #703.

🤖 Generated with Claude Code

The risk-branch comment in pipeline_output_to_decision said any
positive size_pct sells the whole position because the gate does not
size a sell. That was written against the pre-#667 gate and reached
main through #662's follow-up; since #667 the gate sizes it as a share
of the position (0.25 sells a quarter, 1 or more sells all). Comment
only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentic-trading-lab Ready Ready Preview Oct 31, 2026 3:30am UTC

FlyM1ss and others added 2 commits October 30, 2026 14:24
…biguous size_pct

- Refuse a size_fraction strictly between 1 and 100 (a fraction and a
  percentage disagree there) and state size_pct's unit in the last step's
  execution rules when the step asks for risk_actions (#690).
- Carry a risk action's qty/quantity/position_size to the gate (#700).
- Execute orders and risk_actions together; an actions list still overrides
  both, and the dropped lists are logged and recorded on the tape (#701).
- Let an unreadable size_pct reach the gate's refusal instead of holding (#702).
- Record fraction x held on a refused fraction sell, not 0 (#703).
- TAPE_VERSION 2 -> 3; LLM_SELL_SIZING unchanged (no pipeline feeds its readers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FlyM1ss FlyM1ss changed the title docs(backtests): say what a risk action's size_pct sells now fix(backtests): size a pipeline risk action as asked and refuse an ambiguous size_pct Oct 30, 2026
@FlyM1ss
FlyM1ss marked this pull request as ready for review October 30, 2026 18:36
…isk sells from one rule

Addresses the /code-review of #691:
- An order on a symbol drops every risk action on it (named on the tape as
  ignored_risk_symbols and logged): no double sell of one holding, no stop
  beside a buy market-selling the old position, and a reply naming each
  symbol once stays within the gate's action cap.
- read_pipeline_output reads a reply once and returns the decision with
  what it ignored; the gate, the log line and the tape share it
  (replaces shadowed_envelopes).
- _model_qty takes the first share-count key the model filled in, so
  {"qty": null, "quantity": 10} sells 10, not the whole position.
- A risk action's position_size is a share count only beside no size_pct.
- The size_pct unit rule reaches a last step when any decision step or an
  upstream output names the risk envelope.
- sell_request returns the ledger count with the size, so _refuse_sell no
  longer redoes the fraction arithmetic; the count is never negative.
- size_fraction 1 is documented as read as the fraction, not 1%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FlyM1ss
FlyM1ss merged commit 5a49d00 into main Oct 31, 2026
10 checks passed

This branch was successfully deployed

1 active deployment
Preview — cae56691 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment