feat: accept valuation amount instead of price for rebalancing input
For holdings with quantity > 0, the input now accepts the total valuation amount and derives the current price by dividing by quantity. Holdings with quantity 0 (target-only) still accept price directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fe48e20642
commit
238c4d1caf
@ -111,8 +111,13 @@ export default function RebalancePage() {
|
||||
setError(null);
|
||||
try {
|
||||
const priceMap: Record<string, number> = {};
|
||||
for (const [ticker, price] of Object.entries(prices)) {
|
||||
priceMap[ticker] = parseFloat(price);
|
||||
for (const [ticker, value] of Object.entries(prices)) {
|
||||
const qty = getHoldingQty(ticker);
|
||||
if (qty > 0) {
|
||||
priceMap[ticker] = parseFloat(value) / qty;
|
||||
} else {
|
||||
priceMap[ticker] = parseFloat(value);
|
||||
}
|
||||
}
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
@ -190,23 +195,25 @@ export default function RebalancePage() {
|
||||
{/* Price Input */}
|
||||
<Card className="mb-6">
|
||||
<CardHeader>
|
||||
<CardTitle>현재 가격 입력</CardTitle>
|
||||
<CardTitle>평가 금액 입력</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{Object.keys(prices).map((ticker) => {
|
||||
const target = targets.find((t) => t.ticker === ticker);
|
||||
const qty = getHoldingQty(ticker);
|
||||
const isValuation = qty > 0;
|
||||
return (
|
||||
<div key={ticker}>
|
||||
<Label htmlFor={`price-${ticker}`}>
|
||||
{nameMap[ticker] || ticker} {target ? `(목표 ${target.target_ratio}%)` : ''} - 보유 {getHoldingQty(ticker)}주
|
||||
{nameMap[ticker] || ticker} {target ? `(목표 ${target.target_ratio}%)` : ''} - 보유 {qty}주
|
||||
</Label>
|
||||
<Input
|
||||
id={`price-${ticker}`}
|
||||
type="number"
|
||||
value={prices[ticker]}
|
||||
onChange={(e) => setPrices((prev) => ({ ...prev, [ticker]: e.target.value }))}
|
||||
placeholder="현재 가격"
|
||||
placeholder={isValuation ? '평가 금액' : '현재 가격'}
|
||||
className="mt-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user