Imported from ea28/autoquant (
AGENTS.md). Install upstream withnpx skills add ea28/autoquant. Copyright stays with the author.
Agent Operating Manual
This is the canonical rulebook for Codex candidate runs in this repo.
Mission
Improve strategy.py for Kalshi KXBTC15M inside a fixed arena.
You are not here to rewrite the harness. You are here to produce a better strategy under controlled evaluation.
Editable surface
Codex candidates may edit:
strategy.py
Codex candidates may read:
workspace_artifacts/workspace_manifest.jsonworkspace_artifacts/strategy_frontier.mdworkspace_artifacts/agent_context.jsonworkspace_artifacts/recent_lessons.jsonprogram.mdREADME.mdresearch_notes.mdarena.pyloop.pykalshi_autoresearch/docs/
Codex candidates must not edit:
research_notes.mdarena.pyloop.py- anything under
kalshi_autoresearch/ - schemas, dependencies, or package metadata
Codex candidates must explicitly state which lane they touched, or which class of change they made if the work was about session validity, replay/live mismatch, feed handling, or maker auto-disable rules.
Required reading order
Before editing, read these in order.
If an artifact below is marked when present, read it if it exists and continue if it does not. Some operator-root sessions will lag the latest artifact set.
workspace_artifacts/workspace_manifest.jsonworkspace_artifacts/strategy_frontier.mdworkspace_artifacts/agent_context.jsonworkspace_artifacts/recent_lessons.jsonworkspace_artifacts/session_validity.jsonworkspace_artifacts/session_compare.jsonworkspace_artifacts/missed_opportunities.jsonworkspace_artifacts/lane_metrics.jsonworkspace_artifacts/feed_health_summary.jsonworkspace_artifacts/order_funnel.jsonwhen presentworkspace_artifacts/fill_reconciliation.jsonwhen presentworkspace_artifacts/repo_map.mdworkspace_artifacts/strategy_quickref.mdworkspace_artifacts/candidate_output.schema.jsonworkspace_artifacts/promotion_policy.mdstrategy.py
Treat that order as intentional. It goes from evaluation context, to editing guardrails, to output contract, to promotion rubric, to code.
Fallback when workspace_artifacts/ is missing
Direct root-repo Codex sessions may not have a pre-seeded workspace_artifacts/ directory.
If that directory is missing, use this fallback order instead:
AGENTS.mdprogram.mddocs/repo-map.mddocs/strategy-quick-reference.mdpython3 arena.py agent-context --write-workspace-artifactspython3 arena.py scoreboardstrategy.py
Do not fail just because workspace_artifacts/ is absent. That directory is guaranteed in candidate workspaces created by loop.py, but not necessarily in the operator root.
In the operator root, treat workspace_artifacts/ as generated state. Refresh it with:
python3 arena.py agent-context --write-workspace-artifacts
Objective
Primary objective:
edge over baselines
Fixed baselines:
no_tradealways_yesalways_no
Important secondary diagnostics:
Sharpe rationet PnL per episodetotal net PnLwithin one split onlymax drawdownorder count / fill count
Optimize for repeatable, risk-adjusted edge. Do not optimize for one lucky replay window.
Current taker lane family:
momentum_followopening_value_v2binary_valuestale_book_repricinglate_value_rescuedeep_value_v2
Current engine posture:
- taker lanes are the default promotable surface
- maker logic is allowed only as a guarded hybrid branch
- maker logic must auto-disable whenever queue awareness, passive-fill realism, or order lifecycle integrity is weak
- a candidate must not assume maker fills or queue priority without saying why the maker branch would stay enabled
Promotion model
There are three different concepts:
- research champion
- promotion eligibility
- deployment readiness
They are not the same.
Promotion eligibility
A candidate is eligible only if it:
- compiles
- changes only
strategy.py - improves train
mean_edge_dollarsversus the current champion - improves validation
mean_edge_dollarsversus the current champion - improves holdout
mean_edge_dollarsversus the current champion - keeps validation
mean_edge_dollarspositive - keeps holdout
mean_edge_dollarspositive - keeps validation
median_edge_dollarsnon-negative - keeps holdout
median_edge_dollarsnon-negative - meets the paired train win-rate threshold
- meets the paired validation win-rate threshold
- passes the runtime promotion gate
Promotion recommendation
You must still explicitly choose one of:
promotekeep_testingdiscard
Outperforming is necessary. It is not sufficient.
Recommend:
promoteonly when the candidate is quantitatively stronger and still strategically trustworthykeep_testingwhen the result is promising but too narrow, fragile, or incompletediscardwhen the change is not worth carrying forward even if one metric improved
Deployment readiness
A research champion is not automatically safe for any live or “real strategy” branch.
Use python3 arena.py scoreboard in the operator repo to inspect readiness.
Deployment readiness is stricter than research promotion. The current readiness gate requires:
- positive train
mean_edge_dollars - positive train
sharpe_ratio - positive validation
mean_edge_dollars - positive validation
median_edge_dollars - positive validation
sharpe_ratio - positive validation
total_net_pnl_dollars - positive holdout
mean_edge_dollars - positive holdout
median_edge_dollars - positive holdout
sharpe_ratio - positive holdout
total_net_pnl_dollars
Live-demo readiness is a separate gate from deployment readiness. It requires explicit session validity, feed health, and enough completed demo sessions to make session-level Sharpe meaningful.
Session validity semantics
Use these meanings consistently when reading live/demo artifacts:
valid: the session reached a tradeable Kalshi market with a fresh actionable book, at least one fresh fast spot feed, and credible order/fill reconciliationinvalid_startup: startup never reached a tradeable market before timeoutfeed_starved: the market existed but required feeds never became safely freshempty_book_startup: the market existed but the book stayed empty or non-actionablemarket_roll_interrupted: the session lost actionability during a roll before the active window could be completed
Older artifacts may collapse empty_book_startup into invalid_startup or stale_kalshi. Treat those as environment invalidations, not as strategy wins.
Safety
- Demo-first by default.
- Candidate workspaces do not contain secrets.
- Candidate subprocesses also run with Kalshi and Polymarket env vars scrubbed.
- If uncertain, prefer lower-risk changes and better diagnostics.
Workspace artifacts
Every candidate workspace includes workspace_artifacts/ with:
workspace_manifest.json: machine-readable workspace contract, commands, reading order, and no-change policystrategy_frontier.md: short dynamic summary of the champion's strengths, weaknesses, and next hypothesesagent_context.json: current scoreboard, recent results, recent lessons, latest session summary, and suggested commandsrecent_lessons.json: compact structured lessons from recent research notesrepo_map.md: where things live and what they dostrategy_quickref.md: short editing and context API referencecandidate_output.schema.json: exact response contractpromotion_policy.md: quantitative gate plus qualitative promotion rulessession_validity.jsonsession_compare.jsonmissed_opportunities.jsonlane_metrics.jsonfeed_health_summary.jsonorder_funnel.jsonwhen availablefill_reconciliation.jsonwhen availabletrain_bank.jsonvalidation_bank.json
Read those first. They are the candidate-safe context layer.
Order funnel artifacts
When present, the order-funnel artifacts are the primary explanation for under-trading or over-canceling:
order_funnel.json: counts from strategy intent through risk block, submit, acknowledge, working, cancel, partial fill, full fill, exit, and flattenfill_reconciliation.json: exchange-versus-local order, fill, and position agreement
If you are proposing a more aggressive strategy, you must explain which part of the funnel should improve and why.
Candidate-safe commands
These commands should work inside a candidate workspace:
python3 -m json.tool workspace_artifacts/workspace_manifest.json
sed -n '1,220p' workspace_artifacts/strategy_frontier.md
python3 -m json.tool workspace_artifacts/agent_context.json
python3 arena.py replay --strategy strategy.py --bank workspace_artifacts/train_bank.json
python3 arena.py replay --strategy strategy.py --bank workspace_artifacts/validation_bank.json
python3 arena.py inspect-live --series KXBTC15M --feed-mode hybrid --wait-seconds 4
Context API reminders
on_market_openis time-bounded.ctx.current_timeis set duringon_market_open.ctx.current_tickis also available duringon_market_openwhen the runtime has an opening snapshot.ctx.market_metadata(ticker)returns immutable market metadata.ctx.recent_reference_ticks(...)andctx.latest_reference_tick(...)expose Binance, Coinbase, and Chainlink RTDS when available.ctx.recent_peer_market_snapshots(...)andctx.latest_peer_market_snapshot(...)expose the matching Polymarket peer market when available.ctx.market_metadata(ticker)should be treated as the source of truth for the active market's immutable metadata.
Strategy design guidance
- Prefer one bounded idea at a time.
- Run the visible workspace replay commands before responding unless you are making a deliberate no-op discard.
- If no safe improvement is justified, it is acceptable to leave
strategy.pyunchanged, setfiles_touchedto[], and recommenddiscard. - Respect fees and spreads.
- Value lanes may use spot direction as a confidence penalty, not a universal veto.
- If touching maker behavior, treat maker auto-disable as a guardrail, not as a failure. The correct behavior can be to fall back to taker-only mode.
- Do not compare raw
total_net_pnl_dollarsacross train, validation, and holdout unless the banks have the same episode count. Usemedian_edge_dollars,mean_edge_dollars,net_pnl_per_episode_dollars,mean_return_pct, andsharpe_ratiofor cross-split comparisons. - The hidden holdout is operator-only. Candidate agents should optimize against train and validation, then let the harness decide whether the change survives the hidden holdout gate.
- Treat Binance and Coinbase as spot proxies, not settlement truth.
- Treat Polymarket as a peer market, not settlement truth.
- Treat Polymarket as read-only in this repo. Do not design around placing Polymarket orders.
- Treat stale feeds as missing data.
- Avoid assumptions about maker fills or queue position.
- Maker work is only a valid promotion target when the candidate can explain why maker auto-disable would remain off and why the replay/live path is still trustworthy.
- Leave enough diagnostics in
on_episode_endfor later agents to understand why the strategy traded or stayed out. - If replay and live behavior diverge, prefer diagnosing that mismatch over broadening the strategy blindly.
Strategy file organization
Keep strategy.py readable. Prefer edits within these internal sections:
- parameters and thresholds
- lifecycle hooks
- signal construction
- entry logic
- exit logic
- diagnostics and math helpers
Do not turn the file into an unstructured threshold dump.
Notes policy
Do not edit research_notes.md directly.
Instead, return:
hypothesisexpected_signalrisk_changeschange_summarydiff_checklistlessons_appliedguardrail_checksfiles_touchedregression_riskswhy_this_should_beat_baselinesrollback_ifnotes_for_next_agentfollow_up_experimentspromotion_recommendationpromotion_rationale
When possible, make the change classification explicit in change_summary and notes_for_next_agent:
strategy-lanesession-validityreplay/live-mismatchfeed-robustnessprompt/docs
New reporting requirements:
- In
change_summary, explicitly include:change_class=...lane=...orlane=noneengine_mode_target=taker|maker|hybrid|maker-auto-disable
- In
guardrail_checks, explicitly say whether maker should remain enabled for the touched scenario or auto-disable. - In
notes_for_next_agent, explicitly state the expected order-funnel effect:- more intents
- better submit-to-ack
- better ack-to-fill
- fewer stale cancels
- cleaner fill reconciliation
- or stricter maker shutdown
Do not add new top-level JSON fields unless the schema is updated. Put the extra reporting inside the existing required fields.
The runtime appends the relevant parts into the shared journal after the run.