@@ -69,8 +69,9 @@ <h2>Live Positions / 实盘持仓</h2>
6969 < table id ="live-positions-table ">
7070 < thead >
7171 < tr >
72- < th > Symbol</ th > < th > Shares</ th > < th > Avg Cost</ th > < th > Price</ th >
73- < th > Value</ th > < th > P&L</ th > < th > P&L %</ th > < th > Today</ th >
72+ < th > Symbol</ th > < th > Side</ th > < th > Qty</ th > < th > Price</ th >
73+ < th > Market Value</ th > < th > Avg Entry</ th > < th > Cost Basis</ th >
74+ < th > Today P/L %</ th > < th > Today P/L $</ th > < th > Total P/L %</ th >
7475 </ tr >
7576 </ thead >
7677 < tbody > </ tbody >
@@ -226,18 +227,19 @@ <h2>Trade History / 交易记录</h2>
226227
227228 const tbody = document . querySelector ( '#live-positions-table tbody' ) ;
228229 data . positions . forEach ( p => {
229- const plClass = p . unrealized_pl >= 0 ? 'positive' : 'negative' ;
230- const todayClass = ( p . change_today || 0 ) >= 0 ? 'positive' : 'negative' ;
231- const today = p . change_today || 0 ;
230+ const todayClass = ( p . today_pl || 0 ) >= 0 ? 'positive' : 'negative' ;
231+ const totalClass = ( p . total_pl || 0 ) >= 0 ? 'positive' : 'negative' ;
232232 tbody . innerHTML += `<tr>
233233 <td class="symbol">${ symLink ( p . symbol ) } </td>
234- <td>${ p . shares } </td>
235- <td>$$ {p . avg_cost . toFixed ( 2 ) } </td>
234+ <td>${ p . side || 'long' } </td>
235+ <td>${ p . qty } </td>
236236 <td>$${ p . current_price . toFixed ( 2 ) } </td>
237237 <td>$${ Math . round ( p . market_value ) . toLocaleString ( ) } </td>
238- <td class="${ plClass } ">${ p . unrealized_pl >= 0 ? '+' : '' } $${ p . unrealized_pl . toFixed ( 0 ) } </td>
239- <td class="${ plClass } ">${ p . unrealized_pl_pct >= 0 ? '+' : '' } ${ p . unrealized_pl_pct . toFixed ( 1 ) } %</td>
240- <td class="${ todayClass } ">${ today >= 0 ? '+' : '' } ${ today . toFixed ( 2 ) } %</td>
238+ <td>$${ p . avg_entry_price . toFixed ( 2 ) } </td>
239+ <td>$${ Math . round ( p . cost_basis ) . toLocaleString ( ) } </td>
240+ <td class="${ todayClass } ">${ p . today_pl_pct >= 0 ? '+' : '' } ${ p . today_pl_pct . toFixed ( 2 ) } %</td>
241+ <td class="${ todayClass } ">${ p . today_pl >= 0 ? '+' : '' } $${ p . today_pl . toFixed ( 0 ) } </td>
242+ <td class="${ totalClass } ">${ p . total_pl_pct >= 0 ? '+' : '' } ${ p . total_pl_pct . toFixed ( 1 ) } %</td>
241243 </tr>` ;
242244 } ) ;
243245 }
0 commit comments