import React from 'react'; import { formatNumber, formatPercent, getQty, getBuyPrice, getCurrentPrice, getProfitRate, getProfitLoss, toNumeric, profitColorClass, } from '../stockUtils'; const AiTradeTab = ({ aib }) => ( <> {aib.balanceError ?

{aib.balanceError}

: null} {/* AI Balance section */}

AI 모의투자

보유 현황

AI가 운용 중인 모의투자 계좌의 잔고와 보유 종목을 확인합니다.

{aib.balanceLoading ? ( 조회 중 ) : null}
{[ { label: '총 평가', value: aib.totalEval }, { label: '예수금', value: aib.deposit }, ].map((item) => (
{item.label} {formatNumber(item.value)}
))}
{aib.holdings.length ? (
{aib.holdings.map((item, idx) => { const profitLoss = getProfitLoss(item); const profitLossNumeric = toNumeric(profitLoss); const profitClass = profitColorClass(profitLossNumeric); const profitRate = getProfitRate(item); const profitRateNumeric = toNumeric(profitRate); const profitRateClass = profitColorClass(profitRateNumeric); return (

{item.name ?? item.code ?? 'N/A'}

{item.code ?? ''}
수량 {formatNumber(getQty(item))}
매입가 {formatNumber(getBuyPrice(item))}
현재가 {formatNumber(getCurrentPrice(item))}
평가금액 {getCurrentPrice(item) != null && getQty(item) != null ? formatNumber(toNumeric(getCurrentPrice(item)) * toNumeric(getQty(item))) : '-'}
수익률 {formatPercent(profitRate)}
평가손익 {formatNumber(profitLoss)}
); })}
) : (

보유 종목이 없습니다.

)}
{/* Manual order section */}

수동 주문

직접 매수/매도

종목명 또는 종목코드를 입력하고 매수/매도 주문을 요청합니다.

{aib.manualError ? (

{aib.manualError}

) : null} {aib.manualResult ? (

요청 결과

                            {typeof aib.manualResult === 'string'
                                ? aib.manualResult
                                : JSON.stringify(aib.manualResult, null, 2)}
                        
) : null}
{/* KIS modal */} {aib.kisModal ? (
aib.setKisModal('')} />

주문 결과

{aib.kisModal}
) : null} ); export default AiTradeTab;