migo0722 commited on
Commit
b42caae
·
verified ·
1 Parent(s): 8e218fe

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +185 -186
index.html CHANGED
@@ -1,222 +1,221 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-TW">
3
  <head>
4
- <meta charset="UTF-8">
5
- <title>大仁哥曝險與再平衡計算機</title>
6
  <style>
7
- body,div,input,select,button,p,h1,h2,h3,span,label,strong{box-sizing:border-box;font-family:"Microsoft JhengHei",sans-serif;}
8
- body{background-color:rgb(245,247,250);margin:0;padding:20px;display:flex;justify-content:center;}
9
- .container{background-color:rgb(255,255,255);padding:30px;border-radius:12px;box-shadow:0 4px 12px rgb(0,0,0,0.1);max-width:800px;width:100%;display:flex;flex-wrap:wrap;gap:30px;}
10
- .left-panel,.right-panel{flex:1;min-width:300px;}
11
- h2{color:rgb(33,37,41);border-bottom:2px solid rgb(226,232,240);padding-bottom:10px;}
12
- .input-group{margin-bottom:15px;}
13
- .input-group label{display:block;margin-bottom:5px;color:rgb(73,80,87);font-weight:bold;}
14
- .input-group input,.input-group select{width:100%;padding:10px;border:1px solid rgb(206,212,218);border-radius:6px;font-size:16px;}
15
- .result-box{background-color:rgb(248,249,250);padding:15px;border-radius:8px;margin-bottom:15px;}
16
- .result-item{display:flex;justify-content:space-between;margin-bottom:10px;font-size:18px;}
17
- .result-item.highlight{color:rgb(220,53,69);font-weight:bold;font-size:20px;}
18
- .progress-bar-bg{background-color:rgb(226,232,240);border-radius:10px;height:20px;width:100%;overflow:hidden;margin-top:5px;}
19
- .progress-bar-fill{height:100%;background-color:rgb(76,175,80);transition:width 0.3s,background-color 0.3s;}
20
- .allocation-bar{display:flex;height:20px;border-radius:10px;overflow:hidden;margin-top:10px;}
21
- .alloc-lev{background-color:rgb(220,53,69);}
22
- .alloc-pro{background-color:rgb(255,193,7);}
23
- .alloc-cash{background-color:rgb(76,175,80);}
24
- .legend{display:flex;gap:10px;font-size:14px;margin-top:5px;}
25
- .legend-item{display:flex;align-items:center;gap:5px;}
26
- .dot{width:12px;height:12px;border-radius:50%;}
27
- .advice-box{background-color:rgb(232,244,253);border-left:5px solid rgb(33,150,243);padding:15px;border-radius:4px;font-size:16px;color:rgb(13,71,161);line-height:1.5;}
28
- .warning{background-color:rgb(253,237,237);border-left:5px solid rgb(244,67,54);color:rgb(183,28,28);}
 
 
 
 
 
 
 
29
  </style>
30
  </head>
31
  <body>
32
- <div class="container">
33
- <div class="left-panel">
34
- <h2>資產輸入區</h2>
35
- <div class="input-group">
36
- <label>槓桿ETF(正2)市值額度</label>
37
- <input type="number" class="lev-input" placeholder="請輸入金額" oninput="calculate()">
38
  </div>
39
- <div class="input-group">
40
- <label>原型ETF(0050)市值額度</label>
41
- <input type="number" class="pro-input" placeholder="請輸入金額" oninput="calculate()">
42
  </div>
43
- <div class="input-group">
44
- <label>現金額度</label>
45
- <input type="number" class="cash-input" placeholder="請輸入金額" oninput="calculate()">
46
  </div>
47
- <h2>再平衡目標設定</h2>
48
- <div class="input-group">
49
- <label>目標總曝險比例(%)</label>
50
- <input type="number" class="target-input" placeholder="例如:120" oninput="calculate()">
51
- </div>
52
- <div class="input-group">
53
- <label>預計調整工具</label>
54
- <select class="adjust-select" onchange="calculate()">
55
- <option value="lev">買賣槓桿ETF(正2)</option>
56
- <option value="pro">買賣原型ETF(0050)</option>
57
- </select>
58
  </div>
59
  </div>
60
- <div class="right-panel">
61
- <h2>分析結果</h2>
62
- <div class="result-box">
63
- <div class="result-item">
64
- <span>總資產:</span>
65
- <span class="total-assets">0</span>
66
  </div>
67
- <div class="result-item">
68
  <span>當前總曝險金額:</span>
69
- <span class="total-exposure">0</span>
70
  </div>
71
- <div class="result-item highlight">
72
- <span>實際曝險比例:</span>
73
- <span class="exposure-pct">0%</span>
74
  </div>
75
- <div class="progress-bar-bg">
76
- <div class="progress-bar-fill" style="width:0%;"></div>
77
  </div>
78
  </div>
79
- <div class="result-box">
80
- <div class="result-item">
81
- <span>資產佔比(正2:原型:現金):</span>
82
- <span class="allocation-text">0:0:0</span>
83
  </div>
84
- <div class="allocation-bar">
85
- <div class="alloc-lev" style="width:0%;"></div>
86
- <div class="alloc-pro" style="width:0%;"></div>
87
- <div class="alloc-cash" style="width:0%;"></div>
88
  </div>
89
- <div class="legend">
90
- <div class="legend-item"><div class="dot alloc-lev"></div>正2</div>
91
- <div class="legend-item"><div class="dot alloc-pro"></div>原型</div>
92
- <div class="legend-item"><div class="dot alloc-cash"></div>現金</div>
93
  </div>
94
  </div>
95
- <h2>調整建議</h2>
96
- <div class="advice-box advice-text">請輸入資料以獲取建議。</div>
 
 
97
  </div>
98
  </div>
99
  <script>
100
- function calculate(){
101
- const lev=parseFloat(document.querySelector('.lev-input').value)||0;
102
- const pro=parseFloat(document.querySelector('.pro-input').value)||0;
103
- const cash=parseFloat(document.querySelector('.cash-input').value)||0;
104
- const targetExposurePct=parseFloat(document.querySelector('.target-input').value)||0;
105
- const adjustAsset=document.querySelector('.adjust-select').value;
106
- const totalAssets=lev+pro+cash;
107
- const elAssets=document.querySelector('.total-assets');
108
- const elExposure=document.querySelector('.total-exposure');
109
- const elPct=document.querySelector('.exposure-pct');
110
- const elBar=document.querySelector('.progress-bar-fill');
111
- const elAllocText=document.querySelector('.allocation-text');
112
- const elAllocLev=document.querySelector('.alloc-lev');
113
- const elAllocPro=document.querySelector('.alloc-pro');
114
- const elAllocCash=document.querySelector('.alloc-cash');
115
- const elAdvice=document.querySelector('.advice-text');
116
- const adviceBox=document.querySelector('.advice-box');
117
- if(totalAssets===0){
118
- elAssets.textContent='0';
119
- elExposure.textContent='0';
120
- elPct.textContent='0%';
121
- elBar.style.width='0%';
122
- elAllocText.textContent='0:0:0';
123
- elAllocLev.style.width='0%';
124
- elAllocPro.style.width='0%';
125
- elAllocCash.style.width='0%';
126
- elAdvice.textContent='請輸入資料以獲取建議。';
127
- adviceBox.className='advice-box\tadvice-text';
128
  return;
129
  }
130
- const totalExposure=lev+lev+pro;
131
- const currentExposurePct=(totalExposure/totalAssets)/(1/100);
132
- elAssets.textContent=Math.round(totalAssets).toLocaleString();
133
- elExposure.textContent=Math.round(totalExposure).toLocaleString();
134
- elPct.textContent=currentExposurePct.toFixed(2)+'%';
135
- let barWidth=currentExposurePct;
136
- if(barWidth>100)barWidth=100;
137
- elBar.style.width=barWidth+'%';
138
- if(currentExposurePct<=100){
139
- elBar.style.backgroundColor='rgb(76,175,80)';
140
- }else if(currentExposurePct<=150){
141
- elBar.style.backgroundColor='rgb(255,193,7)';
142
  }else{
143
- elBar.style.backgroundColor='rgb(244,67,54)';
144
  }
145
- let rawLev=(lev/totalAssets)/(1/100);
146
- let rawPro=(pro/totalAssets)/(1/100);
147
- let rawCash=(cash/totalAssets)/(1/100);
148
- let fLev=Math.floor(rawLev);
149
- let fPro=Math.floor(rawPro);
150
- let fCash=Math.floor(rawCash);
151
- let remainder=100-(fLev+fPro+fCash);
152
- let fractions=[
153
- {key:'lev',val:rawLev-fLev},
154
- {key:'pro',val:rawPro-fPro},
155
- {key:'cash',val:rawCash-fCash}
156
  ];
157
- fractions.sort(function(a,b){return b.val-a.val;});
158
- for(let i=0;i<remainder;i++){
159
- if(fractions[i].key==='lev')fLev++;
160
- else if(fractions[i].key==='pro')fPro++;
161
- else if(fractions[i].key==='cash')fCash++;
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
- elAllocText.textContent=fLev+':'+fPro+':'+fCash;
164
- elAllocLev.style.width=fLev+'%';
165
- elAllocPro.style.width=fPro+'%';
166
- elAllocCash.style.width=fCash+'%';
167
- if(targetExposurePct>0){
168
- const targetExposureAmount=totalAssets/(100/targetExposurePct);
169
- const diffExposure=targetExposureAmount-totalExposure;
170
- if(Math.abs(diffExposure)<1){
171
- adviceBox.className='advice-box\tadvice-text';
172
- elAdvice.textContent='目前曝險已達標,無需調整。';
 
173
  }else{
174
- if(adjustAsset==='lev'){
175
- const changeAmount=diffExposure/2;
176
- if(changeAmount>0){
177
- if(cash>=changeAmount){
178
- adviceBox.className='advice-box\tadvice-text';
179
- elAdvice.innerHTML='建議將現金轉買入槓桿ETF額度:<br><strong>'+Math.round(changeAmount).toLocaleString()+'</strong>';
180
- }else{
181
- adviceBox.className='advice-box\tadvice-text\twarning';
182
- elAdvice.innerHTML='目標需要買入槓桿ETF額度:<strong>'+Math.round(changeAmount).toLocaleString()+'</strong><br>警告:現金餘額不足!';
183
- }
184
- }else{
185
- const sellAmount=Math.abs(changeAmount);
186
- if(lev>=sellAmount){
187
- adviceBox.className='advice-box\tadvice-text';
188
- elAdvice.innerHTML='建議賣出槓桿ETF轉為現金額度:<br><strong>'+Math.round(sellAmount).toLocaleString()+'</strong>';
189
- }else{
190
- adviceBox.className='advice-box\tadvice-text\twarning';
191
- elAdvice.innerHTML='目標需要賣出槓桿ETF額度:<strong>'+Math.round(sellAmount).toLocaleString()+'</strong><br>警告:槓桿ETF餘額不足以賣出!';
192
- }
193
- }
194
- }else{
195
- const changeAmount=diffExposure;
196
- if(changeAmount>0){
197
- if(cash>=changeAmount){
198
- adviceBox.className='advice-box\tadvice-text';
199
- elAdvice.innerHTML='建議將現金轉買入原型ETF額度:<br><strong>'+Math.round(changeAmount).toLocaleString()+'</strong>';
200
- }else{
201
- adviceBox.className='advice-box\tadvice-text\twarning';
202
- elAdvice.innerHTML='目標需要買入原型ETF額度:<strong>'+Math.round(changeAmount).toLocaleString()+'</strong><br>警告:現金餘額不足!';
203
- }
204
- }else{
205
- const sellAmount=Math.abs(changeAmount);
206
- if(pro>=sellAmount){
207
- adviceBox.className='advice-box\tadvice-text';
208
- elAdvice.innerHTML='建議賣出原型ETF轉為現金額度:<br><strong>'+Math.round(sellAmount).toLocaleString()+'</strong>';
209
- }else{
210
- adviceBox.className='advice-box\tadvice-text\twarning';
211
- elAdvice.innerHTML='目標需要賣出原型ETF額度:<strong>'+Math.round(sellAmount).toLocaleString()+'</strong><br>警告:原型ETF餘額不足以賣出!';
212
- }
213
- }
214
- }
215
  }
 
 
 
 
216
  }else{
217
- adviceBox.className='advice-box\tadvice-text';
218
- elAdvice.textContent='請在左側輸入目標總曝險比例以獲得調整建議。';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  }
 
220
  }
221
  </script>
222
  </body>
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-TW">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <title>大仁哥曝險與資產動態平衡計算機</title>
6
  <style>
7
+ 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;}
8
+ body{background-color:rgb(245,247,250);padding:24px;display:flex;justify-content:center;}
9
+ .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;}
10
+ .input-col,.output-col{flex:1;min-width:320px;}
11
+ .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;}
12
+ .field-group{margin-bottom:16px;}
13
+ .field-group label{display:block;margin-bottom:6px;color:rgb(73,80,87);font-weight:bold;font-size:15px;}
14
+ .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;}
15
+ .field-group input:focus{border-color:rgb(13,110,253);}
16
+ .metric-card{background-color:rgb(248,249,250);padding:18px;border-radius:10px;margin-bottom:18px;border:1px solid rgb(233,236,239);}
17
+ .metric-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;font-size:16px;}
18
+ .metric-row.accent{color:rgb(220,53,69);font-weight:bold;font-size:20px;}
19
+ .meter-bg{background-color:rgb(226,232,240);border-radius:8px;height:18px;width:100%;overflow:hidden;margin-top:8px;}
20
+ .meter-fill{height:100%;background-color:rgb(40,167,69);transition:width 0.3s,background-color 0.3s;}
21
+ .split-bar{display:flex;height:18px;border-radius:8px;overflow:hidden;margin-top:8px;}
22
+ .bar-lev{background-color:rgb(220,53,69);}
23
+ .bar-pro{background-color:rgb(255,193,7);}
24
+ .bar-cash{background-color:rgb(40,167,69);}
25
+ .legend-group{display:flex;gap:14px;font-size:13px;margin-top:8px;color:rgb(108,117,125);}
26
+ .legend-point{display:flex;align-items:center;gap:5px;}
27
+ .badge-dot{width:10px;height:10px;border-radius:50%;}
28
+ .advice-panel{display:flex;flex-direction:column;gap:14px;}
29
+ .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);}
30
+ .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);}
31
+ .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);}
32
+ .plan-header{font-weight:bold;font-size:16px;margin-bottom:8px;}
33
+ .plan-desc{font-size:14px;line-height:1.6;margin-bottom:10px;}
34
+ .action-steps{padding-left:20px;font-size:14px;line-height:1.7;margin-bottom:10px;}
35
+ .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);}
36
  </style>
37
  </head>
38
  <body>
39
+ <div class="app-container">
40
+ <div class="input-col">
41
+ <div class="section-title">第一步:現有資產額度</div>
42
+ <div class="field-group">
43
+ <label>槓桿ETF(正2)市值</label>
44
+ <input type="number" class="val-lev" placeholder="例如:300000" oninput="runCalculations()">
45
  </div>
46
+ <div class="field-group">
47
+ <label>原型0050市值</label>
48
+ <input type="number" class="val-pro" placeholder="例如:400000" oninput="runCalculations()">
49
  </div>
50
+ <div class="field-group">
51
+ <label>現金儲備額度</label>
52
+ <input type="number" class="val-cash" placeholder="例如:300000" oninput="runCalculations()">
53
  </div>
54
+ <div class="section-title">第二步:目標曝險設定</div>
55
+ <div class="field-group">
56
+ <label>期望總曝險比例(%)</label>
57
+ <input type="number" class="val-target" placeholder="例如:100 或 120" oninput="runCalculations()">
 
 
 
 
 
 
 
58
  </div>
59
  </div>
60
+ <div class="output-col">
61
+ <div class="section-title">現況曝險與資產結構</div>
62
+ <div class="metric-card">
63
+ <div class="metric-row">
64
+ <span>可投資總資產:</span>
65
+ <span class="txt-assets">0 元</span>
66
  </div>
67
+ <div class="metric-row">
68
  <span>當前總曝險金額:</span>
69
+ <span class="txt-exposure">0 元</span>
70
  </div>
71
+ <div class="metric-row accent">
72
+ <span>實際總曝險比:</span>
73
+ <span class="txt-exp-pct">0%</span>
74
  </div>
75
+ <div class="meter-bg">
76
+ <div class="meter-fill" style="width:0%;"></div>
77
  </div>
78
  </div>
79
+ <div class="metric-card">
80
+ <div class="metric-row">
81
+ <span>資金配置佔比(正2:原型:現金):</span>
82
+ <span class="txt-ratio">0:0:0</span>
83
  </div>
84
+ <div class="split-bar">
85
+ <div class="bar-lev" style="width:0%;"></div>
86
+ <div class="bar-pro" style="width:0%;"></div>
87
+ <div class="bar-cash" style="width:0%;"></div>
88
  </div>
89
+ <div class="legend-group">
90
+ <div class="legend-point"><div class="badge-dot bar-lev"></div>正2部位</div>
91
+ <div class="legend-point"><div class="badge-dot bar-pro"></div>原型部位</div>
92
+ <div class="legend-point"><div class="badge-dot bar-cash"></div>現金部位</div>
93
  </div>
94
  </div>
95
+ <div class="section-title">大仁哥既有部位調整策略</div>
96
+ <div class="advice-panel">
97
+ <div class="plan-card neutral">請於左側輸入各項額度與期望目標曝險比例以取得分析。</div>
98
+ </div>
99
  </div>
100
  </div>
101
  <script>
102
+ function fmt(val){
103
+ return Math.round(val).toLocaleString();
104
+ }
105
+ function runCalculations(){
106
+ const levVal=parseFloat(document.querySelector('.val-lev').value)||0;
107
+ const proVal=parseFloat(document.querySelector('.val-pro').value)||0;
108
+ const cashVal=parseFloat(document.querySelector('.val-cash').value)||0;
109
+ const targetPct=parseFloat(document.querySelector('.val-target').value)||0;
110
+ const total=levVal+proVal+cashVal;
111
+ const txtAssets=document.querySelector('.txt-assets');
112
+ const txtExp=document.querySelector('.txt-exposure');
113
+ const txtExpPct=document.querySelector('.txt-exp-pct');
114
+ const meterFill=document.querySelector('.meter-fill');
115
+ const txtRatio=document.querySelector('.txt-ratio');
116
+ const barLev=document.querySelector('.bar-lev');
117
+ const barPro=document.querySelector('.bar-pro');
118
+ const barCash=document.querySelector('.bar-cash');
119
+ const adviceBox=document.querySelector('.advice-panel');
120
+ if(total===0){
121
+ txtAssets.textContent='0 元';
122
+ txtExp.textContent='0 元';
123
+ txtExpPct.textContent='0%';
124
+ meterFill.style.width='0%';
125
+ txtRatio.textContent='0:0:0';
126
+ barLev.style.width='0%';
127
+ barPro.style.width='0%';
128
+ barCash.style.width='0%';
129
+ adviceBox.innerHTML='<div class="plan-card neutral">請於左側輸入各項額度與期望目標曝險比例以取得分析。</div>';
130
  return;
131
  }
132
+ const currentExposure=levVal+levVal+proVal;
133
+ const currentPct=(currentExposure/total)/(1/100);
134
+ txtAssets.textContent=fmt(total)+' 元';
135
+ txtExp.textContent=fmt(currentExposure)+' 元';
136
+ txtExpPct.textContent=currentPct.toFixed(2)+'%';
137
+ let fillWidth=currentPct;
138
+ if(fillWidth>100)fillWidth=100;
139
+ meterFill.style.width=fillWidth+'%';
140
+ if(currentPct<=100){
141
+ meterFill.style.backgroundColor='rgb(40,167,69)';
142
+ }else if(currentPct<=150){
143
+ meterFill.style.backgroundColor='rgb(255,193,7)';
144
  }else{
145
+ meterFill.style.backgroundColor='rgb(220,53,69)';
146
  }
147
+ let rLev=(levVal/total)/(1/100);
148
+ let rPro=(proVal/total)/(1/100);
149
+ let rCash=(cashVal/total)/(1/100);
150
+ let floorLev=Math.floor(rLev);
151
+ let floorPro=Math.floor(rPro);
152
+ let floorCash=Math.floor(rCash);
153
+ let rem=100-(floorLev+floorPro+floorCash);
154
+ let fractions=[
155
+ {k:'lev',v:rLev-floorLev},
156
+ {k:'pro',v:rPro-floorPro},
157
+ {k:'cash',v:rCash-floorCash}
158
  ];
159
+ fractions.sort(function(a,b){return b.v-a.v;});
160
+ for(let i=0;i<rem;i++){
161
+ if(fractions[i].k==='lev')floorLev++;
162
+ else if(fractions[i].k==='pro')floorPro++;
163
+ else if(fractions[i].k==='cash')floorCash++;
164
+ }
165
+ txtRatio.textContent=floorLev+':'+floorPro+':'+floorCash;
166
+ barLev.style.width=floorLev+'%';
167
+ barPro.style.width=floorPro+'%';
168
+ barCash.style.width=floorCash+'%';
169
+ if(targetPct<=0){
170
+ adviceBox.innerHTML='<div class="plan-card neutral">請於左側設定大於0的期望總曝險比例(%)。</div>';
171
+ return;
172
+ }
173
+ if(targetPct>200){
174
+ adviceBox.innerHTML='<div class="plan-card warn"><div class="plan-header">超出工具內建極限(200%)</div><div class="plan-desc">在不進行額外融資或向券商借貸的前提下,即便將100%資產全數押入槓桿ETF(正2),最大極限曝險即為200%。若欲追求超過200%的曝險,需引進外部信貸或期貨部位。</div></div>';
175
+ return;
176
  }
177
+ const targetExposureAmount=total/(100/targetPct);
178
+ const diffExp=targetExposureAmount-currentExposure;
179
+ if(Math.abs(diffExp)<1){
180
+ 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>';
181
+ return;
182
+ }
183
+ let cardsHtml='';
184
+ if(diffExp>0){
185
+ if(proVal>=diffExp){
186
+ const swapVal=diffExp;
187
+ 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>';
188
  }else{
189
+ const swapAllPro=proVal;
190
+ const remainExp=diffExp-swapAllPro;
191
+ const cashBuyLev=remainExp/2;
192
+ 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>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  }
194
+ const pureLevTarget=total/(200/targetPct);
195
+ const pureCashTarget=total-pureLevTarget;
196
+ const levGap=pureLevTarget-levVal;
197
+ 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>';
198
  }else{
199
+ const dropExp=Math.abs(diffExp);
200
+ if(levVal>=(dropExp/2)){
201
+ const sellLev=dropExp/2;
202
+ 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>';
203
+ }else{
204
+ const sellAllLev=levVal;
205
+ const remainDrop=dropExp-(levVal+levVal);
206
+ const sellPro=remainDrop;
207
+ 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>';
208
+ }
209
+ if(levVal>=dropExp){
210
+ const swapLevToPro=dropExp;
211
+ 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>';
212
+ }else{
213
+ const pureLevTarget=total/(200/targetPct);
214
+ const pureCashTarget=total-pureLevTarget;
215
+ 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>';
216
+ }
217
  }
218
+ adviceBox.innerHTML=cardsHtml;
219
  }
220
  </script>
221
  </body>