diff --git a/index.html b/index.html index 8a1abf5..fda3a54 100644 --- a/index.html +++ b/index.html @@ -730,7 +730,8 @@ const GAIN_STOP_TIERS = [ const EXIT_STALE_DAYS = 14; const EXIT_RESOLUTION_DAYS = 2; const AGENTS_KEY = "pma_agents_v2"; -const SUG_KEY = "pma_suggestions_v2"; +const SUG_KEY = "pma_suggestions_v3"; +const SUGGESTION_ENGINE_VERSION = 4; const FOCUS_KEY = "pma_focus_v1"; const VIEW_KEY = "pma_view_v1"; const PF_SORT_KEY = "pma_portfolio_sort_v1"; @@ -844,11 +845,11 @@ function partsInLocalTime(d=new Date()){ } const todayStr = () => {const p=partsInLocalTime();return `${p.year}-${p.month}-${p.day}`;}; const RUN_INTERVAL_MS = 60000; -const currentCycleHour = () => {const p=partsInLocalTime();return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}`;}; +const currentCycleHour = () => {const p=partsInLocalTime();return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}|v${SUGGESTION_ENGINE_VERSION}`;}; function cycleHourFromIso(iso){ const d=new Date(iso); if(isNaN(d))return null; - const p=partsInLocalTime(d);return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}`; + const p=partsInLocalTime(d);return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}|v${SUGGESTION_ENGINE_VERSION}`; } const nowIso = () => new Date().toISOString(); const cycleIso = () => SIM_DAY ? new Date(SIM_DAY+"T12:00:00Z").toISOString() : nowIso(); @@ -990,7 +991,7 @@ function loadState(){ } function saveState(st){localStorage.setItem(AGENTS_KEY,JSON.stringify(st));} function loadSuggestions(){try{const s=localStorage.getItem(SUG_KEY);return s?JSON.parse(s):{date:null,suggestions:[]};}catch(e){return {date:null,suggestions:[]};}} -function saveSuggestions(sugs){const p={date:todayStr(),generated_at:nowIso(),suggestions:sugs};localStorage.setItem(SUG_KEY,JSON.stringify(p));return p;} +function saveSuggestions(sugs,marketCount=0){const p={date:todayStr(),generated_at:nowIso(),engine_version:SUGGESTION_ENGINE_VERSION,market_count:marketCount,suggestion_cap:SUGGESTION_TOTAL,suggestions:sugs};localStorage.setItem(SUG_KEY,JSON.stringify(p));return p;} function collectSyncItems(){const items={};SYNC_KEYS.forEach(k=>{const v=localStorage.getItem(k);if(v!=null)items[k]=v;});return items;} function applySyncItems(items){if(!items||typeof items!=="object")return false;SYNC_KEYS.forEach(k=>{if(items[k]!=null)localStorage.setItem(k,items[k]);});return true;} function stateFromSyncItems(items){ @@ -1574,7 +1575,7 @@ async function backtestWeek(st){ const leaderId=copyPick?copyPick.id:AGENTS.filter(a=>a.kind==="strategy")[0].id; st.copycatLeader=leaderId; runCopycat(st.agents.copycat,st.agents[leaderId],priceMap,copyPick); - if(day===dates[dates.length-1])saveSuggestions(sugs); // latest live-ish board for the Suggestions tab + if(day===dates[dates.length-1])saveSuggestions(sugs,markets.length); // latest live-ish board for the Suggestions tab } SIM_DAY=null; await backtestWhales(st,dates); @@ -1600,7 +1601,7 @@ async function runDailyCycle(){ const markets=await fetchMarkets(Infinity,100,count=>setStatus(`fetching all active markets (${count})…`,true)); setStatus("analyzing…",true); const sugs=generateSuggestions(markets); - saveSuggestions(sugs); + saveSuggestions(sugs,markets.length); st=loadState(); const focus=getFocus(); // Price map for suggestion-market positions (strategy + copycat only). @@ -1672,7 +1673,7 @@ function renderOverview(){ {ic:lead.c.emoji,label:"Leader",value:lead.c.name.split(" ")[0]}, {ic:"📈",label:"Leader return",value:fmtPct(lead.ret),cls:signClass(lead.pnl)}, {ic:"⚖️",label:"Avg return",value:fmtPct(avgRet),cls:signClass(avgRet)}, - {ic:"💡",label:"Ideas this hour",value:sugCount}, + {ic:"💡",label:"Scored ideas",value:sugCount}, {ic:"🏆",label:"Agents",value:AGENTS.length}, ]; $("stats").innerHTML=stats.map(s=>`