Skip to content

feat(research): bind reprice pilots to market episodes - #162

Closed
proerror77 wants to merge 1 commit into
codex/polymarket-canonical-event-endfrom
codex/polymarket-reprice-pilot
Closed

proerror77 wants to merge 1 commit into
codex/polymarket-canonical-event-endfrom
codex/polymarket-reprice-pilot

Conversation

@proerror77

Copy link
Copy Markdown
Owner

Change contract

Provide a fail-closed library contract for BTC 5m reprice pilots: exact Polymarket market identity carried as event_id, one stable Up and Down token per episode, whole-episode train/test cohorts, and a train-only frozen selection evaluated on held-out rows.

Out of scope

CLI execution, MCTS artifact publication, 30-second targets, settlement baselines, Live/Paper, and other horizons.

Dependency or merge order

Layer 3 of 4; base is #161 (which is based on #160). Merge after #161 and before #163. The checked-in BTC and SOL template policy identities rotate because this library is governed policy source.

Focused validation

git diff --check; targeted counterexample test rejects an episode without exactly one Up and one Down token, excludes crossing/missing-end episodes, and proves a threshold is frozen from train rows before held-out evaluation. rustfmt --check was run on owned files. Local Rust compilation was intentionally not run; Linux CI is the build authority.

Rollout/rollback impact

No runtime command changes yet. This adds a reusable research-only fail-closed contract; revert removes the contract and restores the prior policy identity.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22279392-32a0-4508-ba7c-571719e9e26a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-reprice-pilot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proerror77
proerror77 force-pushed the codex/polymarket-reprice-pilot branch from 1670c4b to f6fa62d Compare July 19, 2026 16:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1670c4bb83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1386 to +1388
let matrix = autofactor_matrix_from_v2(rows)?;
let scores = expr.evaluate(&matrix)?;
let labels = autofactor_labels_from_v2(rows, target);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Filter to the target side before evaluating stateful expressions

When expr contains Delta, RollingMean, RollingStd, or ZScore, this evaluates it over the paired Up and Down rows returned by the cohort splitter and removes the opposite side only afterward through its non-finite label. Candidate mining in mine_domain_autofactors_from_v2_with_guidance instead filters to the target side before evaluation, so fitting the same candidate uses a different series, and its frozen threshold and held-out PnL depend on interleaved values from the other token and on row ordering. Filter to the requested side before constructing the matrix while retaining the original row indices for event aggregation.

Useful? React with 👍 / 👎.

Comment on lines +1216 to +1217
for (market_id, (up_tokens, down_tokens)) in event_tokens {
if up_tokens.len() != 1 || down_tokens.len() != 1 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject a token shared by both market sides

When an episode assigns the same non-empty pm_token_id to both Up and Down rows, both sets have length one and this identity check accepts it. That permits one outcome token to masquerade as both sides despite the documented fail-closed requirement for one Up token and one Down token, corrupting side-bound pilot data; reject episodes where the two singleton token sets overlap.

Useful? React with 👍 / 👎.

Comment on lines +1393 to +1394
.filter_map(|(idx, (score, label))| {
(score.is_finite() && label.is_finite()).then_some((idx, score, label))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Account for unfillable full-depth exits in pilot metrics

For these full-depth targets, set_future_exit_labels leaves label_future_exit_full_depth_pnl_10s/30s as None when the observed future book cannot fill the exit, while setting the corresponding fillable label to Some(0.0). This filter drops those decisions before both threshold fitting and held-out selection, so a pilot that selects many positions that cannot be exited can report PnL solely from its few fillable winners and appear profitable. Preserve observed-but-unfillable rows when calculating selection coverage and expose or gate their full-depth exit fill rate instead of silently omitting them.

Useful? React with 👍 / 👎.

@proerror77
proerror77 deleted the branch codex/polymarket-canonical-event-end July 19, 2026 16:39
@proerror77 proerror77 closed this Jul 19, 2026
@proerror77
proerror77 deleted the codex/polymarket-reprice-pilot branch July 24, 2026 08:44
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