pandora-cli-skills 1.1.43 → 1.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +19 -0
  2. package/README_FOR_SHARING.md +21 -0
  3. package/SKILL.md +60 -6
  4. package/cli/lib/arb_command_service.cjs +175 -9
  5. package/cli/lib/arbitrage_service.cjs +187 -3
  6. package/cli/lib/brier_score_service.cjs +271 -0
  7. package/cli/lib/command_router.cjs +6 -0
  8. package/cli/lib/error_recovery_service.cjs +98 -0
  9. package/cli/lib/forecast_store.cjs +361 -0
  10. package/cli/lib/lifecycle_command_service.cjs +5 -24
  11. package/cli/lib/mcp_tool_registry.cjs +52 -1
  12. package/cli/lib/mirror_command_service.cjs +3 -3
  13. package/cli/lib/mirror_econ_service.cjs +409 -1
  14. package/cli/lib/mirror_handlers/deploy.cjs +2 -2
  15. package/cli/lib/mirror_handlers/simulate.cjs +1 -1
  16. package/cli/lib/model_command_service.cjs +99 -0
  17. package/cli/lib/model_diagnose_service.cjs +204 -0
  18. package/cli/lib/model_handlers/calibrate.cjs +181 -0
  19. package/cli/lib/model_handlers/correlation.cjs +406 -0
  20. package/cli/lib/model_handlers/diagnose.cjs +47 -0
  21. package/cli/lib/model_handlers/score_brier.cjs +103 -0
  22. package/cli/lib/model_store.cjs +292 -0
  23. package/cli/lib/pandora_deploy_service.cjs +4 -2
  24. package/cli/lib/parsers/mirror_deploy_flags.cjs +7 -2
  25. package/cli/lib/parsers/mirror_go_flags.cjs +7 -2
  26. package/cli/lib/parsers/mirror_hedge_calc_flags.cjs +7 -2
  27. package/cli/lib/parsers/mirror_remaining_flags.cjs +64 -2
  28. package/cli/lib/parsers/model_flags.cjs +446 -0
  29. package/cli/lib/parsers/simulate_flags.cjs +289 -0
  30. package/cli/lib/parsers/watch_flags.cjs +64 -0
  31. package/cli/lib/quant/abm_market.cjs +312 -0
  32. package/cli/lib/quant/copula.cjs +399 -0
  33. package/cli/lib/quant/errors.cjs +12 -0
  34. package/cli/lib/quant/importance_sampling.cjs +223 -0
  35. package/cli/lib/quant/mc_stats.cjs +179 -0
  36. package/cli/lib/quant/particle_filter.cjs +311 -0
  37. package/cli/lib/quant/rng.cjs +206 -0
  38. package/cli/lib/quant/variance_reduction.cjs +148 -0
  39. package/cli/lib/schema_command_service.cjs +138 -2
  40. package/cli/lib/shared/constants.cjs +6 -0
  41. package/cli/lib/shared/mcp_path_guard.cjs +47 -0
  42. package/cli/lib/shared/model_artifact.cjs +52 -0
  43. package/cli/lib/simulate_command_service.cjs +140 -0
  44. package/cli/lib/simulate_handlers/agents.cjs +209 -0
  45. package/cli/lib/simulate_handlers/common.cjs +361 -0
  46. package/cli/lib/simulate_handlers/mc.cjs +212 -0
  47. package/cli/lib/simulate_handlers/particle_filter.cjs +370 -0
  48. package/cli/lib/sports_model_input_service.cjs +5 -25
  49. package/cli/lib/watch_command_service.cjs +114 -0
  50. package/cli/pandora.cjs +120 -3
  51. package/package.json +2 -2
  52. package/references/creation-script.md +1 -1
  53. package/tests/cli/cli.integration.test.cjs +464 -2
  54. package/tests/cli/mcp.integration.test.cjs +100 -0
  55. package/tests/unit/abm_market.test.cjs +272 -0
  56. package/tests/unit/brier_scoring.test.cjs +74 -0
  57. package/tests/unit/brier_watch_command.test.cjs +121 -0
  58. package/tests/unit/combinatorial_arb.test.cjs +171 -0
  59. package/tests/unit/mirror_simulate_mc.test.cjs +152 -0
  60. package/tests/unit/model_calibrate.test.cjs +142 -0
  61. package/tests/unit/model_correlation.test.cjs +147 -0
  62. package/tests/unit/model_diagnose.test.cjs +83 -0
  63. package/tests/unit/new-features.test.cjs +10 -0
  64. package/tests/unit/quant_core.test.cjs +104 -0
  65. package/tests/unit/quant_models.test.cjs +85 -0
  66. package/tests/unit/quant_stores.test.cjs +134 -0
  67. package/tests/unit/simulate_command_service.test.cjs +91 -0
  68. package/tests/unit/simulate_flags.test.cjs +185 -0
  69. package/tests/unit/simulate_handlers.test.cjs +103 -0
package/README.md CHANGED
@@ -130,6 +130,25 @@ pandora --output json lifecycle resolve --id <lifecycle-id> --confirm
130
130
  - `pandora schema`
131
131
  - `pandora mcp`
132
132
 
133
+ ## Quant ABM Baseline (Module Contract)
134
+
135
+ - Deterministic ABM engine: `cli/lib/quant/abm_market.cjs`.
136
+ - Simulate-agents handler module: `cli/lib/simulate_handlers/agents.cjs`.
137
+ - Supported handler flags:
138
+ - `--n-informed` or `--n_informed`
139
+ - `--n-noise` or `--n_noise`
140
+ - `--n-mm` or `--n_mm`
141
+ - `--n-steps` or `--n_steps`
142
+ - `--seed`
143
+ - ABM payload fields include:
144
+ - `convergenceError`
145
+ - `spreadTrajectory[]`
146
+ - `volume` (`total`, `averagePerStep`, `byAgentType`)
147
+ - `pnlByAgentType`
148
+ - `runtimeBounds` (`complexity`, `estimatedAgentDecisions`, `estimatedWorkUnits`)
149
+ - Runtime bound metadata is documented as `O(n_steps * (n_informed + n_noise))`.
150
+ - Unit coverage for this baseline is in `tests/unit/abm_market.test.cjs`.
151
+
133
152
  ## Docs
134
153
 
135
154
  - Full command contract and workflows: [`SKILL.md`](./SKILL.md)
@@ -136,6 +136,27 @@ Prerequisite: Node.js `>=18`.
136
136
  - `pandora resolve`
137
137
  - `pandora lp add|remove|positions`
138
138
 
139
+ ## Quant ABM baseline (current implementation)
140
+ - Deterministic ABM engine module:
141
+ - `cli/lib/quant/abm_market.cjs`
142
+ - Simulate-agents handler module:
143
+ - `cli/lib/simulate_handlers/agents.cjs`
144
+ - Handler parser accepts:
145
+ - `--n-informed|--n_informed`
146
+ - `--n-noise|--n_noise`
147
+ - `--n-mm|--n_mm`
148
+ - `--n-steps|--n_steps`
149
+ - `--seed`
150
+ - ABM output fields include:
151
+ - `convergenceError`
152
+ - `spreadTrajectory[]`
153
+ - `volume` (`total`, `averagePerStep`, `byAgentType`)
154
+ - `pnlByAgentType`
155
+ - `runtimeBounds` with complexity `O(n_steps * (n_informed + n_noise))`
156
+ - Coverage notes:
157
+ - `tests/unit/abm_market.test.cjs` validates deterministic seed behavior, required ABM metrics, parser/handler behavior, and runtime-bound calculations.
158
+ - `package.json` `test:unit` includes the ABM suite in default unit execution.
159
+
139
160
  ## Agent-native expansion details
140
161
 
141
162
  ### MCP server (`pandora mcp`)
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: pandora-cli-skills
3
3
  summary: Canonical skill and operator guide for Pandora CLI including mirror, polymarket, resolve, and LP flows.
4
- version: 1.1.43
4
+ version: 1.1.44
5
5
  ---
6
6
 
7
7
  # Pandora CLI & Skills
@@ -48,6 +48,7 @@ npm link
48
48
  - Phase 3 analytics command: `pandora portfolio`
49
49
  - Phase 3 monitoring command: `pandora watch`
50
50
  - Phase 3 watch alerts: `--alert-yes-*`, `--alert-net-liquidity-*`, `--fail-on-alert`
51
+ - Phase 3 forecast scoring flags: `--track-brier`, `--brier-source`, `--brier-file`
51
52
  - Phase 4 commands:
52
53
  - `pandora history`
53
54
  - `pandora export`
@@ -61,6 +62,9 @@ npm link
61
62
  - `pandora resolve`
62
63
  - `pandora lp add|remove|positions`
63
64
  - `pandora stream prices|events`
65
+ - Quant/model commands:
66
+ - `pandora simulate mc|particle-filter|agents`
67
+ - `pandora model calibrate|correlation|diagnose|score brier`
64
68
  - Fork runtime flags for transaction families:
65
69
  - `--fork`
66
70
  - `--fork-rpc-url <url>`
@@ -80,6 +84,29 @@ npm link
80
84
  - `max_daily_loss_usd` is enforced as daily live notional (`counters.liveNotionalUsdc`).
81
85
  - `max_open_markets` is enforced as daily live operation count (`counters.liveOps`).
82
86
 
87
+ ## Quant ABM baseline (module contract)
88
+ - Deterministic ABM core:
89
+ - `cli/lib/quant/abm_market.cjs`
90
+ - Simulate-agents handler:
91
+ - `cli/lib/simulate_handlers/agents.cjs`
92
+ - Handler flags:
93
+ - `--n-informed|--n_informed`
94
+ - `--n-noise|--n_noise`
95
+ - `--n-mm|--n_mm`
96
+ - `--n-steps|--n_steps`
97
+ - `--seed`
98
+ - ABM payload fields:
99
+ - `convergenceError`
100
+ - `spreadTrajectory[]`
101
+ - `volume` (`total`, `averagePerStep`, `byAgentType`)
102
+ - `pnlByAgentType`
103
+ - `runtimeBounds` (`complexity`, `estimatedAgentDecisions`, `estimatedWorkUnits`)
104
+ - Runtime complexity metadata: `O(n_steps * (n_informed + n_noise))`.
105
+ - Unit coverage:
106
+ - `tests/unit/abm_market.test.cjs`
107
+ - Note:
108
+ - This section documents the current module + handler contract. Top-level simulate namespace routing can consume this handler when wired by command service.
109
+
83
110
  ## Complete command + flag reference (authoritative)
84
111
  This section mirrors live CLI help output so agent runs can rely on one source of truth.
85
112
 
@@ -93,7 +120,7 @@ pandora [--output table|json] markets list [--limit <n>] [--after <cursor>] [--b
93
120
  pandora [--output table|json] markets get [--id <id> ...] [--stdin]
94
121
  pandora [--output table|json] sports books list|events list|events live|odds snapshot|odds bulk|consensus|create plan|create run|sync once|sync run|sync start|sync stop|sync status|resolve plan [flags]
95
122
  pandora [--output table|json] lifecycle start --config <path>|status --id <id>|resolve --id <id> --confirm
96
- pandora arb scan --markets <csv> --output ndjson|json [--min-net-spread-pct <n>] [--fee-pct-per-leg <n>] [--amount-usdc <n>] [--iterations <n>] [--interval-ms <ms>]
123
+ pandora arb scan --markets <csv> --output ndjson|json [--min-net-spread-pct <n>] [--fee-pct-per-leg <n>] [--slippage-pct-per-leg <n>] [--amount-usdc <n>] [--combinatorial] [--max-bundle-size <n>] [--iterations <n>] [--interval-ms <ms>]
97
124
  pandora [--output table|json] odds record --competition <id> --interval <sec> [--max-samples <n>] [--event-id <id>] [--venues pandora_amm,polymarket]
98
125
  pandora [--output table|json] odds history --event-id <id> --output csv|json [--limit <n>]
99
126
  pandora [--output table|json] polls list [--limit <n>] [--after <cursor>] [--before <cursor>] [--order-by <field>] [--order-direction asc|desc] [--chain-id <id>] [--creator <address>] [--status <int>] [--category <int>] [--question-contains <text>] [--where-json <json>]
@@ -102,7 +129,7 @@ pandora [--output table|json] events list [--type all|liquidity|oracle-fee|claim
102
129
  pandora [--output table|json] events get --id <id> [--type all|liquidity|oracle-fee|claim]
103
130
  pandora [--output table|json] positions list [--wallet <address>] [--market-address <address>] [--chain-id <id>] [--limit <n>] [--after <cursor>] [--before <cursor>] [--order-by <field>] [--order-direction asc|desc] [--where-json <json>]
104
131
  pandora [--output table|json] portfolio --wallet <address> [--chain-id <id>] [--limit <n>] [--include-events|--no-events] [--with-lp] [--rpc-url <url>]
105
- pandora [--output table|json] watch [--wallet <address>] [--market-address <address>] [--side yes|no] [--amount-usdc <amount>] [--iterations <n>] [--interval-ms <ms>] [--chain-id <id>] [--include-events|--no-events] [--yes-pct <0-100>] [--alert-yes-below <0-100>] [--alert-yes-above <0-100>] [--alert-net-liquidity-below <amount>] [--alert-net-liquidity-above <amount>] [--fail-on-alert]
132
+ pandora [--output table|json] watch [--wallet <address>] [--market-address <address>] [--side yes|no] [--amount-usdc <amount>] [--iterations <n>] [--interval-ms <ms>] [--chain-id <id>] [--include-events|--no-events] [--yes-pct <0-100>] [--alert-yes-below <0-100>] [--alert-yes-above <0-100>] [--alert-net-liquidity-below <amount>] [--alert-net-liquidity-above <amount>] [--fail-on-alert] [--track-brier] [--brier-source <name>] [--brier-file <path>] [--group-by source|market|competition]
106
133
  pandora [--output table|json] scan [--limit <n>] [--after <cursor>] [--before <cursor>] [--order-by <field>] [--order-direction asc|desc] [--chain-id <id>] [--creator <address>] [--poll-address <address>] [--market-type <type>] [--where-json <json>] [--active|--resolved|--expiring-soon] [--expiring-hours <n>] [--expand]
107
134
  pandora [--output table|json] quote [--indexer-url <url>] [--timeout-ms <ms>] --market-address <address> --side yes|no --amount-usdc <amount> [--yes-pct <0-100>] [--slippage-bps <0-10000>]
108
135
  pandora [--output table|json] trade [--indexer-url <url>] [--timeout-ms <ms>] [--dotenv-path <path>] [--skip-dotenv] --market-address <address> --side yes|no --amount-usdc <amount> --dry-run|--execute [--yes-pct <0-100>] [--slippage-bps <0-10000>] [--min-shares-out-raw <uint>] [--max-amount-usdc <amount>] [--min-probability-pct <0-100>] [--max-probability-pct <0-100>] [--allow-unquoted-execute] [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--usdc <address>]
@@ -111,6 +138,8 @@ pandora [--output table|json] export --wallet <address> --format csv|json [--cha
111
138
  pandora [--output table|json] arbitrage [--chain-id <id>] [--venues pandora,polymarket] [--limit <n>] [--min-spread-pct <n>] [--min-liquidity-usdc <n>] [--max-close-diff-hours <n>] [--similarity-threshold <0-1>] [--cross-venue-only|--allow-same-venue] [--with-rules] [--include-similarity] [--question-contains <text>] [--polymarket-host <url>] [--polymarket-mock-url <url>]
112
139
  pandora [--output table|json] autopilot run|once --market-address <address> --side yes|no --amount-usdc <amount> [--trigger-yes-below <0-100>] [--trigger-yes-above <0-100>] [--paper|--execute-live] [--interval-ms <ms>] [--cooldown-ms <ms>] [--max-amount-usdc <amount>] [--max-open-exposure-usdc <amount>] [--max-trades-per-day <n>] [--state-file <path>] [--kill-switch-file <path>] [--webhook-url <url>] [--telegram-bot-token <token>] [--telegram-chat-id <id>] [--discord-webhook-url <url>]
113
140
  pandora [--output table|json] mirror browse|plan|deploy|verify|lp-explain|hedge-calc|simulate|go|sync|status|close ...
141
+ pandora [--output table|json] simulate mc|particle-filter|agents ...
142
+ pandora [--output table|json] model calibrate|correlation|diagnose|score brier ...
114
143
  pandora [--output table|json] polymarket check|approve|preflight|trade ...
115
144
  pandora [--output table|json] webhook test [--webhook-url <url>] [--webhook-template <json>] [--webhook-secret <secret>] [--telegram-bot-token <token>] [--telegram-chat-id <id>] [--discord-webhook-url <url>] [--webhook-timeout-ms <ms>] [--webhook-retries <n>]
116
145
  pandora [--output table|json] leaderboard [--metric profit|volume|win-rate] [--chain-id <id>] [--limit <n>] [--min-trades <n>]
@@ -131,12 +160,12 @@ Mirror subcommand detail:
131
160
  ```text
132
161
  browse --min-yes-pct <n> --max-yes-pct <n> --min-volume-24h <n> [--closes-after <date>] [--closes-before <date>] [--question-contains <text>] [--limit <n>] [--chain-id <id>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
133
162
  plan --source polymarket --polymarket-market-id <id>|--polymarket-slug <slug> [--chain-id <id>] [--target-slippage-bps <n>] [--turnover-target <n>] [--depth-slippage-bps <n>] [--safety-multiplier <n>] [--min-liquidity-usdc <n>] [--max-liquidity-usdc <n>] [--with-rules] [--include-similarity] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
134
- deploy --plan-file <path>|--polymarket-market-id <id>|--polymarket-slug <slug> --dry-run|--execute [--liquidity-usdc <n>] [--fee-tier 500|3000|10000] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--oracle <address>] [--factory <address>] [--usdc <address>] [--distribution-yes <parts>] [--distribution-no <parts>] [--sources <url...>] [--min-close-lead-seconds <n>] [--manifest-file <path>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
163
+ deploy --plan-file <path>|--polymarket-market-id <id>|--polymarket-slug <slug> --dry-run|--execute [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--oracle <address>] [--factory <address>] [--usdc <address>] [--distribution-yes <parts>] [--distribution-no <parts>] [--sources <url...>] [--min-close-lead-seconds <n>] [--manifest-file <path>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
135
164
  verify --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug> [--trust-deploy] [--manifest-file <path>] [--include-similarity] [--with-rules] [--allow-rule-mismatch] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
136
165
  lp-explain --liquidity-usdc <n> [--source-yes-pct <0-100>] [--distribution-yes <parts>] [--distribution-no <parts>]
137
166
  hedge-calc [--reserve-yes-usdc <n> --reserve-no-usdc <n>] [--excess-yes-usdc <n>] [--excess-no-usdc <n>] [--polymarket-yes-pct <0-100>] [--hedge-ratio <n>] [--hedge-cost-bps <n>] [--volume-scenarios <csv>] [--pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug>] [--trust-deploy] [--manifest-file <path>]
138
- simulate --liquidity-usdc <n> [--source-yes-pct <0-100>] [--target-yes-pct <0-100>] [--distribution-yes <parts>] [--distribution-no <parts>] [--fee-tier 500|3000|10000] [--volume-scenarios <csv>] [--hedge-ratio <n>] [--hedge-cost-bps <n>] [--polymarket-yes-pct <0-100>]
139
- go --polymarket-market-id <id>|--polymarket-slug <slug> [--liquidity-usdc <n>] [--fee-tier 500|3000|10000] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--paper|--dry-run|--execute-live|--execute] [--auto-sync] [--sync-once] [--sync-interval-ms <ms>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--oracle <address>] [--factory <address>] [--sources <url...>] [--manifest-file <path>] [--trust-deploy] [--skip-gate] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--with-rules] [--include-similarity] [--min-close-lead-seconds <n>]
167
+ simulate --liquidity-usdc <n> [--source-yes-pct <0-100>] [--target-yes-pct <0-100>] [--distribution-yes <parts>] [--distribution-no <parts>] [--fee-tier <500-50000>] [--volume-scenarios <csv>] [--hedge-ratio <n>] [--hedge-cost-bps <n>] [--polymarket-yes-pct <0-100>]
168
+ go --polymarket-market-id <id>|--polymarket-slug <slug> [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--paper|--dry-run|--execute-live|--execute] [--auto-sync] [--sync-once] [--sync-interval-ms <ms>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--oracle <address>] [--factory <address>] [--sources <url...>] [--manifest-file <path>] [--trust-deploy] [--skip-gate] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--with-rules] [--include-similarity] [--min-close-lead-seconds <n>]
140
169
  sync run|once|start --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug> [--paper|--dry-run|--execute-live|--execute] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--trust-deploy] [--manifest-file <path>] [--skip-gate] [--daemon] [--stream|--no-stream] [--interval-ms <ms>] [--drift-trigger-bps <n>] [--hedge-trigger-usdc <n>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--depth-slippage-bps <n>] [--min-time-to-close-sec <n>] [--iterations <n>] [--state-file <path>] [--kill-switch-file <path>] [--chain-id <id>] [--rpc-url <url>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--webhook-url <url>] [--telegram-bot-token <token>] [--telegram-chat-id <id>] [--discord-webhook-url <url>]
141
170
  status --state-file <path>|--strategy-hash <hash> [--with-live] [--pandora-market-address <address>|--market-address <address>] [--polymarket-market-id <id>|--polymarket-slug <slug>]
142
171
  close --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug> --dry-run|--execute
@@ -158,6 +187,18 @@ preflight [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--rpc-url <url
158
187
  trade --condition-id <id>|--slug <slug>|--token-id <id> --token yes|no --amount-usdc <n> --dry-run|--execute [--side buy|sell] [--polymarket-host <url>] [--polymarket-mock-url <url>] [--timeout-ms <ms>] [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--funder <address>]
159
188
  ```
160
189
 
190
+ Simulate/model subcommand detail:
191
+
192
+ ```text
193
+ simulate mc [--trials <n>] [--horizon <n>] [--start-yes-pct <0-100>] [--entry-yes-pct <0-100>] [--position yes|no] [--stake-usdc <n>] [--drift-bps <n>] [--vol-bps <n>] [--confidence <50-100>] [--var-level <50-100>] [--seed <n>] [--antithetic] [--stratified]
194
+ simulate particle-filter (--observations-json <json>|--input <path>|--stdin) [--particles <n>] [--process-noise <n>] [--observation-noise <n>] [--drift-bps <n>] [--initial-yes-pct <0-100>] [--initial-spread <n>] [--resample-threshold <0-1>] [--resample-method systematic|multinomial] [--credible-interval <50-100>] [--seed <n>]
195
+ simulate agents [--n-informed <n>] [--n-noise <n>] [--n-mm <n>] [--n-steps <n>] [--seed <int>]
196
+ model calibrate (--prices <csv>|--returns <csv>) [--dt <n>] [--jump-threshold-sigma <n>] [--min-jump-count <n>] [--model-id <id>] [--save-model <path>]
197
+ model correlation --series <id:v1,v2,...> --series <id:v1,v2,...> [--copula t|gaussian|clayton|gumbel] [--compare <csv>] [--tail-alpha <n>] [--df <n>] [--joint-threshold-z <n>] [--scenario-shocks <csv>] [--model-id <id>] [--save-model <path>]
198
+ model diagnose [--calibration-rmse <n>] [--drift-bps <n>] [--spread-bps <n>] [--depth-coverage <0..1>] [--informed-flow-ratio <0..1>] [--noise-ratio <0..1>] [--anomaly-rate <0..1>] [--manipulation-alerts <n>] [--tail-dependence <0..1>]
199
+ model score brier [--source <name>] [--market-address <address>] [--competition <id>] [--event-id <id>] [--model-id <id>] [--group-by source|market|competition|model|none] [--window-days <n>] [--bucket-count <n>] [--forecast-file <path>] [--include-records] [--include-unresolved] [--limit <n>]
200
+ ```
201
+
161
202
  ## Sports command matrix
162
203
  | Command | Purpose | Primary flags |
163
204
  | --- | --- | --- |
@@ -448,6 +489,10 @@ Common structured error codes for automation:
448
489
  - `ODDS_*`: odds record/history storage and connector failures.
449
490
  - `ARB_*`: arb scan parsing/execution output-mode failures.
450
491
  - `CONFIG_*`: config read/parse failures (for example `CONFIG_FILE_NOT_FOUND`).
492
+ - `SIMULATE_*`: simulate namespace failures (`SIMULATE_MC_INVALID_INPUT`, `SIMULATE_PARTICLE_FILTER_FAILED`, `SIMULATE_AGENTS_FAILED`).
493
+ - `MODEL_*`: model namespace failures (`MODEL_CALIBRATE_INVALID_INPUT`, `MODEL_CORRELATION_FAILED`, `MODEL_DIAGNOSE_INVALID_INPUT`, `MODEL_SCORE_BRIER_FAILED`).
494
+ - `FORECAST_*`: forecast ledger read/write/normalization failures (`FORECAST_WRITE_FAILED`, `FORECAST_INVALID_RECORD`, `FORECAST_READ_FAILED`).
495
+ - `BRIER_*`: brier scoring input/grouping failures (`BRIER_INVALID_INPUT`, `BRIER_INVALID_GROUP_BY`, `BRIER_FAILED`).
451
496
  - `MCP_FILE_ACCESS_BLOCKED`: MCP-mode file path denied outside workspace root.
452
497
  - `WEBHOOK_DELIVERY_FAILED`: webhook hard-fail when `--fail-on-webhook-error` is set.
453
498
 
@@ -530,6 +575,15 @@ Error envelope:
530
575
  - `lp positions`: `{ ok: true, command: "lp", data: { schemaVersion, generatedAt, action: "positions", mode: "read", wallet, count, items[] } }`
531
576
  - `polymarket`:
532
577
  - `check|preflight|approve|trade` all return `{ ok: true, command, data }` with `schemaVersion` and `generatedAt`; execute paths include `result`/`tx` blocks.
578
+ - `simulate`:
579
+ - `simulate.mc`: `{ ok: true, command: "simulate.mc", data: { schemaVersion, generatedAt, inputs, summary, distribution, diagnostics[] } }`
580
+ - `simulate.particle-filter`: `{ ok: true, command: "simulate.particle-filter", data: { schemaVersion, generatedAt, inputs, summary, trajectory[], diagnostics[] } }`
581
+ - `simulate.agents`: `{ ok: true, command: "simulate.agents", data: { schemaVersion, generatedAt, parameters, convergenceError, spreadTrajectory[], volume, pnlByAgentType, finalState, runtimeBounds } }`
582
+ - `model`:
583
+ - `model.calibrate`: `{ ok: true, command: "model.calibrate", data: { schemaVersion, generatedAt, action: "calibrate", model, diagnostics, persistence } }`
584
+ - `model.correlation`: `{ ok: true, command: "model.correlation", data: { schemaVersion, generatedAt, action: "correlation", copula, metrics, stress, comparisons, diagnostics, model, persistence } }`
585
+ - `model.diagnose`: `{ ok: true, command: "model.diagnose", data: { schemaVersion, generatedAt, inputs, components, aggregate, recommendations, flags, diagnostics[] } }`
586
+ - `model.score.brier`: `{ ok: true, command: "model.score.brier", data: { schemaVersion, generatedAt, action: "score.brier", filters, ledger, report, diagnostics[] } }`
533
587
  - `leaderboard`:
534
588
  - `{ ok: true, command: "leaderboard", data: { schemaVersion, generatedAt, indexerUrl, metric, limit, minTrades, count, items[], diagnostics[] } }`
535
589
  - `analyze`:
@@ -14,7 +14,7 @@ const ARB_MARKET_FIELDS = [
14
14
  ];
15
15
 
16
16
  const ARB_USAGE =
17
- 'pandora arb scan --markets <csv> --output ndjson|json [--min-net-spread-pct <n>] [--fee-pct-per-leg <n>] [--amount-usdc <n>] [--interval-ms <ms>] [--iterations <n>] [--indexer-url <url>] [--timeout-ms <ms>]';
17
+ 'pandora arb scan --markets <csv> --output ndjson|json [--min-net-spread-pct <n>] [--fee-pct-per-leg <n>] [--slippage-pct-per-leg <n>] [--amount-usdc <n>] [--combinatorial] [--max-bundle-size <n>] [--interval-ms <ms>] [--iterations <n>] [--indexer-url <url>] [--timeout-ms <ms>]';
18
18
 
19
19
  function requireDep(deps, name) {
20
20
  if (!deps || typeof deps[name] !== 'function') {
@@ -139,6 +139,114 @@ function buildArbOpportunities(options) {
139
139
  return opportunities;
140
140
  }
141
141
 
142
+ function enumerateCombinations(items, size, onCombination) {
143
+ if (!Array.isArray(items) || !Number.isInteger(size) || size < 1 || size > items.length) return;
144
+ if (typeof onCombination !== 'function') return;
145
+
146
+ const selected = [];
147
+ function walk(startIndex) {
148
+ if (selected.length === size) {
149
+ onCombination(selected.slice());
150
+ return;
151
+ }
152
+ const remaining = size - selected.length;
153
+ const maxStart = items.length - remaining;
154
+ for (let index = startIndex; index <= maxStart; index += 1) {
155
+ selected.push(items[index]);
156
+ walk(index + 1);
157
+ selected.pop();
158
+ }
159
+ }
160
+ walk(0);
161
+ }
162
+
163
+ /**
164
+ * Build bundle-level combinatorial opportunities across provided markets.
165
+ * @param {object} options
166
+ * @returns {object[]}
167
+ */
168
+ function buildCombinatorialArbOpportunities(options) {
169
+ const marketSnapshots = Array.isArray(options.marketSnapshots)
170
+ ? options.marketSnapshots.filter((item) => item && Number.isFinite(item.yesPct))
171
+ : [];
172
+ if (marketSnapshots.length < 3) return [];
173
+
174
+ const minNetSpreadPct = Number.isFinite(options.minNetSpreadPct) ? Number(options.minNetSpreadPct) : 0;
175
+ const feePctPerLeg = Number.isFinite(options.feePctPerLeg) ? Number(options.feePctPerLeg) : 0;
176
+ const slippagePctPerLeg = Number.isFinite(options.slippagePctPerLeg) ? Number(options.slippagePctPerLeg) : 0;
177
+ const amountUsdc = Number.isFinite(options.amountUsdc) ? Number(options.amountUsdc) : 0;
178
+ const requestedMaxBundleSize = Number.isInteger(options.maxBundleSize) ? options.maxBundleSize : 4;
179
+ const maxBundleSize = Math.max(3, Math.min(requestedMaxBundleSize, marketSnapshots.length));
180
+
181
+ const opportunities = [];
182
+ for (let bundleSize = 3; bundleSize <= maxBundleSize; bundleSize += 1) {
183
+ enumerateCombinations(marketSnapshots, bundleSize, (bundle) => {
184
+ const bundleMarketIds = bundle.map((item) => item.id);
185
+ const sumYesPct = roundNumber(bundle.reduce((total, item) => total + Number(item.yesPct), 0), 6);
186
+ const sumNoPct = roundNumber(bundle.reduce((total, item) => total + (100 - Number(item.yesPct)), 0), 6);
187
+ const feeImpactPct = roundNumber(bundleSize * feePctPerLeg, 6);
188
+ const slippageImpactPct = roundNumber(bundleSize * slippagePctPerLeg, 6);
189
+
190
+ const evaluate = (strategy) => {
191
+ const grossEdgePct = strategy === 'buy_yes_bundle' ? roundNumber(100 - sumYesPct, 6) : roundNumber(sumYesPct - 100, 6);
192
+ if (grossEdgePct <= 0) return;
193
+
194
+ const netSpreadPct = roundNumber(grossEdgePct - feeImpactPct - slippageImpactPct, 6);
195
+ if (netSpreadPct <= 0 || netSpreadPct < minNetSpreadPct) return;
196
+
197
+ const payoutPct = strategy === 'buy_yes_bundle' ? 100 : roundNumber((bundleSize - 1) * 100, 6);
198
+ const totalEntryPct = strategy === 'buy_yes_bundle' ? sumYesPct : sumNoPct;
199
+ const grossProfitUsdc = roundNumber((amountUsdc * grossEdgePct) / 100, 6);
200
+ const profitUsdc = roundNumber((amountUsdc * netSpreadPct) / 100, 6);
201
+
202
+ opportunities.push({
203
+ opportunityType: 'combinatorial',
204
+ strategy,
205
+ pair: `bundle:${bundleMarketIds.join('|')}:${strategy}`,
206
+ bundleMarketIds,
207
+ bundleSize,
208
+ legs: bundle.map((item) => ({
209
+ marketId: item.id,
210
+ yesPct: roundNumber(item.yesPct, 6),
211
+ noPct: roundNumber(100 - item.yesPct, 6),
212
+ })),
213
+ sumYesPct,
214
+ sumNoPct,
215
+ totalEntryPct,
216
+ payoutPct,
217
+ grossSpreadPct: grossEdgePct,
218
+ grossEdgePct,
219
+ feePctPerLeg: roundNumber(feePctPerLeg, 6),
220
+ slippagePctPerLeg: roundNumber(slippagePctPerLeg, 6),
221
+ feeImpactPct,
222
+ slippageImpactPct,
223
+ netSpreadPct,
224
+ netSpread: roundNumber(netSpreadPct / 100, 8),
225
+ amountUsdc: roundNumber(amountUsdc, 6),
226
+ grossProfitUsdc,
227
+ profitUsdc,
228
+ profit: profitUsdc,
229
+ });
230
+ };
231
+
232
+ evaluate('buy_yes_bundle');
233
+ evaluate('buy_no_bundle');
234
+ });
235
+ }
236
+
237
+ opportunities.sort((left, right) => {
238
+ if (right.netSpreadPct !== left.netSpreadPct) {
239
+ return right.netSpreadPct - left.netSpreadPct;
240
+ }
241
+ if (right.bundleSize !== left.bundleSize) {
242
+ return right.bundleSize - left.bundleSize;
243
+ }
244
+ return left.pair.localeCompare(right.pair);
245
+ });
246
+
247
+ return opportunities;
248
+ }
249
+
142
250
  /**
143
251
  * Parse `arb scan` command flags.
144
252
  * @param {string[]} args
@@ -159,7 +267,10 @@ function parseArbScanFlags(args, deps) {
159
267
  output: 'ndjson',
160
268
  minNetSpreadPct: 0,
161
269
  feePctPerLeg: 0,
270
+ slippagePctPerLeg: 0,
162
271
  amountUsdc: 100,
272
+ combinatorial: false,
273
+ maxBundleSize: 4,
163
274
  intervalMs: 5_000,
164
275
  iterations: null,
165
276
  };
@@ -187,11 +298,25 @@ function parseArbScanFlags(args, deps) {
187
298
  i += 1;
188
299
  continue;
189
300
  }
301
+ if (token === '--slippage-pct-per-leg') {
302
+ options.slippagePctPerLeg = parseNumber(requireFlagValue(rest, i, '--slippage-pct-per-leg'), '--slippage-pct-per-leg');
303
+ i += 1;
304
+ continue;
305
+ }
190
306
  if (token === '--amount-usdc') {
191
307
  options.amountUsdc = parsePositiveNumber(requireFlagValue(rest, i, '--amount-usdc'), '--amount-usdc');
192
308
  i += 1;
193
309
  continue;
194
310
  }
311
+ if (token === '--combinatorial') {
312
+ options.combinatorial = true;
313
+ continue;
314
+ }
315
+ if (token === '--max-bundle-size') {
316
+ options.maxBundleSize = parsePositiveInteger(requireFlagValue(rest, i, '--max-bundle-size'), '--max-bundle-size');
317
+ i += 1;
318
+ continue;
319
+ }
195
320
  if (token === '--interval-ms') {
196
321
  options.intervalMs = parsePositiveInteger(requireFlagValue(rest, i, '--interval-ms'), '--interval-ms');
197
322
  i += 1;
@@ -222,6 +347,14 @@ function parseArbScanFlags(args, deps) {
222
347
  throw new CliError('INVALID_FLAG_VALUE', '--fee-pct-per-leg must be >= 0.');
223
348
  }
224
349
 
350
+ if (options.slippagePctPerLeg < 0) {
351
+ throw new CliError('INVALID_FLAG_VALUE', '--slippage-pct-per-leg must be >= 0.');
352
+ }
353
+
354
+ if (!Number.isInteger(options.maxBundleSize) || options.maxBundleSize < 3) {
355
+ throw new CliError('INVALID_FLAG_VALUE', '--max-bundle-size must be an integer >= 3.');
356
+ }
357
+
225
358
  options.markets = Array.from(
226
359
  new Set(
227
360
  options.markets
@@ -234,6 +367,10 @@ function parseArbScanFlags(args, deps) {
234
367
  throw new CliError('INVALID_ARGS', 'arb scan requires at least two distinct market ids.');
235
368
  }
236
369
 
370
+ if (options.combinatorial && options.markets.length < 3) {
371
+ throw new CliError('INVALID_ARGS', 'arb scan --combinatorial requires at least three distinct market ids.');
372
+ }
373
+
237
374
  return options;
238
375
  }
239
376
 
@@ -313,7 +450,8 @@ function createRunArbCommand(deps) {
313
450
 
314
451
  const maxIterations = Number.isInteger(options.iterations) ? options.iterations : Number.POSITIVE_INFINITY;
315
452
  let iteration = 0;
316
- const snapshots = [];
453
+ const iterationSnapshots = [];
454
+ let emittedCombinatorialCount = 0;
317
455
 
318
456
  while (iteration < maxIterations) {
319
457
  iteration += 1;
@@ -321,13 +459,30 @@ function createRunArbCommand(deps) {
321
459
  buildGraphqlGetQuery,
322
460
  graphqlRequest,
323
461
  });
324
- const snapshots = buildMarketSnapshots(markets, options.markets);
325
- const opportunities = buildArbOpportunities({
326
- marketSnapshots: snapshots,
462
+ const marketSnapshots = buildMarketSnapshots(markets, options.markets);
463
+ const pairwiseOpportunities = buildArbOpportunities({
464
+ marketSnapshots,
327
465
  minNetSpreadPct: options.minNetSpreadPct,
328
466
  feePctPerLeg: options.feePctPerLeg,
329
467
  amountUsdc: options.amountUsdc,
330
468
  });
469
+ const combinatorialOpportunities = options.combinatorial
470
+ ? buildCombinatorialArbOpportunities({
471
+ marketSnapshots,
472
+ minNetSpreadPct: options.minNetSpreadPct,
473
+ feePctPerLeg: options.feePctPerLeg,
474
+ slippagePctPerLeg: options.slippagePctPerLeg,
475
+ amountUsdc: options.amountUsdc,
476
+ maxBundleSize: options.maxBundleSize,
477
+ })
478
+ : [];
479
+ emittedCombinatorialCount += combinatorialOpportunities.length;
480
+ const opportunities = [...pairwiseOpportunities, ...combinatorialOpportunities].sort((left, right) => {
481
+ if (right.netSpreadPct !== left.netSpreadPct) {
482
+ return right.netSpreadPct - left.netSpreadPct;
483
+ }
484
+ return String(left.pair || '').localeCompare(String(right.pair || ''));
485
+ });
331
486
 
332
487
  if (options.output === 'ndjson') {
333
488
  for (const opportunity of opportunities) {
@@ -343,10 +498,12 @@ function createRunArbCommand(deps) {
343
498
  );
344
499
  }
345
500
  } else {
346
- snapshots.push({
501
+ iterationSnapshots.push({
347
502
  iteration,
348
503
  observedAt: new Date().toISOString(),
349
504
  count: opportunities.length,
505
+ pairwiseCount: pairwiseOpportunities.length,
506
+ combinatorialCount: combinatorialOpportunities.length,
350
507
  opportunities,
351
508
  });
352
509
  }
@@ -357,6 +514,11 @@ function createRunArbCommand(deps) {
357
514
  }
358
515
 
359
516
  if (options.output === 'json') {
517
+ const diagnostics = [];
518
+ if (options.combinatorial && emittedCombinatorialCount === 0) {
519
+ diagnostics.push('No combinatorial bundles cleared net spread thresholds for this run.');
520
+ }
521
+
360
522
  const payload = {
361
523
  action: 'scan',
362
524
  indexerUrl,
@@ -367,11 +529,14 @@ function createRunArbCommand(deps) {
367
529
  markets: options.markets,
368
530
  minNetSpreadPct: options.minNetSpreadPct,
369
531
  feePctPerLeg: options.feePctPerLeg,
532
+ slippagePctPerLeg: options.slippagePctPerLeg,
370
533
  amountUsdc: options.amountUsdc,
534
+ combinatorial: options.combinatorial,
535
+ maxBundleSize: options.maxBundleSize,
371
536
  },
372
- opportunities: snapshots.flatMap((row) => row.opportunities),
373
- snapshots,
374
- diagnostics: [],
537
+ opportunities: iterationSnapshots.flatMap((row) => row.opportunities),
538
+ snapshots: iterationSnapshots,
539
+ diagnostics,
375
540
  };
376
541
 
377
542
  if (context.outputMode === 'json') {
@@ -387,6 +552,7 @@ function createRunArbCommand(deps) {
387
552
  module.exports = {
388
553
  ARB_USAGE,
389
554
  buildArbOpportunities,
555
+ buildCombinatorialArbOpportunities,
390
556
  createRunArbCommand,
391
557
  parseArbScanFlags,
392
558
  };