스킬 정리 및 리팩토링
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
DashboardOrderSide,
|
||||
DashboardStockItem,
|
||||
} from "@/features/trade/types/trade.types";
|
||||
import { parseKisAccountParts } from "@/lib/kis/account";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface OrderFormProps {
|
||||
@@ -60,6 +61,14 @@ export function OrderForm({ stock, matchedHolding }: OrderFormProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
const accountParts = parseKisAccountParts(verifiedCredentials.accountNo);
|
||||
if (!accountParts) {
|
||||
alert(
|
||||
"계좌번호 형식이 올바르지 않습니다. 설정에서 8-2 형식(예: 12345678-01)으로 다시 확인해 주세요.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await placeOrder(
|
||||
{
|
||||
symbol: stock.symbol,
|
||||
@@ -67,8 +76,8 @@ export function OrderForm({ stock, matchedHolding }: OrderFormProps) {
|
||||
orderType: "limit",
|
||||
price: priceNum,
|
||||
quantity: qtyNum,
|
||||
accountNo: verifiedCredentials.accountNo,
|
||||
accountProductCode: "01",
|
||||
accountNo: `${accountParts.accountNo}-${accountParts.accountProductCode}`,
|
||||
accountProductCode: accountParts.accountProductCode,
|
||||
},
|
||||
verifiedCredentials,
|
||||
);
|
||||
@@ -84,8 +93,17 @@ export function OrderForm({ stock, matchedHolding }: OrderFormProps) {
|
||||
parseInt(quantity.replace(/,/g, "") || "0", 10);
|
||||
|
||||
const setPercent = (pct: string) => {
|
||||
// TODO: 계좌 잔고 연동 시 퍼센트 자동 계산으로 교체
|
||||
console.log("Percent clicked:", pct);
|
||||
const ratio = Number.parseInt(pct.replace("%", ""), 10) / 100;
|
||||
if (!Number.isFinite(ratio) || ratio <= 0) return;
|
||||
|
||||
// UI 흐름: 비율 버튼 클릭 -> 보유수량 기준 계산(매도 탭) -> 주문수량 입력값 반영
|
||||
if (activeTab === "sell" && matchedHolding?.quantity) {
|
||||
const calculatedQuantity = Math.max(
|
||||
1,
|
||||
Math.floor(matchedHolding.quantity * ratio),
|
||||
);
|
||||
setQuantity(String(calculatedQuantity));
|
||||
}
|
||||
};
|
||||
|
||||
const isMarketDataAvailable = Boolean(stock);
|
||||
|
||||
Reference in New Issue
Block a user