Hold complete bundles at cost until settlement

This commit is contained in:
Theodore Song
2026-08-21 22:20:47 -04:00
parent 3152096057
commit 546f174276
6 changed files with 31 additions and 29 deletions
+21 -19
View File
@@ -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 109</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 110</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 109 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. Intact guaranteed bundles are conservatively marked at no less than their cost basis, while modeled profit remains unbooked until settlement. 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 110 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. Intact guaranteed bundles are conservatively held at cost in portfolio accounting, while modeled profit remains unbooked until settlement. 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 109 · Adaptive strategy 62 · Five-minute autonomous scans · Exact-fee directional learning · Conservative intact-bundle accounting · 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 110 · Adaptive strategy 62 · Five-minute autonomous scans · Exact-fee directional learning · Conservative intact-bundle accounting · 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 = 109;
const BUILD_VERSION = 110;
const AGENT_LEARNING_VERSION = 3;
const SUGGESTION_ENGINE_VERSION = 62;
const MAKER_STRATEGY_VERSION = 3;
@@ -2271,26 +2271,19 @@ function portfolioPositionValue(p){
let total=positions.reduce((sum,pos)=>sum+Number(pos.shares||0)*Number(pos.current_price||0),0);
completeBundleGroups(p).forEach(group=>{
const raw=group.reduce((sum,pos)=>sum+Number(pos.shares||0)*Number(pos.current_price||0),0);
total+=Math.max(0,completeBundleAccountingFloor(group)-raw);
const lockedValue=completeBundleAccountingFloor(group);
if(lockedValue>0)total+=lockedValue-raw;
});
return total;
}
function applyCompleteBundleAccountingMarks(p){
completeBundleGroups(p).forEach(group=>{
const raw=group.reduce((sum,pos)=>sum+Number(pos.shares||0)*Number(pos.current_price||0),0);
const floor=completeBundleAccountingFloor(group),adjustment=Math.max(0,floor-raw);
const cost=group.reduce((sum,pos)=>sum+Number(pos.cost||0),0);
let distributed=0;
group.forEach((pos,index)=>{
const lockedValue=completeBundleAccountingFloor(group);
if(!(lockedValue>0))return;
group.forEach(pos=>{
const rawValue=Number(pos.shares||0)*Number(pos.current_price||0);
const weight=cost>0?Number(pos.cost||0)/cost:1/group.length;
const allocated=index===group.length-1
? adjustment-distributed
: Number((adjustment*weight).toFixed(2));
distributed+=allocated;
pos.raw_value=+rawValue.toFixed(2);pos.bundle_mark_adjustment=+allocated.toFixed(2);
pos.value=+(pos.raw_value+pos.bundle_mark_adjustment).toFixed(2);
pos.unrealized_pnl=+(pos.value-Number(pos.cost||0)).toFixed(2);
pos.raw_value=+rawValue.toFixed(2);pos.bundle_mark_adjustment=+(Number(pos.cost||0)-pos.raw_value).toFixed(2);
pos.value=+Number(pos.cost||0).toFixed(2);pos.unrealized_pnl=0;
});
});
}
@@ -6933,6 +6926,13 @@ function runEngineSelfTest(){
applyCompleteBundleAccountingMarks(conservativeBundleMarkBook);
const conservativeBundleAccountedValue=conservativeBundleMarkBook.positions.reduce((sum,pos)=>sum+Number(pos.value),0);
const conservativeBundleCost=conservativeBundleMarkBook.positions.reduce((sum,pos)=>sum+Number(pos.cost),0);
const optimisticBundleMarkBook=JSON.parse(JSON.stringify(repricedBoundaryBook));
optimisticBundleMarkBook.positions.forEach(pos=>{
pos.current_price=+(Number(pos.current_price)*1.25).toFixed(6);
pos.value=+(Number(pos.shares)*Number(pos.current_price)).toFixed(2);
pos.unrealized_pnl=+(pos.value-Number(pos.cost)).toFixed(2);
});
applyCompleteBundleAccountingMarks(optimisticBundleMarkBook);
const undersizedBoundaryCandidate=Object.assign({},repricedBoundaryCandidate,{execution_units:50.04});
const undersizedBoundaryBook=defaultPortfolio();
openPositions(undersizedBoundaryBook,AGENTS.find(a=>a.id==="value"),[undersizedBoundaryCandidate],"All",{
@@ -7392,7 +7392,9 @@ function runEngineSelfTest(){
intactBundleDoesNotShowArtificialLoss:conservativeBundleRawValue<conservativeBundleCost
&&Math.abs(conservativeBundleAccountedValue-conservativeBundleCost)<=0.01
&&Math.abs(equity(conservativeBundleMarkBook)-STARTING_BALANCE)<=0.01,
modeledSettlementProfitIsNotBookedEarly:Math.abs(equity(conservativeBundleMarkBook)-STARTING_BALANCE)<=0.01,
modeledSettlementProfitIsNotBookedEarly:Math.abs(equity(conservativeBundleMarkBook)-STARTING_BALANCE)<=0.01
&&Math.abs(equity(optimisticBundleMarkBook)-STARTING_BALANCE)<=0.01
&&optimisticBundleMarkBook.positions.every(pos=>pos.unrealized_pnl===0),
undersizedAtomicFailureIsReported:undersizedBoundaryBook.positions.length===0
&&undersizedBoundaryBook.lastDecision.rejectionCounts.bundle_execution===1,
blocksUnverifiedBundleEntry:unverifiedBundleOpen===null&&unverifiedBundleBook.positions.length===0&&unverifiedBundleBook.cash===STARTING_BALANCE,