Quantify excluded learning outcomes

This commit is contained in:
Theodore Song
2026-08-22 08:48:04 -04:00
parent 605a5f2ae4
commit d32ce0de42
+9 -3
View File
@@ -2850,6 +2850,8 @@ function buildAdaptiveProfile(p){
}; };
const closedRows=(p.closed||[]).filter(t=>normalizedStrategyVersion(t.strategy_version)>=34); const closedRows=(p.closed||[]).filter(t=>normalizedStrategyVersion(t.strategy_version)>=34);
const eligibleClosed=closedRows.filter(t=>!generalAdaptiveLearningExclusion(t)); const eligibleClosed=closedRows.filter(t=>!generalAdaptiveLearningExclusion(t));
const excludedClosed=closedRows.filter(t=>generalAdaptiveLearningExclusion(t));
const exclusionReasons=excludedClosed.reduce((counts,trade)=>{const reason=generalAdaptiveLearningExclusion(trade);counts[reason]=(counts[reason]||0)+1;return counts;},{});
eligibleClosed.forEach(t=>add(t,true)); eligibleClosed.forEach(t=>add(t,true));
(p.positions||[]).filter(t=>daysHeld(t)>=1&&!generalAdaptiveLearningExclusion(t)).forEach(t=>add(t,false)); (p.positions||[]).filter(t=>daysHeld(t)>=1&&!generalAdaptiveLearningExclusion(t)).forEach(t=>add(t,false));
const learned=Object.fromEntries(Object.entries(buckets).map(([k,b])=>[k,summarizeLearningBucket(b,6)])); const learned=Object.fromEntries(Object.entries(buckets).map(([k,b])=>[k,summarizeLearningBucket(b,6)]));
@@ -2860,7 +2862,9 @@ function buildAdaptiveProfile(p){
const currentClosedSum=currentClosedObservations.reduce((s,x)=>s+x.ret*x.weight,0); const currentClosedSum=currentClosedObservations.reduce((s,x)=>s+x.ret*x.weight,0);
const ranked=Object.entries(learned).filter(([k,v])=>!k.startsWith("side:")&&v.weight>=1) const ranked=Object.entries(learned).filter(([k,v])=>!k.startsWith("side:")&&v.weight>=1)
.sort((a,b)=>b[1].score-a[1].score); .sort((a,b)=>b[1].score-a[1].score);
return {version:SUGGESTION_ENGINE_VERSION,samples:eligibleClosed.length,excluded_samples:closedRows.length-eligibleClosed.length, return {version:SUGGESTION_ENGINE_VERSION,samples:eligibleClosed.length,excluded_samples:excludedClosed.length,
directional_realized_pnl:+eligibleClosed.reduce((sum,trade)=>sum+Number(trade.realized_pnl||0),0).toFixed(2),
excluded_realized_pnl:+excludedClosed.reduce((sum,trade)=>sum+Number(trade.realized_pnl||0),0).toFixed(2),exclusion_reasons:exclusionReasons,
effective_samples:+totalWeight.toFixed(2),global_score:+globalScore.toFixed(4),buckets:learned,current_buckets:currentLearned, effective_samples:+totalWeight.toFixed(2),global_score:+globalScore.toFixed(4),buckets:learned,current_buckets:currentLearned,
current_samples:currentClosedReturns.length,current_effective_samples:+currentClosedWeight.toFixed(2), current_samples:currentClosedReturns.length,current_effective_samples:+currentClosedWeight.toFixed(2),
current_global_score:+(currentClosedSum/(currentClosedWeight+4)).toFixed(4), current_global_score:+(currentClosedSum/(currentClosedWeight+4)).toFixed(4),
@@ -4951,7 +4955,7 @@ function decisionSummary(p){
const blockerLabels={historical_prior:"history-tested losing setup",learning:"live learned losing regime",pilot_learning:"sports pilot demoted",shock_learning:"shock pilot unpromoted",resolution_week_learning:"resolution-week pilot demoted",event_overlap:"same event",confidence:"confidence",overlap:"material overlap",already_held:"already held",cooldown:"stop cooldown",focus:"category focus",price:"entry price",edge:"edge",timing:"timing",liquidity:"liquidity",activity:"activity",evidence:"evidence",direction:"direction",portfolio_limit:"portfolio limit"}; const blockerLabels={historical_prior:"history-tested losing setup",learning:"live learned losing regime",pilot_learning:"sports pilot demoted",shock_learning:"shock pilot unpromoted",resolution_week_learning:"resolution-week pilot demoted",event_overlap:"same event",confidence:"confidence",overlap:"material overlap",already_held:"already held",cooldown:"stop cooldown",focus:"category focus",price:"entry price",edge:"edge",timing:"timing",liquidity:"liquidity",activity:"activity",evidence:"evidence",direction:"direction",portfolio_limit:"portfolio limit"};
const blockerRows=Object.entries(d.rejectionCounts||{}).filter(([,count])=>count>0).sort((a,b)=>b[1]-a[1]); const blockerRows=Object.entries(d.rejectionCounts||{}).filter(([,count])=>count>0).sort((a,b)=>b[1]-a[1]);
const blockers=blockerRows.length?` Blocks: ${blockerRows.slice(0,4).map(([key,count])=>`${blockerLabels[key]||key} ${count}`).join(", ")}.`:""; const blockers=blockerRows.length?` Blocks: ${blockerRows.slice(0,4).map(([key,count])=>`${blockerLabels[key]||key} ${count}`).join(", ")}.`:"";
const learning=d.learning?` Learning: ${d.learning.samples} eligible directional trades retained as historical context${d.learning.excluded_samples?`; ${d.learning.excluded_samples} bundle, maker, specialized-pilot, or settlement-unsafe trade${d.learning.excluded_samples===1?" was":"s were"} excluded and remains in the visible P&L ledger`:""}, ${(d.learning.global_score*100).toFixed(2)}% all-version shrunk expectancy; ${d.learning.current_samples||0} completed under adaptive strategy ${SUGGESTION_ENGINE_VERSION} with ${((d.learning.current_global_score||0)*100).toFixed(2)}% current-strategy shrunk expectancy. Only eligible current-strategy directional trades can change sizing or personal cohort promotion${d.learning.best?`; historical strongest ${d.learning.best.feature.replace(":"," ")}`:""}${d.learning.worst?`; historical weakest ${d.learning.worst.feature.replace(":"," ")}`:""}.`:""; const learning=d.learning?` Learning: ${d.learning.samples} eligible directional trades produced ${fmtUSD(d.learning.directional_realized_pnl||0)} realized P&L and remain as historical context${d.learning.excluded_samples?`; ${d.learning.excluded_samples} separately evaluated trade${d.learning.excluded_samples===1?" was":"s were"} excluded from directional learning (${Object.entries(d.learning.exclusion_reasons||{}).map(([reason,count])=>`${reason} ${count}`).join(", ")||"specialized or unsafe"}), representing ${fmtUSD(d.learning.excluded_realized_pnl||0)} that remains in the visible account P&L`:""}. Directional all-version shrunk expectancy is ${(d.learning.global_score*100).toFixed(2)}%; ${d.learning.current_samples||0} completed under adaptive strategy ${SUGGESTION_ENGINE_VERSION} with ${((d.learning.current_global_score||0)*100).toFixed(2)}% current-strategy shrunk expectancy. Only eligible current-strategy directional trades can change sizing or personal cohort promotion${d.learning.best?`; historical strongest ${d.learning.best.feature.replace(":"," ")}`:""}${d.learning.worst?`; historical weakest ${d.learning.worst.feature.replace(":"," ")}`:""}.`:"";
let calibration=""; let calibration="";
if(d.marketLearning){ if(d.marketLearning){
const ml=d.marketLearning,hasCounts=Number.isFinite(ml.events)&&Number.isFinite(ml.markets),hasCurrentCounts=Number.isFinite(ml.current_events); const ml=d.marketLearning,hasCounts=Number.isFinite(ml.events)&&Number.isFinite(ml.markets),hasCurrentCounts=Number.isFinite(ml.current_events);
@@ -7564,7 +7568,9 @@ function runEngineSelfTest(){
currentCapitalLearningSurvivesOfflineCompaction:offlineCurrentProfile.current_samples===currentPositiveProfile.current_samples currentCapitalLearningSurvivesOfflineCompaction:offlineCurrentProfile.current_samples===currentPositiveProfile.current_samples
&&offlineCurrentProfile.current_buckets["signal:catalyst"].score===currentPositiveProfile.current_buckets["signal:catalyst"].score, &&offlineCurrentProfile.current_buckets["signal:catalyst"].score===currentPositiveProfile.current_buckets["signal:catalyst"].score,
specializedUnsafeTradesCannotBiasDirectionalLearning:isolatedLearningProfile.samples===1&&isolatedLearningProfile.excluded_samples===1 specializedUnsafeTradesCannotBiasDirectionalLearning:isolatedLearningProfile.samples===1&&isolatedLearningProfile.excluded_samples===1
&&isolatedLearningProfile.current_samples===1&&isolatedLearningProfile.global_score<0.01, &&isolatedLearningProfile.current_samples===1&&isolatedLearningProfile.global_score<0.01
&&isolatedLearningProfile.directional_realized_pnl===10&&isolatedLearningProfile.excluded_realized_pnl===328.4
&&isolatedLearningProfile.exclusion_reasons["specialized-learner"]===1,
legacyTradesCannotIncreaseCurrentSizing:legacyPositiveDecision.maxFrac===0.045, legacyTradesCannotIncreaseCurrentSizing:legacyPositiveDecision.maxFrac===0.045,
currentProfitsCanIncreaseBoundedSizing:currentPositiveDecision.maxFrac>legacyPositiveDecision.maxFrac currentProfitsCanIncreaseBoundedSizing:currentPositiveDecision.maxFrac>legacyPositiveDecision.maxFrac
&&currentPositiveDecision.maxFrac<=0.06, &&currentPositiveDecision.maxFrac<=0.06,