mirror of
https://github.com/theodore-song/polymarket-analyst.git
synced 2026-08-24 04:58:08 +00:00
Fix live bundle minimum execution
This commit is contained in:
@@ -34,7 +34,7 @@ jobs:
|
||||
- run: node scripts/run-autonomous-cycle.mjs
|
||||
env:
|
||||
ARENA_URL: https://polymarket-site-eta.vercel.app
|
||||
EXPECTED_BUILD: "107"
|
||||
EXPECTED_BUILD: "108"
|
||||
RUNTIME_BRANCH: runtime-state
|
||||
RUNTIME_STATE_PATH: runtime/state.json
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -20,7 +20,7 @@ market snapshots. During an outage, cycles continue locally; cached entries are
|
||||
allowed for 90 minutes, older snapshots become mark-only, and all cached data
|
||||
expires after 24 hours.
|
||||
|
||||
Build 107 runs the headless GitHub Actions runtime every five minutes, continues
|
||||
Build 108 runs the headless GitHub Actions runtime every five minutes, continues
|
||||
from the previous agent snapshot,
|
||||
and runs the next due paper cycle even when no browser is open. It writes a
|
||||
sanitized snapshot to the `runtime-state` branch and `/api/state` uses that as a
|
||||
@@ -41,7 +41,7 @@ Polymarket event key. Related Ethereum or Bitcoin contracts cannot create
|
||||
several simultaneous copies of one move, and outcomes from the same underlying
|
||||
three-hour shock window count as one learner event.
|
||||
|
||||
Each Build 107 cycle also scans the 1,000 most-active Polymarket events for
|
||||
Each Build 108 cycle also scans the 1,000 most-active Polymarket events for
|
||||
complete negative-risk bundles and logically nested threshold or deadline
|
||||
pairs. Gamma's market-specific fee flag replaces the old blanket 0.5-cent fee
|
||||
reserve for markets declared fee-free. The closest 60 structures are then
|
||||
@@ -57,7 +57,7 @@ The Suggestions view stores scan, depth, fee, actionable, and closest
|
||||
executable-margin counts so an empty lane is evidence rather than an ambiguous
|
||||
failure.
|
||||
|
||||
Build 107 retains the directional learner's exact-fee policy, which replaced the blanket half-cent cost with
|
||||
Build 108 retains the directional learner's exact-fee policy, which replaced the blanket half-cent cost with
|
||||
the market's Gamma fee schedule at both the entry and future checkpoint, plus a
|
||||
separate half-cent round-trip slippage allowance. Fee-free markets pay only the
|
||||
slippage allowance; an unavailable fee schedule gets a conservative four-cent
|
||||
@@ -73,7 +73,7 @@ directional evidence under fee policy 2 and keeps those lanes observation-only
|
||||
until current independent 24-hour and 72-hour cohorts pass the existing
|
||||
promotion gate.
|
||||
|
||||
Build 107 retains Build 100's retirement of the old 3-6 day resolution-window
|
||||
Build 108 retains Build 100's retirement of the old 3-6 day resolution-window
|
||||
capital permission. That audit clustered confidence by event but still averaged
|
||||
several correlated contracts inside each event, while production could choose
|
||||
only one. The corrected replay chooses the highest-volume eligible contract per event and
|
||||
@@ -193,7 +193,7 @@ evidence proves an edge.
|
||||
|
||||
Run `npm run evaluate:sports-favorites` for the retired pregame favorite audit.
|
||||
Its 12-hour, 60%-75% cohort had positive point estimates but did not establish a
|
||||
reliable confidence bound, so Build 107 no longer allocates capital to that rule.
|
||||
reliable confidence bound, so Build 108 no longer allocates capital to that rule.
|
||||
|
||||
Strategy 62 instead uses the exact-fee settlement calibration's three-day Sports
|
||||
NO cohort as a bounded paper exploration lane. The corrected 5,000-market run
|
||||
|
||||
+49
-10
@@ -341,7 +341,7 @@ footer{margin-top:34px;padding-top:22px;border-top:1px solid var(--border);color
|
||||
<nav class="topnav">
|
||||
<div class="brand">
|
||||
<div class="logo">🏆</div>
|
||||
<div><div class="brand-name">Polymarket Arena</div><div class="brand-sub">10 agents · 5 core + 5 aggressive</div><div class="build-badge">Adaptive strategy 62 · contest-level learning · build 107</div></div>
|
||||
<div><div class="brand-name">Polymarket Arena</div><div class="brand-sub">10 agents · 5 core + 5 aggressive</div><div class="build-badge">Adaptive strategy 62 · contest-level learning · build 108</div></div>
|
||||
</div>
|
||||
<div class="tabs" id="tabs">
|
||||
<button class="tab" data-tab="overview">Overview</button>
|
||||
@@ -363,7 +363,7 @@ footer{margin-top:34px;padding-top:22px;border-top:1px solid var(--border);color
|
||||
<div class="personal-banner" id="personalBanner">
|
||||
<b>Personal research mode.</b> This copy is for your own analysis, paper tracking, and manual trade research only. It does not pool money, onboard investors, custody funds, bypass eligibility rules, or place orders without your manual approval.
|
||||
</div>
|
||||
<div class="live-build-banner"><b>Build 107 active:</b> The public paper agents run autonomously every five minutes while every user device is closed. Each cycle scans the 500 most-active eligible markets and 1,000 most-active events, carries exact Gamma fee schedules through cloud and offline caches, and checks complete bundles against live depth. Strategy 62 adds a bounded sports-contest NO exploration lane: one highest-priced NO contract per real contest near the three-day checkpoint, exact entry fee plus slippage, 0.5% initial size, 3% total cap, and automatic forward promotion or suspension. This point-positive historical pattern is not a proven edge. Phones and computers display the same read-only autonomous state. Profits are not guaranteed.</div>
|
||||
<div class="live-build-banner"><b>Build 108 active:</b> The public paper agents run autonomously every five minutes while every user device is closed. Each cycle scans the 500 most-active eligible markets and 1,000 most-active events, carries exact Gamma fee schedules through cloud and offline caches, and checks complete bundles against live depth. Strategy 62 adds a bounded sports-contest NO exploration lane: one highest-priced NO contract per real contest near the three-day checkpoint, exact entry fee plus slippage, 0.5% initial size, 3% total cap, and automatic forward promotion or suspension. This point-positive historical pattern is not a proven edge. Phones and computers display the same read-only autonomous state. Profits are not guaranteed.</div>
|
||||
|
||||
<!-- ============ OVERVIEW ============ -->
|
||||
<section class="tabpanel" data-tab="overview">
|
||||
@@ -745,7 +745,7 @@ footer{margin-top:34px;padding-top:22px;border-top:1px solid var(--border);color
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
Build 107 · Adaptive strategy 62 · Five-minute autonomous scans · Exact-fee directional learning · Contest-deduplicated sports exploration · Live depth, fee, and size-verified bundle audit · Corrected one-decision-per-event settlement audit · Autonomous runtime 1 · Offline runtime 2 · Maker research 3 · Agent learning 3 · Paper trading only · Live prices from Polymarket's public Gamma and CLOB APIs · Not financial advice ·
|
||||
Build 108 · Adaptive strategy 62 · Five-minute autonomous scans · Exact-fee directional learning · Contest-deduplicated sports exploration · Live depth, fee, and size-verified bundle audit · Corrected one-decision-per-event settlement audit · Autonomous runtime 1 · Offline runtime 2 · Maker research 3 · Agent learning 3 · Paper trading only · Live prices from Polymarket's public Gamma and CLOB APIs · Not financial advice ·
|
||||
<a class="market-link" href="https://github.com/theodore-song/polymarket-analyst" target="_blank" rel="noopener">Source on GitHub</a>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -774,7 +774,7 @@ const POLITICS_TREND_MIN_HOLD_HOURS = 72;
|
||||
const EXIT_CONFIRM_HOURS = 6;
|
||||
const AGENTS_KEY = "pma_agents_v2";
|
||||
const SUG_KEY = "pma_suggestions_v5";
|
||||
const BUILD_VERSION = 107;
|
||||
const BUILD_VERSION = 108;
|
||||
const AGENT_LEARNING_VERSION = 3;
|
||||
const SUGGESTION_ENGINE_VERSION = 62;
|
||||
const MAKER_STRATEGY_VERSION = 3;
|
||||
@@ -1261,6 +1261,12 @@ function bundleExecutableLeg(book,units,feeSchedule){
|
||||
const askPrice=cost/Number(units),feePerShare=feeConfigValid?fees/Number(units):SIGNAL_ROUND_TRIP_COST;
|
||||
return {ask_price:askPrice,fee_per_share:feePerShare,total_price:askPrice+feePerShare,fee_config_valid:feeConfigValid};
|
||||
}
|
||||
function bundleMinimumExecutionUnits(unitCost,baselineUnits=0){
|
||||
const cost=Number(unitCost),baseline=Math.max(0,Number(baselineUnits)||0);
|
||||
if(!(cost>0))return +Math.max(BUNDLE_MIN_UNITS,baseline).toFixed(2);
|
||||
const notionalUnits=Math.ceil(((BUNDLE_MIN_NOTIONAL+0.01)/cost)*100)/100;
|
||||
return +Math.max(BUNDLE_MIN_UNITS,baseline,notionalUnits).toFixed(2);
|
||||
}
|
||||
async function fetchBundleBooks(tokenIds){
|
||||
const books=new Map(),unique=[...new Set((tokenIds||[]).map(String).filter(Boolean))];
|
||||
for(let index=0;index<unique.length;index+=BUNDLE_BOOK_BATCH_SIZE){
|
||||
@@ -1291,7 +1297,7 @@ async function verifyExecutableBundles(candidates){
|
||||
const shortlist=(candidates||[]).slice().sort((a,b)=>Number(b.net_edge||-Infinity)-Number(a.net_edge||-Infinity)).slice(0,BUNDLE_DEPTH_CANDIDATE_LIMIT);
|
||||
const tokenIds=shortlist.flatMap(candidate=>(candidate.bundle_legs||[]).map(leg=>leg.token_id));
|
||||
const books=await fetchBundleBooks(tokenIds),depthChecked=shortlist.map(candidate=>{
|
||||
const estimatedCost=Number(candidate.bundle_cost_per_unit),requiredUnits=+(Math.max(BUNDLE_MIN_UNITS,BUNDLE_MIN_NOTIONAL/Math.max(estimatedCost,0.01))).toFixed(2);
|
||||
const estimatedCost=Number(candidate.bundle_cost_per_unit),requiredUnits=bundleMinimumExecutionUnits(Math.max(estimatedCost,0.01));
|
||||
const legs=(candidate.bundle_legs||[]).map(leg=>{
|
||||
const book=books.get(String(leg.token_id||"")),minimum=Number(book&&book.min_order_size||0),units=Math.max(requiredUnits,minimum);
|
||||
const executable=bundleExecutableLeg(book,units,leg.fee_schedule);
|
||||
@@ -1299,15 +1305,28 @@ async function verifyExecutableBundles(candidates){
|
||||
fee_per_share:executable?+executable.fee_per_share.toFixed(6):null,entry_price:executable?+executable.total_price.toFixed(6):null,
|
||||
fee_config_valid:Boolean(executable&&executable.fee_config_valid),depth_verified:Boolean(executable)});
|
||||
});
|
||||
const commonUnits=Math.max(requiredUnits,...legs.map(leg=>Number(leg.required_units||0)));
|
||||
const repricedLegs=legs.map(leg=>{
|
||||
let commonUnits=Math.max(requiredUnits,...legs.map(leg=>Number(leg.required_units||0)));
|
||||
let repricedLegs=legs.map(leg=>{
|
||||
if(Number(leg.required_units)===commonUnits)return leg;
|
||||
const executable=bundleExecutableLeg(books.get(String(leg.token_id||"")),commonUnits,leg.fee_schedule);
|
||||
return Object.assign({},leg,{required_units:+commonUnits.toFixed(2),ask_vwap:executable?+executable.ask_price.toFixed(6):null,
|
||||
fee_per_share:executable?+executable.fee_per_share.toFixed(6):null,entry_price:executable?+executable.total_price.toFixed(6):null,
|
||||
fee_config_valid:Boolean(executable&&executable.fee_config_valid),depth_verified:Boolean(executable)});
|
||||
});
|
||||
const depthVerified=repricedLegs.length>=2&&repricedLegs.every(leg=>leg.depth_verified),cost=depthVerified?repricedLegs.reduce((sum,leg)=>sum+Number(leg.entry_price),0):Infinity;
|
||||
let depthVerified=repricedLegs.length>=2&&repricedLegs.every(leg=>leg.depth_verified);
|
||||
let cost=depthVerified?repricedLegs.reduce((sum,leg)=>sum+Number(leg.entry_price),0):Infinity;
|
||||
const finalUnits=depthVerified?bundleMinimumExecutionUnits(cost,commonUnits):commonUnits;
|
||||
if(finalUnits>commonUnits){
|
||||
commonUnits=finalUnits;
|
||||
repricedLegs=repricedLegs.map(leg=>{
|
||||
const executable=bundleExecutableLeg(books.get(String(leg.token_id||"")),commonUnits,leg.fee_schedule);
|
||||
return Object.assign({},leg,{required_units:+commonUnits.toFixed(2),ask_vwap:executable?+executable.ask_price.toFixed(6):null,
|
||||
fee_per_share:executable?+executable.fee_per_share.toFixed(6):null,entry_price:executable?+executable.total_price.toFixed(6):null,
|
||||
fee_config_valid:Boolean(executable&&executable.fee_config_valid),depth_verified:Boolean(executable)});
|
||||
});
|
||||
depthVerified=repricedLegs.length>=2&&repricedLegs.every(leg=>leg.depth_verified);
|
||||
cost=depthVerified?repricedLegs.reduce((sum,leg)=>sum+Number(leg.entry_price),0):Infinity;
|
||||
}
|
||||
const payout=Number(candidate.bundle_payout_per_unit),profit=payout-cost,netReturn=Number.isFinite(cost)&&cost>0?profit/cost:-Infinity;
|
||||
return Object.assign({},candidate,{bundle_legs:repricedLegs,execution_units:+commonUnits.toFixed(2),execution_notional:Number.isFinite(cost)?+(cost*commonUnits).toFixed(2):null,
|
||||
bundle_cost_per_unit:Number.isFinite(cost)?+cost.toFixed(6):null,bundle_net_profit_per_unit:Number.isFinite(profit)?+profit.toFixed(6):null,
|
||||
@@ -3823,7 +3842,7 @@ function openNegativeRiskBundle(p,cfg,s,stake,decision){
|
||||
peak_price:+current.toFixed(4),gain_stops:{},stop_losses:{}};
|
||||
});
|
||||
const totalCost=+positions.reduce((sum,pos)=>sum+pos.cost,0).toFixed(2);
|
||||
if(totalCost>p.cash||totalCost<50)return null;
|
||||
if(totalCost>p.cash||totalCost<BUNDLE_MIN_NOTIONAL)return null;
|
||||
p.cash=+(p.cash-totalCost).toFixed(2);p.positions.push(...positions);
|
||||
p.history.push({date:logDay(),action:"OPEN",question:s.question,side:bundleSide,
|
||||
detail:`${decision?decision.mode+" mode — ":""}Opened complete ${legs.length}-leg ${bundleSide} bundle for ${fmtUSD(totalCost)} · ${units} bundle units · modeled settlement profit ${fmtUSD(units*Number(s.bundle_net_profit_per_unit))} after estimated costs · live prices required`});
|
||||
@@ -3951,7 +3970,7 @@ function openPositions(p,cfg,rankedSugs,focus,decision,avoidMarketIds,peerStats=
|
||||
if(s.quality==="bundle-arb"){
|
||||
const bundleStake=boundedStakeForRisk(eq,Math.min(eq*Math.min(d.maxFrac,0.04),investable),cfg,s);
|
||||
const bundle=openNegativeRiskBundle(p,cfg,s,bundleStake,decision);
|
||||
if(!bundle)continue;
|
||||
if(!bundle){reject("bundle_execution");continue;}
|
||||
cycleBudgetRemaining=Math.max(0,cycleBudgetRemaining-bundle.cost);
|
||||
opened++;openedIds.push(String(s.bundle_id||s.market_id));
|
||||
continue;
|
||||
@@ -6149,6 +6168,7 @@ window.PMA_ENGINE_DIAGNOSTICS=Object.freeze({
|
||||
peerEvidenceSizeMultiplier,
|
||||
tradeLossBudgetPct,
|
||||
boundedStakeForRisk,
|
||||
bundleMinimumExecutionUnits,
|
||||
sportsFavoritePilotSuggestion,
|
||||
sportsContestKey,
|
||||
sportsContestNoSuggestions,
|
||||
@@ -6844,6 +6864,20 @@ function runEngineSelfTest(){
|
||||
Object.assign({},bundleSuggestion,{depth_verified:false,verification_status:"top-of-book-estimate"}),100,null);
|
||||
const depthCappedBundleBook=defaultPortfolio(),depthCappedBundle=Object.assign({},bundleSuggestion,{execution_units:50});
|
||||
openNegativeRiskBundle(depthCappedBundleBook,AGENTS.find(a=>a.id==="value"),depthCappedBundle,400,null);
|
||||
const repricedBoundaryUnits=bundleMinimumExecutionUnits(0.996041,50.04);
|
||||
const repricedBoundaryCandidate=Object.assign({},dominanceSuggestion,{market_id:"repriced-boundary",bundle_id:"repriced-boundary",
|
||||
bundle_cost_per_unit:0.996041,bundle_net_profit_per_unit:0.003959,execution_units:repricedBoundaryUnits,
|
||||
bundle_legs:[
|
||||
{market_id:"repriced-boundary-a",question:"Boundary A",side:"YES",token_id:"boundary-a",entry_price:0.990693,current_price:0.9895},
|
||||
{market_id:"repriced-boundary-b",question:"Boundary B",side:"NO",token_id:"boundary-b",entry_price:0.005348,current_price:0.006},
|
||||
]});
|
||||
const repricedBoundaryBook=defaultPortfolio();
|
||||
const repricedBoundaryOpen=openNegativeRiskBundle(repricedBoundaryBook,AGENTS.find(a=>a.id==="value"),repricedBoundaryCandidate,400,null);
|
||||
const undersizedBoundaryCandidate=Object.assign({},repricedBoundaryCandidate,{execution_units:50.04});
|
||||
const undersizedBoundaryBook=defaultPortfolio();
|
||||
openPositions(undersizedBoundaryBook,AGENTS.find(a=>a.id==="value"),[undersizedBoundaryCandidate],"All",{
|
||||
minConv:0,maxNew:1,maxFrac:0.04,reserve:0.10,targetExposure:0.60,learning:buildAdaptiveProfile(undersizedBoundaryBook),marketLearning:{samples:0,pending:0,buckets:{}},
|
||||
},new Set(),{});
|
||||
const dominanceBook=defaultPortfolio(),offlineDominanceSuggestion=prepareCycleSuggestions([dominanceSuggestion],"offline-cache",true)[0];
|
||||
openPositions(dominanceBook,AGENTS.find(a=>a.id==="value"),[dominanceSuggestion],"All",{
|
||||
minConv:0,maxNew:1,maxFrac:0.04,reserve:0.10,targetExposure:0.60,learning:buildAdaptiveProfile(dominanceBook),marketLearning:{samples:0,pending:0,buckets:{}},
|
||||
@@ -7292,6 +7326,11 @@ function runEngineSelfTest(){
|
||||
&&zeroFeeBundleSuggestion.bundle_cost_per_unit===0.95&&zeroFeeBundleSuggestion.bundle_net_profit_per_unit===0.05),
|
||||
appliesPublishedFeeCurve:bundleFeePerShare({rate:0.07,exponent:1,takerOnly:true},0.5)===0.0175,
|
||||
depthVwapConsumesMultipleAskLevels:depthVwapFixture===0.396,
|
||||
liveRepricingRoundsUpToMinimumNotional:repricedBoundaryUnits===50.21&&repricedBoundaryUnits*0.996041>=BUNDLE_MIN_NOTIONAL+0.009,
|
||||
repricedMinimumNotionalOpensAtomically:Boolean(repricedBoundaryOpen&&repricedBoundaryBook.positions.length===2
|
||||
&&repricedBoundaryOpen.cost>=BUNDLE_MIN_NOTIONAL),
|
||||
undersizedAtomicFailureIsReported:undersizedBoundaryBook.positions.length===0
|
||||
&&undersizedBoundaryBook.lastDecision.rejectionCounts.bundle_execution===1,
|
||||
blocksUnverifiedBundleEntry:unverifiedBundleOpen===null&&unverifiedBundleBook.positions.length===0&&unverifiedBundleBook.cash===STARTING_BALANCE,
|
||||
capsOpenedUnitsToVerifiedDepth:depthCappedBundleBook.positions.length===3
|
||||
&&depthCappedBundleBook.positions.every(position=>position.shares===50),
|
||||
|
||||
@@ -128,7 +128,7 @@ async function main() {
|
||||
const branch = process.env.RUNTIME_BRANCH || "runtime-state";
|
||||
const pathname = process.env.RUNTIME_STATE_PATH || "runtime/state.json";
|
||||
const arenaUrl = (process.env.ARENA_URL || "https://polymarket-site-eta.vercel.app").replace(/\/$/, "");
|
||||
const expectedBuild = Number(required("EXPECTED_BUILD", "107"));
|
||||
const expectedBuild = Number(required("EXPECTED_BUILD", "108"));
|
||||
await ensureRuntimeBranch(repository, branch);
|
||||
const prior = await readRuntimeFile(repository, branch, pathname);
|
||||
if (prior.snapshot) validateRuntimeSnapshot(prior.snapshot, 0, { allowIncomplete: true });
|
||||
|
||||
@@ -10,7 +10,7 @@ const resolutionAudit = JSON.parse(fs.readFileSync(new URL("../research/resoluti
|
||||
const sportsContestAudit = JSON.parse(fs.readFileSync(new URL("../research/sports-contest-no-exploration-audit.json", import.meta.url), "utf8"));
|
||||
const build = Number(index.match(/const BUILD_VERSION = (\d+);/)?.[1]);
|
||||
|
||||
assert.equal(build, 107);
|
||||
assert.equal(build, 108);
|
||||
assert.deepEqual([...ALLOWED_RUNTIME_KEYS].sort(), ["pma_agents_v2", "pma_suggestions_v5"]);
|
||||
assert.match(index, /function collectPublicRuntimeItems\(\)/);
|
||||
assert.match(index, /const PUBLIC_RUNTIME_KEYS=Object\.freeze\(\[AGENTS_KEY,SUG_KEY\]\)/);
|
||||
@@ -27,7 +27,7 @@ assert.match(api, /Buffer\.from\(file\.content/);
|
||||
assert.match(api, /searchParams\.set\("runtime", `\$\{Date\.now\(\)\}/);
|
||||
assert.match(workflow, /cron: "2,7,12,17,22,27,32,37,42,47,52,57 \* \* \* \*"/);
|
||||
assert.match(workflow, /contents: write/);
|
||||
assert.match(workflow, /EXPECTED_BUILD: "107"/);
|
||||
assert.match(workflow, /EXPECTED_BUILD: "108"/);
|
||||
assert.match(index, /saveSuggestions\(sugs,markets\.length,analysisMarkets\.length,bundleAudit\)/);
|
||||
assert.match(index, /const NEG_RISK_EVENT_SCAN_LIMIT=1000;/);
|
||||
assert.match(index, /bundleOpportunityTelemetry:true/);
|
||||
|
||||
Reference in New Issue
Block a user