전체적인 리팩토링
This commit is contained in:
@@ -8,6 +8,8 @@ import type {
|
||||
DashboardChartTimeframe,
|
||||
DashboardStockCashOrderRequest,
|
||||
DashboardStockCashOrderResponse,
|
||||
DashboardStockOrderableCashRequest,
|
||||
DashboardStockOrderableCashResponse,
|
||||
DashboardStockChartResponse,
|
||||
DashboardStockOrderBookResponse,
|
||||
DashboardStockOverviewResponse,
|
||||
@@ -168,3 +170,34 @@ export async function fetchOrderCash(
|
||||
|
||||
return payload as DashboardStockCashOrderResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 매수가능금액(주문가능현금) 조회 API 호출
|
||||
* @param request 종목/가격 기준 조회 요청
|
||||
* @param credentials KIS 인증 정보
|
||||
*/
|
||||
export async function fetchOrderableCashEstimate(
|
||||
request: DashboardStockOrderableCashRequest,
|
||||
credentials: KisRuntimeCredentials,
|
||||
): Promise<DashboardStockOrderableCashResponse> {
|
||||
const response = await fetch("/api/kis/domestic/orderable-cash", {
|
||||
method: "POST",
|
||||
headers: buildKisRequestHeaders(credentials, {
|
||||
jsonContentType: true,
|
||||
includeAccountNo: true,
|
||||
includeSessionOverride: true,
|
||||
}),
|
||||
body: JSON.stringify(request),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const payload = (await response.json()) as
|
||||
| DashboardStockOrderableCashResponse
|
||||
| KisApiErrorPayload;
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(resolveKisApiErrorMessage(payload, "매수가능금액 조회 중 오류가 발생했습니다."));
|
||||
}
|
||||
|
||||
return payload as DashboardStockOrderableCashResponse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user