import { Decimal } from "decimal.js"; export type DomainType = "real" | "virtual"; export type MarketType = "KRX" | "NASDAQ" | "NYSE" | "AMEX" | "TYO" | "HKEX" | "HNX" | "HSX" | "SSE" | "SZSE"; export type CountryType = "KR" | "US" | "HK" | "JP" | "VN" | "CN"; export type MarketInfoType = MarketType | CountryType | null | undefined; export type CurrencyType = "KRW" | "USD" | "JPY" | "HKD" | "VND" | "CNY"; export type StockSignType = "upper" | "rise" | "steady" | "decline" | "lower"; export type StockRiskType = "none" | "caution" | "warning" | "risk"; export type OrderType = "buy" | "sell"; export type OrderExecution = "IOC" | "FOK"; export type DomesticOrderCondition = "condition" | "best" | "priority" | "extended" | "before" | "after"; export type ForeignOrderCondition = "LOO" | "LOC" | "MOO" | "MOC" | "extended"; export type OrderCondition = DomesticOrderCondition | ForeignOrderCondition; export type ChartPeriod = "day" | "week" | "month" | "year"; export type KisRankingMarketCode = "J" | "Q" | "K"; export type KisRankingType = "marketCap" | "volume" | "fluctuation"; export type OrderPriceInput = Decimal.Value; export type OrderQuantityInput = Decimal.Value; export declare const REAL_DOMAIN = "https://openapi.koreainvestment.com:9443"; export declare const VIRTUAL_DOMAIN = "https://openapivts.koreainvestment.com:29443"; export declare const WEBSOCKET_REAL_DOMAIN = "ws://ops.koreainvestment.com:21000"; export declare const WEBSOCKET_VIRTUAL_DOMAIN = "ws://ops.koreainvestment.com:31000"; export declare const WEBSOCKET_MAX_SUBSCRIPTIONS = 40; export declare const REAL_API_REQUEST_PER_SECOND = 19; export declare const VIRTUAL_API_REQUEST_PER_SECOND = 2; export declare const APPKEY_LENGTH = 36; export declare const SECRETKEY_LENGTH = 180; export declare const DEFAULT_CUST_TYPE = "P"; export declare const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"; export declare const MARKET_CODE_MAP: Record, string>; export declare const MARKET_SHORT_TYPE_MAP: Record, string>; export declare const DAYTIME_MARKET_SHORT_TYPE_MAP: Partial>; export declare const REVERSE_MARKET_CODE_MAP: Record; export declare const REVERSE_MARKET_SHORT_TYPE_MAP: Record; export declare const MARKET_CURRENCY_MAP: Record; export declare const MARKET_COUNTRY_MAP: Record; export declare const MARKET_TIMEZONE_MAP: Record; export declare const STOCK_SIGN_TYPE_MAP: Record; export declare const STOCK_RISK_TYPE_MAP: Record; export interface KisApiMetadata { rtCd?: string; msgCd?: string; message?: string; trId?: string | null; raw: Record; } export interface RawBacked { raw: Record | string[]; meta?: KisApiMetadata; } export interface KisStockInfo extends RawBacked { symbol: string; stdCode: string; nameKor: string; fullNameKor: string; nameEng: string; fullNameEng: string; name: string; market: MarketType; marketName: string; foreign: boolean; domestic: boolean; } export interface KisIndicator { eps: Decimal; bps: Decimal; per: Decimal; pbr: Decimal; week52High: Decimal; week52Low: Decimal; week52HighDate?: Date; week52LowDate?: Date; } export interface KisQuote extends RawBacked { symbol: string; market: MarketType; name?: string; sectorName?: string | null; price: Decimal; close: Decimal; volume: number; amount: Decimal; marketCap: Decimal; sign: StockSignType; risk: StockRiskType; halt: boolean; overbought: boolean; prevPrice: Decimal; prevVolume: Decimal; change: Decimal; rate: Decimal; indicator?: KisIndicator; open: Decimal; high: Decimal; low: Decimal; highLimit: Decimal; lowLimit: Decimal; unit: Decimal; tick: Decimal; decimalPlaces: number; exchangeRate: Decimal; } export interface KisOrderbookItem { price: Decimal; volume: number; } export interface KisOrderbook extends RawBacked { symbol: string; market: MarketType; decimalPlaces: number; asks: KisOrderbookItem[]; bids: KisOrderbookItem[]; count: number; askPrice?: KisOrderbookItem; bidPrice?: KisOrderbookItem; } export interface KisChartBar { time: Date; timeKst: Date; open: Decimal; close: Decimal; high: Decimal; low: Decimal; volume: number; amount: Decimal; change: Decimal; sign: StockSignType; price: Decimal; prevPrice: Decimal; rate: Decimal; raw: Record; } export interface KisChart extends RawBacked { symbol: string; market: MarketType; timezone: string; bars: KisChartBar[]; } export interface KisCurrencyChart extends RawBacked { symbol: string; timezone: string; bars: KisChartBar[]; } export interface KisInvestorTrendItem extends RawBacked { date: Date; dateKst: Date; close: Decimal; change: Decimal; rate: Decimal; foreignNet: number; institutionNet: number; individualNet: number; foreignNetQuantity: number; institutionNetQuantity: number; individualNetQuantity: number; } export interface KisInvestors extends RawBacked { symbol: string; items: KisInvestorTrendItem[]; foreignTotal: number; institutionTotal: number; individualTotal: number; foreignTotalQuantity: number; institutionTotalQuantity: number; individualTotalQuantity: number; } export interface KisRankingItem extends RawBacked { rank: number; symbol: string; name: string; price: Decimal; change: Decimal; sign: StockSignType; changeSign: StockSignType; changeRate: Decimal; rate: Decimal; volume: number; prevVolume: number; tradingValue: Decimal; listedShares: number; volumeRate: Decimal; turnoverRate: Decimal; } export interface KisRanking extends RawBacked { market: KisRankingMarketCode; type: KisRankingType; rankingType: KisRankingType; items: KisRankingItem[]; } export interface KisDeposit extends RawBacked { accountNumber: string; currency: CurrencyType; amount: Decimal; withdrawableAmount: Decimal; exchangeRate: Decimal; } export interface KisBalanceStock extends RawBacked { accountNumber: string; symbol: string; market: MarketType; name: string; currentPrice: Decimal; quantity: Decimal; qty: Decimal; orderable: Decimal; purchaseAmount: Decimal; purchaseAmountKrw: Decimal; currentAmount: Decimal; amount: Decimal; profit: Decimal; profitRate: Decimal; exchangeRate: Decimal; currency: CurrencyType; } export interface KisBalance extends RawBacked { accountNumber: string; country?: CountryType | null; stocks: KisBalanceStock[]; deposits: Partial>; purchaseAmount: Decimal; currentAmount: Decimal; profit: Decimal; profitRate: Decimal; amount: Decimal; total: Decimal; } export interface KisOrderableAmount extends RawBacked { accountNumber: string; symbol: string; market: MarketType; price: Decimal | null; condition?: OrderCondition | null; execution?: OrderExecution | null; unitPrice: Decimal; amount: Decimal; quantity: Decimal; qty: Decimal; foreignAmount: Decimal; foreignQuantity: Decimal; foreignQty: Decimal; exchangeRate: Decimal; conditionKor: string; } export interface KisOrder extends RawBacked { accountNumber: string; symbol: string; market: MarketType; branch: string; number: string; time: Date; timeKst: Date; } export interface KisPendingOrder extends KisOrder { type: OrderType; price: Decimal; unitPrice: Decimal | null; quantity: Decimal; qty: Decimal; executedQuantity: Decimal; pendingQuantity: Decimal; orderableQuantity: Decimal; condition?: OrderCondition | null; execution?: OrderExecution | null; rejected: boolean; rejectedReason?: string | null; } export interface KisPendingOrders extends RawBacked { accountNumber: string; orders: KisPendingOrder[]; } export interface KisDailyOrder extends KisPendingOrder { name: string; } export interface KisDailyOrders extends RawBacked { accountNumber: string; orders: KisDailyOrder[]; } export interface KisOrderProfit extends RawBacked { accountNumber: string; symbol: string; market: MarketType; name: string; time: Date; buyPrice: Decimal; sellPrice: Decimal; buyAmount: Decimal; sellAmount: Decimal; quantity: Decimal; profit: Decimal; profitRate: Decimal; exchangeRate: Decimal; } export interface KisOrderProfits extends RawBacked { accountNumber: string; orders: KisOrderProfit[]; fees: Decimal; profit: Decimal; } export interface KisWebsocketTR { id: string; key: string; } export interface KisSubscriptionEvent { tr: KisWebsocketTR; response: T; }