수정
Some checks failed
CI/CD Pipeline / test-backend (push) Has been cancelled
CI/CD Pipeline / test-frontend (push) Has been cancelled
CI/CD Pipeline / build-and-push (push) Has been cancelled

This commit is contained in:
2026-04-06 13:16:15 +09:00
parent 24443621f9
commit ab1b1a4cb6
5 changed files with 45 additions and 14 deletions

View File

@@ -466,7 +466,7 @@ export default function Analysis() {
{perf.worst_stocks.map((s) => (
<div key={s.stock_code} className="flex justify-between text-sm">
<span className="text-gray-200">{s.stock_code}</span>
<span className="text-red-400">{fmtKRW(s.net_pnl)}</span>
<span className={s.net_pnl < 0 ? "text-red-400" : "text-green-400"}>{fmtKRW(s.net_pnl)}</span>
</div>
))}
</div>
@@ -477,7 +477,7 @@ export default function Analysis() {
{perf.best_stocks.map((s) => (
<div key={s.stock_code} className="flex justify-between text-sm">
<span className="text-gray-200">{s.stock_code}</span>
<span className="text-green-400">{fmtKRW(s.net_pnl)}</span>
<span className={s.net_pnl > 0 ? "text-green-400" : "text-red-400"}>{fmtKRW(s.net_pnl)}</span>
</div>
))}
</div>

View File

@@ -6,6 +6,15 @@ import HtsPage from '../components/HtsPage'
import api from '../lib/api'
import { useState, Fragment } from 'react'
/** DB에서 KST로 저장된 datetime 문자열을 Date 객체로 변환
* trade_executor가 _get_kst_now()로 KST naive datetime을 저장하므로 +09:00 보정 */
const toKST = (dtStr: string) => {
if (!dtStr) return new Date()
const s = dtStr.trim()
if (s.includes('+') || s.endsWith('Z')) return new Date(s)
return new Date(s + '+09:00')
}
interface Trade {
id: string
created_at: string
@@ -76,13 +85,13 @@ function buildPairs(trades: Trade[]): TradePair[] {
// 매수 이후 가장 가까운 매도 찾기
const sell = sells.find(s =>
!usedSells.has(s.id) &&
new Date(s.created_at) >= new Date(buy.created_at)
toKST(s.created_at) >= toKST(buy.created_at)
) ?? null
if (sell) usedSells.add(sell.id)
const holdMinutes = sell
? differenceInMinutes(new Date(sell.created_at), new Date(buy.created_at))
? differenceInMinutes(toKST(sell.created_at), toKST(buy.created_at))
: null
const pl = sell
@@ -96,7 +105,7 @@ function buildPairs(trades: Trade[]): TradePair[] {
}
// 최신 매수 기준 내림차순
return pairs.sort((a, b) =>
new Date(b.buy.created_at).getTime() - new Date(a.buy.created_at).getTime()
toKST(b.buy.created_at).getTime() - toKST(a.buy.created_at).getTime()
)
}
@@ -138,7 +147,7 @@ function PairView({ pairs }: { pairs: TradePair[] }) {
</div>
</td>
<td className="py-2.5 px-3 text-xs text-blue-300 whitespace-nowrap">
{format(new Date(p.buy.created_at), 'MM/dd HH:mm', { locale: ko })}
{format(toKST(p.buy.created_at), 'MM/dd HH:mm', { locale: ko })}
</td>
<td className="py-2.5 px-3 text-right text-white tabular-nums">
{fmtPrice(p.buy.executed_price ?? p.buy.order_price)}
@@ -146,7 +155,7 @@ function PairView({ pairs }: { pairs: TradePair[] }) {
<td className="py-2.5 px-3 text-xs whitespace-nowrap">
{isOpen
? <span className="text-yellow-400 font-medium">미청산</span>
: <span className="text-red-300">{format(new Date(p.sell!.created_at), 'MM/dd HH:mm', { locale: ko })}</span>
: <span className="text-red-300">{format(toKST(p.sell!.created_at), 'MM/dd HH:mm', { locale: ko })}</span>
}
</td>
<td className="py-2.5 px-3 text-right tabular-nums text-slate-300">