| <!DOCTYPE html> |
| <html lang="zh-TW"> |
| <head> |
| <meta charset="UTF-8"> |
| <title>大仁哥曝險與資產動態平衡計算機(萬元版)</title> |
| <style> |
| html,body,div,input,select,button,p,h1,h2,h3,span,label,strong,ol,li{box-sizing:border-box;font-family:"Microsoft JhengHei",sans-serif;margin:0;padding:0;} |
| body{background-color:rgb(245,247,250);padding:24px;display:flex;justify-content:center;} |
| .app-container{background-color:rgb(255,255,255);padding:32px;border-radius:14px;box-shadow:0 6px 16px rgba(0,0,0,0.08);max-width:960px;width:100%;display:flex;flex-wrap:wrap;gap:32px;} |
| .input-col,.output-col{flex:1;min-width:320px;} |
| .section-title{color:rgb(33,37,41);font-size:20px;font-weight:bold;border-bottom:2px solid rgb(226,232,240);padding-bottom:12px;margin-bottom:20px;} |
| .field-group{margin-bottom:16px;} |
| .field-group label{display:block;margin-bottom:6px;color:rgb(73,80,87);font-weight:bold;font-size:15px;} |
| .field-group input{width:100%;padding:12px;border:1px solid rgb(206,212,218);border-radius:8px;font-size:16px;outline:none;transition:border-color 0.2s;} |
| .field-group input:focus{border-color:rgb(13,110,253);} |
| .metric-card{background-color:rgb(248,249,250);padding:18px;border-radius:10px;margin-bottom:18px;border:1px solid rgb(233,236,239);} |
| .metric-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;font-size:16px;} |
| .metric-row.accent{color:rgb(220,53,69);font-weight:bold;font-size:20px;} |
| .meter-bg{background-color:rgb(226,232,240);border-radius:8px;height:18px;width:100%;overflow:hidden;margin-top:8px;} |
| .meter-fill{height:100%;background-color:rgb(40,167,69);transition:width 0.3s,background-color 0.3s;} |
| .split-bar{display:flex;height:18px;border-radius:8px;overflow:hidden;margin-top:8px;} |
| .bar-lev{background-color:rgb(220,53,69);} |
| .bar-pro{background-color:rgb(255,193,7);} |
| .bar-cash{background-color:rgb(40,167,69);} |
| .legend-group{display:flex;gap:14px;font-size:13px;margin-top:8px;color:rgb(108,117,125);} |
| .legend-point{display:flex;align-items:center;gap:5px;} |
| .badge-dot{width:10px;height:10px;border-radius:50%;} |
| .advice-panel{display:flex;flex-direction:column;gap:14px;} |
| .plan-card{background-color:rgb(241,248,255);border:1px solid rgb(184,218,255);border-left:5px solid rgb(13,110,253);padding:16px;border-radius:8px;color:rgb(10,54,115);} |
| .plan-card.neutral{background-color:rgb(248,249,250);border:1px solid rgb(222,226,230);border-left:5px solid rgb(108,117,125);color:rgb(73,80,87);} |
| .plan-card.warn{background-color:rgb(255,243,205);border:1px solid rgb(255,238,186);border-left:5px solid rgb(255,193,7);color:rgb(133,100,4);} |
| .plan-header{font-weight:bold;font-size:16px;margin-bottom:8px;} |
| .plan-desc{font-size:14px;line-height:1.6;margin-bottom:10px;} |
| .action-steps{padding-left:20px;font-size:14px;line-height:1.7;margin-bottom:10px;} |
| .balance-preview{background-color:rgba(255,255,255,0.7);border-radius:6px;padding:8px 12px;font-size:13px;display:flex;flex-wrap:wrap;gap:12px;border:1px dashed rgb(184,218,255);} |
| </style> |
| </head> |
| <body> |
| <div class="app-container"> |
| <div class="input-col"> |
| <div class="section-title">第一步:現有資產額度(萬元)</div> |
| <div class="field-group"> |
| <label>槓桿ETF(正2)市值(萬元)</label> |
| <input type="number" step="any" class="val-lev" placeholder="例如:30 (代表30萬元)" oninput="runCalculations()"> |
| </div> |
| <div class="field-group"> |
| <label>原型0050市值(萬元)</label> |
| <input type="number" step="any" class="val-pro" placeholder="例如:40 (代表40萬元)" oninput="runCalculations()"> |
| </div> |
| <div class="field-group"> |
| <label>現金儲備額度(萬元)</label> |
| <input type="number" step="any" class="val-cash" placeholder="例如:30 (代表30萬元)" oninput="runCalculations()"> |
| </div> |
| <div class="section-title">第二步:目標曝險設定</div> |
| <div class="field-group"> |
| <label>期望總曝險比例(%)</label> |
| <input type="number" step="any" class="val-target" placeholder="例如:100 或 120" oninput="runCalculations()"> |
| </div> |
| </div> |
| <div class="output-col"> |
| <div class="section-title">現況曝險與資產結構</div> |
| <div class="metric-card"> |
| <div class="metric-row"> |
| <span>可投資總資產:</span> |
| <span class="txt-assets">0 萬元</span> |
| </div> |
| <div class="metric-row"> |
| <span>當前總曝險金額:</span> |
| <span class="txt-exposure">0 萬元</span> |
| </div> |
| <div class="metric-row accent"> |
| <span>實際總曝險比:</span> |
| <span class="txt-exp-pct">0%</span> |
| </div> |
| <div class="meter-bg"> |
| <div class="meter-fill" style="width:0%;"></div> |
| </div> |
| </div> |
| <div class="metric-card"> |
| <div class="metric-row"> |
| <span>資金配置佔比(正2:原型:現金):</span> |
| <span class="txt-ratio">0:0:0</span> |
| </div> |
| <div class="split-bar"> |
| <div class="bar-lev" style="width:0%;"></div> |
| <div class="bar-pro" style="width:0%;"></div> |
| <div class="bar-cash" style="width:0%;"></div> |
| </div> |
| <div class="legend-group"> |
| <div class="legend-point"><div class="badge-dot bar-lev"></div>正2部位</div> |
| <div class="legend-point"><div class="badge-dot bar-pro"></div>原型部位</div> |
| <div class="legend-point"><div class="badge-dot bar-cash"></div>現金部位</div> |
| </div> |
| </div> |
| <div class="section-title">大仁哥既有部位調整策略</div> |
| <div class="advice-panel"> |
| <div class="plan-card neutral">請於左側輸入各項額度與期望目標曝險比例以取得分析。</div> |
| </div> |
| </div> |
| </div> |
| <script> |
| function fmt(val){ |
| const rounded=Math.round(val*100)/100; |
| return rounded.toLocaleString(undefined,{minimumFractionDigits:0,maximumFractionDigits:2})+' 萬元'; |
| } |
| function runCalculations(){ |
| const levVal=parseFloat(document.querySelector('.val-lev').value)||0; |
| const proVal=parseFloat(document.querySelector('.val-pro').value)||0; |
| const cashVal=parseFloat(document.querySelector('.val-cash').value)||0; |
| const targetPct=parseFloat(document.querySelector('.val-target').value)||0; |
| const total=levVal+proVal+cashVal; |
| const txtAssets=document.querySelector('.txt-assets'); |
| const txtExp=document.querySelector('.txt-exposure'); |
| const txtExpPct=document.querySelector('.txt-exp-pct'); |
| const meterFill=document.querySelector('.meter-fill'); |
| const txtRatio=document.querySelector('.txt-ratio'); |
| const barLev=document.querySelector('.bar-lev'); |
| const barPro=document.querySelector('.bar-pro'); |
| const barCash=document.querySelector('.bar-cash'); |
| const adviceBox=document.querySelector('.advice-panel'); |
| if(total===0){ |
| txtAssets.textContent='0 萬元'; |
| txtExp.textContent='0 萬元'; |
| txtExpPct.textContent='0%'; |
| meterFill.style.width='0%'; |
| txtRatio.textContent='0:0:0'; |
| barLev.style.width='0%'; |
| barPro.style.width='0%'; |
| barCash.style.width='0%'; |
| adviceBox.innerHTML='<div class="plan-card neutral">請於左側輸入各項額度與期望目標曝險比例以取得分析。</div>'; |
| return; |
| } |
| const currentExposure=levVal*2+proVal; |
| const currentPct=(currentExposure/total)*100; |
| txtAssets.textContent=fmt(total); |
| txtExp.textContent=fmt(currentExposure); |
| txtExpPct.textContent=currentPct.toFixed(2)+'%'; |
| let fillWidth=currentPct; |
| if(fillWidth>100)fillWidth=100; |
| meterFill.style.width=fillWidth+'%'; |
| if(currentPct<=100){ |
| meterFill.style.backgroundColor='rgb(40,167,69)'; |
| }else if(currentPct<=150){ |
| meterFill.style.backgroundColor='rgb(255,193,7)'; |
| }else{ |
| meterFill.style.backgroundColor='rgb(220,53,69)'; |
| } |
| let rLev=(levVal/total)*100; |
| let rPro=(proVal/total)*100; |
| let rCash=(cashVal/total)*100; |
| let floorLev=Math.floor(rLev); |
| let floorPro=Math.floor(rPro); |
| let floorCash=Math.floor(rCash); |
| let rem=100-(floorLev+floorPro+floorCash); |
| let fractions=[ |
| {k:'lev',v:rLev-floorLev}, |
| {k:'pro',v:rPro-floorPro}, |
| {k:'cash',v:rCash-floorCash} |
| ]; |
| fractions.sort(function(a,b){return b.v-a.v;}); |
| for(let i=0;i<rem;i++){ |
| if(fractions[i].k==='lev')floorLev++; |
| else if(fractions[i].k==='pro')floorPro++; |
| else if(fractions[i].k==='cash')floorCash++; |
| } |
| txtRatio.textContent=floorLev+':'+floorPro+':'+floorCash; |
| barLev.style.width=floorLev+'%'; |
| barPro.style.width=floorPro+'%'; |
| barCash.style.width=floorCash+'%'; |
| if(targetPct<=0){ |
| adviceBox.innerHTML='<div class="plan-card neutral">請於左側設定大於0的期望總曝險比例(%)。</div>'; |
| return; |
| } |
| if(targetPct>200){ |
| adviceBox.innerHTML='<div class="plan-card warn"><div class="plan-header">超出工具內建極限(200%)</div><div class="plan-desc">在不進行額外融資借貸的前提下,即便將100%資產全數押入槓桿ETF(正2),最大極限曝險即為200%。若欲追求超過200%的曝險,需引進期貨或信貸等外部工具。</div></div>'; |
| return; |
| } |
| const targetExposureAmount=total*(targetPct/100); |
| const diffExp=targetExposureAmount-currentExposure; |
| if(Math.abs(diffExp)<0.01){ |
| adviceBox.innerHTML='<div class="plan-card" style="border-left-color:rgb(40,167,69);"><div class="plan-header">目前配置已精準達標</div><div class="plan-desc">當前總曝險為 '+fmt(currentExposure)+' ('+currentPct.toFixed(1)+'%),已吻合目標曝險,維持既有紀律即可。</div></div>'; |
| return; |
| } |
| let cardsHtml=''; |
| if(diffExp>0){ |
| if(proVal>=diffExp){ |
| const swapVal=diffExp; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略一:大仁哥零現金置換法(推薦)</div><div class="plan-desc">核心思維:<strong>「以正2換取原型,釋放資金效率」</strong>。將原型0050賣出轉入正2,每轉1萬元即可提升1萬元曝險,<strong>完全不消耗任何防禦現金</strong>:</div><ol class="action-steps"><li>賣出原型0050額度:'+fmt(swapVal)+'</li><li>將取得資金全數買入槓桿正2:'+fmt(swapVal)+'</li><li>現金部位完全不動:保留 '+fmt(cashVal)+' 作為心理與生活安全防護</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(levVal+swapVal)+'</span><span>調整後0050:'+fmt(proVal-swapVal)+'</span><span>調整後現金:'+fmt(cashVal)+'</span></div></div>'; |
| }else{ |
| const swapAllPro=proVal; |
| const remainExp=diffExp-swapAllPro; |
| const cashBuyLev=remainExp/2; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略一:既有資產梯次補足法</div><div class="plan-desc">現有原型0050全數換為正2後仍有曝險缺口,由既有現金補足:</div><ol class="action-steps"><li>賣出全部原型0050:'+fmt(swapAllPro)+',轉買槓桿正2</li><li>動用現金儲備額度:'+fmt(cashBuyLev)+',買入槓桿正2</li><li>調整後剩餘現金:'+fmt(cashVal-cashBuyLev)+'</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(levVal+swapAllPro+cashBuyLev)+'</span><span>調整後0050:0 萬元</span><span>調整後現金:'+fmt(cashVal-cashBuyLev)+'</span></div></div>'; |
| } |
| const pureLevTarget=total*(targetPct/200); |
| const pureCashTarget=total-pureLevTarget; |
| const levGap=pureLevTarget-levVal; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略二:大仁哥50/50極簡純化架構</div><div class="plan-desc">大仁哥旗艦理念:<strong>「持有一倍槓桿時,原型ETF屬於低效冗餘資產」</strong>。出清原型0050,專注維持正2與強大現金護城河:</div><ol class="action-steps"><li>出清全部原型0050:賣出 '+fmt(proVal)+' 變現</li><li>槓桿正2調整至目標額度:'+(levGap>=0?'買入 '+fmt(levGap):'賣出 '+fmt(Math.abs(levGap)))+' (持倉目標為 '+fmt(pureLevTarget)+')</li><li>剩餘額度全數留存為現金儲備:持倉目標為 '+fmt(pureCashTarget)+'</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(pureLevTarget)+'</span><span>調整後0050:0 萬元</span><span>調整後現金:'+fmt(pureCashTarget)+'</span></div></div>'; |
| }else{ |
| const dropExp=Math.abs(diffExp); |
| if(levVal>=(dropExp/2)){ |
| const sellLev=dropExp/2; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略一:正2獲利調節・壯大現金護城河(推薦)</div><div class="plan-desc">核心思維:<strong>「股市大漲後適度賣出槓桿,鎖定利潤轉化為現金儲備」</strong>:</div><ol class="action-steps"><li>賣出槓桿正2額度:'+fmt(sellLev)+' 轉為現金</li><li>原型0050額度不動:維持 '+fmt(proVal)+'</li><li>實體現金池增長:從 '+fmt(cashVal)+' 提升至 '+fmt(cashVal+sellLev)+' (擴大未來回檔加碼餘裕)</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(levVal-sellLev)+'</span><span>調整後0050:'+fmt(proVal)+'</span><span>調整後現金:'+fmt(cashVal+sellLev)+'</span></div></div>'; |
| }else{ |
| const sellAllLev=levVal; |
| const remainDrop=dropExp-(levVal*2); |
| const sellPro=remainDrop; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略一:雙向降槓桿獲利變現法</div><div class="plan-desc">欲調降之曝險幅度較大,需同步減碼正2與原型以收回充裕現金:</div><ol class="action-steps"><li>賣出全部槓桿正2:'+fmt(sellAllLev)+' 轉為現金</li><li>賣出原型0050額度:'+fmt(sellPro)+' 轉為現金</li><li>保留原型0050部位:'+fmt(proVal-sellPro)+'</li></ol><div class="balance-preview"><span>調整後正2:0 萬元</span><span>調整後0050:'+fmt(proVal-sellPro)+'</span><span>調整後現金:'+fmt(cashVal+sellAllLev+sellPro)+'</span></div></div>'; |
| } |
| if(levVal>=dropExp){ |
| const swapLevToPro=dropExp; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略二:降槓桿不降股票・正2轉原型法</div><div class="plan-desc">若欲平抑波動風險,但不想增加手上閒置現金,可將正2轉為原型0050(每轉1萬元降低1萬元曝險):</div><ol class="action-steps"><li>賣出槓桿正2額度:'+fmt(swapLevToPro)+'</li><li>全數轉買入原型0050:'+fmt(swapLevToPro)+'</li><li>現金儲備維持不動:'+fmt(cashVal)+'</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(levVal-swapLevToPro)+'</span><span>調整後0050:'+fmt(proVal+swapLevToPro)+'</span><span>調整後現金:'+fmt(cashVal)+'</span></div></div>'; |
| }else{ |
| const pureLevTarget=total*(targetPct/200); |
| const pureCashTarget=total-pureLevTarget; |
| cardsHtml+='<div class="plan-card"><div class="plan-header">策略二:大仁哥50/50極簡純化架構</div><div class="plan-desc">出清原型0050,將資產結構徹底重塑為純粹的正2加現金:</div><ol class="action-steps"><li>出清全部原型0050:賣出 '+fmt(proVal)+'</li><li>調整槓桿正2至目標持倉:'+fmt(pureLevTarget)+'</li><li>充實防禦現金池至目標:'+fmt(pureCashTarget)+'</li></ol><div class="balance-preview"><span>調整後正2:'+fmt(pureLevTarget)+'</span><span>調整後0050:0 萬元</span><span>調整後現金:'+fmt(pureCashTarget)+'</span></div></div>'; |
| } |
| } |
| adviceBox.innerHTML=cardsHtml; |
| } |
| </script> |
| </body> |
| </html> |