kis

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseURLReal is the production base URL
	BaseURLReal = "https://openapi.koreainvestment.com:9443"
	// BaseURLSandbox is the sandbox base URL
	BaseURLSandbox = "https://openapivts.koreainvestment.com:29443"
)
View Source
const (
	PathPrefixUAPI      = "/uapi"
	PathPrefixUAPISlash = "/uapi/"
)

KIS REST endpoint path constants.

View Source
const (
	PathDomesticStockInquirePrice               = "/uapi/domestic-stock/v1/quotations/inquire-price"
	PathDomesticStockInquireDailyPrice          = "/uapi/domestic-stock/v1/quotations/inquire-daily-price"
	PathDomesticStockInquireDailyItemChartPrice = "/uapi/domestic-stock/v1/quotations/inquire-daily-itemchartprice"
	PathDomesticStockInquireAskingPriceExpCcn   = "/uapi/domestic-stock/v1/quotations/inquire-asking-price-exp-ccn"
	PathDomesticStockInquireCcnl                = "/uapi/domestic-stock/v1/quotations/inquire-ccnl"
	PathDomesticStockInquireTimeItemConclusion  = "/uapi/domestic-stock/v1/quotations/inquire-time-itemconclusion"
	PathDomesticStockInquireMember              = "/uapi/domestic-stock/v1/quotations/inquire-member"
	PathDomesticStockInquireIndexPrice          = "/uapi/domestic-stock/v1/quotations/inquire-index-price"
	PathDomesticStockInquireIndexDailyPrice     = "/uapi/domestic-stock/v1/quotations/inquire-index-daily-price"
	PathDomesticStockInquireDailyIndexChart     = "/uapi/domestic-stock/v1/quotations/inquire-daily-indexchartprice"
	PathDomesticStockSearchStockInfo            = "/uapi/domestic-stock/v1/quotations/search-stock-info"
	PathDomesticStockSearchInfo                 = "/uapi/domestic-stock/v1/quotations/search-info"
	PathDomesticStockVolumeRank                 = "/uapi/domestic-stock/v1/quotations/volume-rank"
	PathDomesticStockRankingMarketCap           = "/uapi/domestic-stock/v1/ranking/market-cap"
	PathDomesticStockRankingFluctuation         = "/uapi/domestic-stock/v1/ranking/fluctuation"
	PathDomesticStockFinancialRatio             = "/uapi/domestic-stock/v1/finance/financial-ratio"
	PathDomesticStockDividend                   = "/uapi/domestic-stock/v1/ksdinfo/dividend"
)
View Source
const (
	PathDomesticStockTradingInquireBalance           = "/uapi/domestic-stock/v1/trading/inquire-balance"
	PathDomesticStockTradingInquirePsblRvseCncl      = "/uapi/domestic-stock/v1/trading/inquire-psbl-rvsecncl"
	PathDomesticStockTradingInquireDailyCcld         = "/uapi/domestic-stock/v1/trading/inquire-daily-ccld"
	PathDomesticStockTradingInquirePsblOrder         = "/uapi/domestic-stock/v1/trading/inquire-psbl-order"
	PathDomesticStockTradingInquirePeriodTradeProfit = "/uapi/domestic-stock/v1/trading/inquire-period-trade-profit"
	PathDomesticStockTradingOrderCash                = "/uapi/domestic-stock/v1/trading/order-cash"
	PathDomesticStockTradingOrderRvseCncl            = "/uapi/domestic-stock/v1/trading/order-rvsecncl"
)
View Source
const (
	PathOverseasPricePrice                  = "/uapi/overseas-price/v1/quotations/price"
	PathOverseasPriceInquireDailyChartPrice = "/uapi/overseas-price/v1/quotations/inquire-daily-chartprice"
	PathOverseasPriceDailyPrice             = "/uapi/overseas-price/v1/quotations/dailyprice"
	PathOverseasPricePriceDetail            = "/uapi/overseas-price/v1/quotations/price-detail"
	PathOverseasPriceInquireCcnl            = "/uapi/overseas-price/v1/quotations/inquire-ccnl"
	PathOverseasPriceInquireTimeItemChart   = "/uapi/overseas-price/v1/quotations/inquire-time-itemchartprice"
	PathOverseasPriceSearchInfo             = "/uapi/overseas-price/v1/quotations/search-info"
	PathOverseasStockRankingUpdownRate      = "/uapi/overseas-stock/v1/ranking/updown-rate"
	PathOverseasStockTradingInquireBalance  = "/uapi/overseas-stock/v1/trading/inquire-balance"
	PathOverseasStockTradingInquirePsAmount = "/uapi/overseas-stock/v1/trading/inquire-psamount"
	PathOverseasStockTradingInquireCcnl     = "/uapi/overseas-stock/v1/trading/inquire-ccnl"
	PathOverseasStockTradingOrder           = "/uapi/overseas-stock/v1/trading/order"
	PathOverseasStockTradingOrderRvseCncl   = "/uapi/overseas-stock/v1/trading/order-rvsecncl"
)
View Source
const (
	PathDomesticBondInquirePrice   = "/uapi/domestic-bond/v1/quotations/inquire-price"
	PathDomesticBondInquireBalance = "/uapi/domestic-bond/v1/trading/inquire-balance"
	PathETFETNComponentStockPrice  = "/uapi/etfetn/v1/quotations/inquire-component-stock-price"
)

Variables

This section is empty.

Functions

func ParseKISDate

func ParseKISDate(s string) (time.Time, error)

ParseKISDate parses KIS date strings (YYYYMMDD)

func ParseKISDateTime

func ParseKISDateTime(date, t string) (time.Time, error)

ParseKISDateTime parses KIS datetime strings

func SetGlobalTokenManager

func SetGlobalTokenManager(tm TokenManager)

SetGlobalTokenManager overrides the global token manager implementation. If tm is nil, the default file-backed manager is used.

Types

type AccountBalanceOutput

type AccountBalanceOutput struct {
	DnpspCblAmt string `json:"dnca_tot_amt"`       // 예수금총액
	TotEvluAmt  string `json:"tot_evlu_amt"`       // 총평가금액
	PchsAmtSmtl string `json:"pchs_amt_smtl_amt"`  // 매입금액합계
	EvluPflsSm  string `json:"evlu_pfls_smtl_amt"` // 평가손익합계
	EvluErngRt  string `json:"evlu_erng_rt"`       // 평가수익율
	SsetTotAmt  string `json:"sset_tot_amt"`       // 자산총액
}

AccountBalanceOutput represents comprehensive account data

type AccountBalanceResponse

type AccountBalanceResponse struct {
	RtCD   string               `json:"rt_cd"`
	MsgCD  string               `json:"msg_cd"`
	Msg1   string               `json:"msg1"`
	Output AccountBalanceOutput `json:"output"`
}

AccountBalanceResponse represents comprehensive account balance

func (*AccountBalanceResponse) IsSuccess

func (r *AccountBalanceResponse) IsSuccess() bool

IsSuccess checks if response is successful

type BalanceResponse

type BalanceResponse struct {
	RetCode string `json:"rt_cd"`
	MsgCode string `json:"msg_cd"`
	Msg1    string `json:"msg1"`
	Output1 []struct {
		PrdtName     string `json:"prdt_name"`      // 상품명
		HldgQty      string `json:"hldg_qty"`       // 보유수량
		OrdPsblQty   string `json:"ord_psbl_qty"`   // 주문가능수량
		PchsAvgPrce  string `json:"pchs_avg_pric"`  // 매입평균가격
		PchsAmt      string `json:"pchs_amt"`       // 매입금액
		PrprTprt     string `json:"prpr_tprt"`      // 평가손익비율
		EvluAmt      string `json:"evlu_amt"`       // 평가금액
		EvluPflsAmt  string `json:"evlu_pfls_amt"`  // 평가손익금액
		StckLoanUnpr string `json:"stck_loan_unpr"` // 대출단가
		ExpnMgna     string `json:"expn_mgna"`      // 만기보증금액
		FlttRt       string `json:"fltt_rt"`        // 등락율
		BfynFyerDvdn string `json:"bfyn_fyer_dvdn"` // 전년도배당
		StckOprcCurr string `json:"stck_oprc_curr"` // 현재가
		StckSdpr     string `json:"stck_sdpr"`      // 기준가
		StckShrn     string `json:"stck_shrn_iscd"` // 종목코드
	} `json:"output1"`
	Output2 []struct {
		DnCaTotAmt       string `json:"dnca_tot_amt"`          // 예수금총액
		NxdyExccAmt      string `json:"nxdy_excc_amt"`         // D+1추정금액
		PrvsDtCsTotCrAmt string `json:"prvs_dt_cs_tot_cr_amt"` // 전일대비총평가금액
		TotEvluAmt       string `json:"tot_evlu_amt"`          // 총평가금액
		EvluPflsSmtlAmt  string `json:"evlu_pfls_smtl_amt"`    // 평가손익합계금액
		PchsAmtSmtlAmt   string `json:"pchs_amt_smtl_amt"`     // 매입금액합계금액
		EvluAmtSmtlAmt   string `json:"evlu_amt_smtl_amt"`     // 평가금액합계금액
		SllBuyAmtSmtl    string `json:"sll_buy_amt_smtl"`      // 매도매수금액합계
		PnlRt            string `json:"evlu_erng_rt"`          // 손익율
	} `json:"output2"`
}

BalanceResponse represents KIS balance response

type BondBalanceOutput

type BondBalanceOutput struct {
	PdNo       string `json:"pdno"`         // 종목코드
	PrdtName   string `json:"prdt_name"`    // 종목명
	CblcQty    string `json:"cblc_qty"`     // 잔고수량
	BuyUnpr    string `json:"buy_unpr"`     // 매입단가
	BuyAmt     string `json:"buy_amt"`      // 매입금액
	BuyDt      string `json:"buy_dt"`       // 매수일자
	BuySqno    string `json:"buy_sqno"`     // 매수순번
	AgrxQty    string `json:"agrx_qty"`     // 총세수량
	SprxQty    string `json:"sprx_qty"`     // 분리과세수량
	Exdt       string `json:"exdt"`         // 만기일
	BuyErngRt  string `json:"buy_erng_rt"`  // 매수수익률
	OrdPsblQty string `json:"ord_psbl_qty"` // 주문가능수량
}

BondBalanceOutput represents a single bond position

type BondBalanceResponse

type BondBalanceResponse struct {
	RtCD         string              `json:"rt_cd"`
	MsgCD        string              `json:"msg_cd"`
	Msg1         string              `json:"msg1"`
	Output       []BondBalanceOutput `json:"output"`  // 보유 채권 리스트
	Output1      []BondBalanceOutput `json:"output1"` // 보유 채권 리스트 (fallback)
	CtxAreaFK200 string              `json:"ctx_area_fk200"`
	CtxAreaNK200 string              `json:"ctx_area_nk200"`
}

BondBalanceResponse represents KIS bond balance inquiry response

func (*BondBalanceResponse) IsSuccess

func (r *BondBalanceResponse) IsSuccess() bool

type BondBalanceSummary

type BondBalanceSummary struct {
	TotEvluAmt     string `json:"tot_evlu_amt"`       // 총평가금액
	PchsAmtSmtlAmt string `json:"pchs_amt_smtl_amt"`  // 매입금액합계
	EvluPflsSmtl   string `json:"evlu_pfls_smtl_amt"` // 평가손익합계
	EvluErngRt     string `json:"evlu_erng_rt"`       // 평가수익율
}

BondBalanceSummary represents bond account summary

type BondPriceOutput

type BondPriceOutput struct {
	IsinCd       string `json:"isin_cd"`        // ISIN코드
	IsinCdNm     string `json:"isin_cd_nm"`     // ISIN코드명
	BondPblcPric string `json:"bond_pblc_pric"` // 채권공모가격
	BondStprPric string `json:"bond_stpr_pric"` // 채권기준가격
	BondClsgPric string `json:"bond_clsg_pric"` // 채권종가
	BondPrdyVrss string `json:"bond_prdy_vrss"` // 채권전일대비
	BondOprcPric string `json:"bond_oprc_pric"` // 채권시가
	BondHgprPric string `json:"bond_hgpr_pric"` // 채권고가
	BondLwprPric string `json:"bond_lwpr_pric"` // 채권저가
	AcmlVol      string `json:"acml_vol"`       // 누적거래량
	AcmlTrPbmn   string `json:"acml_tr_pbmn"`   // 누적거래대금
}

BondPriceOutput represents bond price data

type BondPriceResponse

type BondPriceResponse struct {
	RtCD   string          `json:"rt_cd"`
	MsgCD  string          `json:"msg_cd"`
	Msg1   string          `json:"msg1"`
	Output BondPriceOutput `json:"output"`
}

BondPriceResponse represents KIS bond price inquiry response

func (*BondPriceResponse) IsSuccess

func (r *BondPriceResponse) IsSuccess() bool

IsSuccess checks if response is successful

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the KIS HTTP client

func NewClient

func NewClient(sandbox bool) *Client

NewClient creates a new KIS client

func NewClientWithTokenManager

func NewClientWithTokenManager(sandbox bool, tokenManager TokenManager) *Client

NewClientWithTokenManager creates a new KIS client with an injected token manager. When tokenManager is nil, the global default manager is used.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, creds broker.Credentials) (*broker.Token, error)

Authenticate authenticates with KIS and returns a token

func (*Client) BootstrapMasterSymbols

func (c *Client) BootstrapMasterSymbols(ctx context.Context) (int, error)

BootstrapMasterSymbols downloads and parses KIS master symbol files once per process.

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, orderID string) error

CancelOrder cancels an order

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, accountID string) (*broker.Balance, error)

GetBalance retrieves account balance

func (*Client) GetOHLCV

func (c *Client) GetOHLCV(ctx context.Context, market, symbol string, opts broker.OHLCVOpts) ([]broker.OHLCV, error)

GetOHLCV retrieves OHLCV data for the given market and symbol

func (*Client) GetPositions

func (c *Client) GetPositions(ctx context.Context, accountID string) ([]broker.Position, error)

GetPositions retrieves account positions

func (*Client) GetQuote

func (c *Client) GetQuote(ctx context.Context, market, symbol string) (*broker.Quote, error)

GetQuote retrieves a quote for the given market and symbol

func (*Client) InquireAccountBalance

func (c *Client) InquireAccountBalance(ctx context.Context, accountNo, accountProductCode string) (*AccountBalanceResponse, error)

InquireAccountBalance retrieves comprehensive account balance (stocks + bonds + cash) TR_ID: TTTC8434R (실전투자 종합잔고)

func (*Client) InquireAskingPriceExpCcn added in v0.6.0

func (c *Client) InquireAskingPriceExpCcn(ctx context.Context, marketDiv, symbol string) (*RawResponse, error)

InquireAskingPriceExpCcn retrieves domestic orderbook/expected matching data. TR_ID: FHKST01010200

func (*Client) InquireBalance

func (c *Client) InquireBalance(ctx context.Context, accountNo, accountProductCode string) (*StockBalanceResponse, error)

InquireBalance retrieves stock account balance TR_ID: TTTC8434R (실전투자), VTTC8434R (모의투자)

func (*Client) InquireBondBalance

func (c *Client) InquireBondBalance(ctx context.Context, accountNo, accountProductCode string) (*BondBalanceResponse, error)

InquireBondBalance retrieves bond account balance with pagination TR_ID: CTSC8407R (장내채권 잔고조회)

func (*Client) InquireBondDaily

func (c *Client) InquireBondDaily(ctx context.Context, isinCode string, startDate, endDate string) (*StockDailyPriceResponse, error)

InquireBondDaily retrieves daily bond price data. KIS domestic-bond endpoint currently uses the same service(TR_ID) and required query schema as inquire-price for historical 조회. TR_ID: FHKST03010100

func (*Client) InquireBondPrice

func (c *Client) InquireBondPrice(ctx context.Context, isinCode string) (*BondPriceResponse, error)

InquireBondPrice retrieves current bond price TR_ID: FHKST03010100 (국내채권 시세조회)

func (*Client) InquireCcnl added in v0.6.0

func (c *Client) InquireCcnl(ctx context.Context, marketDiv, symbol string) (*RawResponse, error)

InquireCcnl retrieves domestic current execution/tick snapshot. TR_ID: FHKST01010300

func (*Client) InquireComponentStockPrice added in v0.6.0

func (c *Client) InquireComponentStockPrice(ctx context.Context, marketDiv, symbol, screenDiv string) (*RawResponse, error)

InquireComponentStockPrice retrieves ETF/ETN component stocks. TR_ID: FHKST121600C0

func (*Client) InquireDailyCcld

func (c *Client) InquireDailyCcld(
	ctx context.Context,
	accountNo, accountProductCode, startDate, endDate, orderOrgNo, orderNo, exchangeID string,
) (*DomesticDailyCcldResponse, error)

InquireDailyCcld retrieves domestic daily order/filled status. TR_ID: TTTC0081R (real), VTTC0081R (sandbox)

func (*Client) InquireDailyIndexChartPrice added in v0.6.0

func (c *Client) InquireDailyIndexChartPrice(ctx context.Context, marketDiv, indexCode, fromDate, toDate, periodDiv string) (*RawResponse, error)

InquireDailyIndexChartPrice retrieves sector/index period chart. TR_ID: FHKUP03500100

func (*Client) InquireDailyPrice

func (c *Client) InquireDailyPrice(ctx context.Context, market, symbol string, startDate, endDate string, adjustPrice bool) (*StockDailyPriceResponse, error)

InquireDailyPrice retrieves daily OHLCV data TR_ID: FHKST01010400 (실전투자), VHKST01010400 (모의투자)

func (*Client) InquireDividend added in v0.6.0

func (c *Client) InquireDividend(ctx context.Context, cts, gb1, fromDate, toDate, shortCode, highGb string) (*RawResponse, error)

InquireDividend retrieves KSD dividend schedule. TR_ID: HHKDB669102C0

func (*Client) InquireFinancialRatio added in v0.6.0

func (c *Client) InquireFinancialRatio(ctx context.Context, divClsCode, marketDiv, symbol string) (*RawResponse, error)

InquireFinancialRatio retrieves domestic financial ratios. TR_ID: FHKST66430300

func (*Client) InquireIndexDailyPrice added in v0.6.0

func (c *Client) InquireIndexDailyPrice(ctx context.Context, periodDiv, marketDiv, indexCode, inputDate1 string) (*RawResponse, error)

InquireIndexDailyPrice retrieves domestic index daily series. TR_ID: FHPUP02120000

func (*Client) InquireIndexPrice added in v0.6.0

func (c *Client) InquireIndexPrice(ctx context.Context, marketDiv, indexCode string) (*RawResponse, error)

InquireIndexPrice retrieves domestic index current quote. TR_ID: FHPUP02100000

func (*Client) InquireMarketCapRank added in v0.6.0

func (c *Client) InquireMarketCapRank(ctx context.Context, p MarketCapRankParams) (*RawResponse, error)

InquireMarketCapRank retrieves market-cap rank. TR_ID: FHPST01740000

func (*Client) InquireMember added in v0.6.0

func (c *Client) InquireMember(ctx context.Context, marketDiv, symbol string) (*RawResponse, error)

InquireMember retrieves broker/member level quote details. TR_ID: FHKST01010600

func (*Client) InquireOverseasBalanceRaw added in v0.6.0

func (c *Client) InquireOverseasBalanceRaw(ctx context.Context, accountNo, accountProductCode, ovrsExcgCd, trCrcyCd, ctxFK200, ctxNK200 string) (*RawResponse, error)

InquireOverseasBalanceRaw retrieves overseas balance details. TR_ID: TTTS3012R (real), VTTS3012R (sandbox)

func (*Client) InquireOverseasCcnl

func (c *Client) InquireOverseasCcnl(
	ctx context.Context,
	accountNo, accountProductCode, startDate, endDate, exchangeCode string,
) (*OverseasCcnlResponse, error)

InquireOverseasCcnl retrieves overseas order/fill status. TR_ID: TTTS3035R (real), VTTS3035R (sandbox)

func (*Client) InquireOverseasDailyChartPrice added in v0.6.0

func (c *Client) InquireOverseasDailyChartPrice(ctx context.Context, marketDiv, symbol, fromDate, toDate, periodDiv string) (*RawResponse, error)

InquireOverseasDailyChartPrice retrieves overseas day/week/month/year chart. TR_ID: FHKST03030100

func (*Client) InquireOverseasDailyPrice added in v0.6.0

func (c *Client) InquireOverseasDailyPrice(ctx context.Context, auth, exchangeCode, symbol, gubn, bymd, modp string) (*RawResponse, error)

InquireOverseasDailyPrice retrieves overseas period quotes. TR_ID: HHDFS76240000

func (*Client) InquireOverseasPrice

func (c *Client) InquireOverseasPrice(ctx context.Context, exchangeCode, symbol string) (*OverseasPriceResponse, error)

InquireOverseasPrice retrieves overseas stock price TR_ID: HHDFS00000300 (미국 주식 현재가) 거래소코드: NASDAQ(NAS), NYSE(NYS), AMEX(AMS)

func (*Client) InquireOverseasPriceDetail added in v0.6.0

func (c *Client) InquireOverseasPriceDetail(ctx context.Context, auth, exchangeCode, symbol string) (*RawResponse, error)

InquireOverseasPriceDetail retrieves overseas orderbook/detail snapshot. TR_ID: HHDFS76200200

func (*Client) InquireOverseasProductBasicInfo

func (c *Client) InquireOverseasProductBasicInfo(ctx context.Context, symbol, prdtTypeCode string) (*OverseasProductBasicInfoResponse, error)

InquireOverseasProductBasicInfo retrieves overseas product basic info. TR_ID: CTPF1702R

func (*Client) InquireOverseasPsAmount added in v0.6.0

func (c *Client) InquireOverseasPsAmount(ctx context.Context, accountNo, accountProductCode, ovrsExcgCd, ovrsOrdUnpr, itemCd string) (*RawResponse, error)

InquireOverseasPsAmount retrieves overseas orderable amount. TR_ID: TTTS3007R (real), VTTS3007R (sandbox)

func (*Client) InquireOverseasTick added in v0.6.0

func (c *Client) InquireOverseasTick(ctx context.Context, exchangeCode, tday, symbol, auth, keyb string) (*RawResponse, error)

InquireOverseasTick retrieves overseas execution/tick details. TR_ID: HHDFS76200300

func (*Client) InquireOverseasTimeItemChartPrice added in v0.6.0

func (c *Client) InquireOverseasTimeItemChartPrice(ctx context.Context, auth, exchangeCode, symbol, nmin, pinc, next, nrec, fill, keyb string) (*RawResponse, error)

InquireOverseasTimeItemChartPrice retrieves overseas intraday time chart/ticks. TR_ID: HHDFS76950200

func (*Client) InquireOverseasUpdownRate added in v0.6.0

func (c *Client) InquireOverseasUpdownRate(ctx context.Context, exchangeCode, nday, gubn, volRange, auth, keyb string) (*RawResponse, error)

InquireOverseasUpdownRate retrieves overseas up/down rank. TR_ID: HHDFS76290000

func (*Client) InquirePeriodTradeProfit added in v0.6.0

func (c *Client) InquirePeriodTradeProfit(ctx context.Context, accountNo, accountProductCode, sortDvsn, startDate, endDate, cblcDvsn, symbol, ctxNK100, ctxFK100 string) (*RawResponse, error)

InquirePeriodTradeProfit retrieves domestic period profit/loss. TR_ID: TTTC8715R

func (*Client) InquirePossibleOrder added in v0.6.0

func (c *Client) InquirePossibleOrder(ctx context.Context, accountNo, accountProductCode, symbol, orderUnitPrice, orderDvsn, cmaEvalIncludedYN, overseasIncludedYN string) (*RawResponse, error)

InquirePossibleOrder retrieves domestic orderable amount. TR_ID: TTTC8908R (real), VTTC8908R (sandbox)

func (*Client) InquirePossibleRvseCncl

func (c *Client) InquirePossibleRvseCncl(ctx context.Context, accountNo, accountProductCode string) (*StockRvseCnclResponse, error)

InquirePossibleRvseCncl retrieves cancellable/modifiable stock orders. TR_ID: TTTC8036R (legacy), VTTC8036R (legacy mock)

func (*Client) InquirePrice

func (c *Client) InquirePrice(ctx context.Context, market, symbol string) (*StockPriceResponse, error)

InquirePrice retrieves current stock price TR_ID: FHKST01010100 (실전투자), VHKST01010300 (모의투자)

func (*Client) InquireProductBasicInfo

func (c *Client) InquireProductBasicInfo(ctx context.Context, symbol, prdtTypeCode string) (*ProductBasicInfoResponse, error)

InquireProductBasicInfo retrieves product basic info (search-info). TR_ID: CTPF1604R

func (*Client) InquireStockBasicInfo

func (c *Client) InquireStockBasicInfo(ctx context.Context, symbol, prdtTypeCode string) (*StockBasicInfoResponse, error)

InquireStockBasicInfo retrieves domestic stock basic info (search-stock-info). TR_ID: CTPF1002R

func (*Client) InquireTimeItemConclusion added in v0.6.0

func (c *Client) InquireTimeItemConclusion(ctx context.Context, marketDiv, symbol, inputHour1 string) (*RawResponse, error)

InquireTimeItemConclusion retrieves intraday time-bucketed trade details. TR_ID: FHPST01060000

func (*Client) InquireVolumeRank added in v0.6.0

func (c *Client) InquireVolumeRank(ctx context.Context, p VolumeRankParams) (*RawResponse, error)

InquireVolumeRank retrieves domestic volume rank. TR_ID: FHPST01710000

func (*Client) ModifyOrder

func (c *Client) ModifyOrder(ctx context.Context, orderID string, req broker.ModifyOrderRequest) (*broker.OrderResult, error)

ModifyOrder modifies an existing order

func (*Client) Name

func (c *Client) Name() string

Name returns the broker name

func (*Client) OrderCash

func (c *Client) OrderCash(ctx context.Context, accountNo, accountProductCode, symbol string, orderType string, quantity int, price int, side string, exchangeID string) (*OrderResponse, error)

OrderCash places a cash order (buy/sell) TR_ID: TTTC0802U (실전 매수), VTTC0802U (모의 매수) TR_ID: TTTC0801U (실전 매도), VTTC0801U (모의 매도)

func (*Client) OrderOverseas

func (c *Client) OrderOverseas(
	ctx context.Context,
	accountNo, accountProductCode, exchangeCode, symbol string,
	quantity int,
	price float64,
	side string,
	ordDvsn string,
) (*OrderResponse, error)

OrderOverseas places an overseas stock order.

func (*Client) OrderOverseasRvseCncl

func (c *Client) OrderOverseasRvseCncl(
	ctx context.Context,
	accountNo, accountProductCode, exchangeCode, symbol, originalOrderNo, rvseCnclDvsnCD string,
	quantity int,
	price float64,
) (*OrderResponse, error)

OrderOverseasRvseCncl places an overseas stock revise/cancel order.

func (*Client) OrderRvseCncl

func (c *Client) OrderRvseCncl(
	ctx context.Context,
	accountNo, accountProductCode, orderOrgNo, originalOrderNo, orderDvsn, rvseCnclDvsnCD string,
	orderQty, orderPrice int,
	qtyAll bool,
	exchangeID string,
) (*OrderResponse, error)

OrderRvseCncl places a domestic stock order revise/cancel request. RVSE_CNCL_DVSN_CD: 01=revise, 02=cancel

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(ctx context.Context, req broker.OrderRequest) (*broker.OrderResult, error)

PlaceOrder places a new order

func (*Client) ReloadMasterSymbols

func (c *Client) ReloadMasterSymbols(ctx context.Context) (int, error)

ReloadMasterSymbols force-reloads master symbols even when already loaded.

func (*Client) SetCredentials

func (c *Client) SetCredentials(appKey, appSecret string)

SetCredentials sets the app key and secret

type DomesticDailyCcldItem

type DomesticDailyCcldItem struct {
	OrdDt      string `json:"ord_dt"`
	OrdGnoBrno string `json:"ord_gno_brno"`
	ODNo       string `json:"odno"`
	OrgnODNo   string `json:"orgn_odno"`
	OrdTmd     string `json:"ord_tmd"`
	PdNo       string `json:"pdno"`
	PrdtName   string `json:"prdt_name"`
	OrdQty     string `json:"ord_qty"`
	OrdUNPR    string `json:"ord_unpr"`
	SllBuyDvsn string `json:"sll_buy_dvsn_cd"`
	TotCcldQty string `json:"tot_ccld_qty"`
	TotCcldAmt string `json:"tot_ccld_amt"`
	AvgPrvs    string `json:"avg_prvs"`
	CnclYN     string `json:"cncl_yn"`
	CncCfrmQty string `json:"cnc_cfrm_qty"`
	RmnQty     string `json:"rmn_qty"`
	RjctQty    string `json:"rjct_qty"`
	OrdDvsnCD  string `json:"ord_dvsn_cd"`
	ExcgIDDvsn string `json:"excg_id_dvsn_cd"`
}

DomesticDailyCcldItem represents one domestic order row.

type DomesticDailyCcldResponse

type DomesticDailyCcldResponse struct {
	RtCD         string                  `json:"rt_cd"`
	MsgCD        string                  `json:"msg_cd"`
	Msg1         string                  `json:"msg1"`
	Output1      []DomesticDailyCcldItem `json:"output1"`
	CtxAreaFK100 string                  `json:"ctx_area_fk100"`
	CtxAreaNK100 string                  `json:"ctx_area_nk100"`
}

DomesticDailyCcldResponse represents domestic daily order/filled inquiry response.

func (*DomesticDailyCcldResponse) IsSuccess

func (r *DomesticDailyCcldResponse) IsSuccess() bool

type ErrorResponse

type ErrorResponse struct {
	RtCD  string `json:"rt_cd"`
	MsgCD string `json:"msg_cd"`
	Msg1  string `json:"msg1"`
}

ErrorResponse represents KIS API error response

func (*ErrorResponse) IsSuccess

func (e *ErrorResponse) IsSuccess() bool

IsSuccess checks if the response indicates success

type FileTokenManager

type FileTokenManager struct {
	// contains filtered or unexported fields
}

FileTokenManager stores tokens in memory and persists them to disk.

func NewFileTokenManager

func NewFileTokenManager() *FileTokenManager

NewFileTokenManager creates the default file-backed token manager.

func NewFileTokenManagerWithDir

func NewFileTokenManagerWithDir(dir string) *FileTokenManager

NewFileTokenManagerWithDir creates a file-backed token manager with an optional fixed directory. When dir is empty, the default directory resolution is used.

func (*FileTokenManager) GetToken

func (tm *FileTokenManager) GetToken(appKey string) (string, time.Time, bool)

GetToken returns the cached token for the given appkey Returns (token, expiresAt, found)

func (*FileTokenManager) SetToken

func (tm *FileTokenManager) SetToken(appKey, token string, expiresAt time.Time) error

SetToken stores the token for the given appkey (in memory and on disk)

func (*FileTokenManager) WaitForAuth

func (tm *FileTokenManager) WaitForAuth(appKey string)

WaitForAuth enforces the per-appkey token issuance rate limit (1/minute)

type MarketCapRankParams added in v0.6.0

type MarketCapRankParams struct {
	InputPrice2     string
	MarketDiv       string
	ScreenDiv       string
	DivClsCode      string
	InputISCD       string
	TrgtClsCode     string
	TrgtExlsClsCode string
	InputPrice1     string
	VolCnt          string
}

MarketCapRankParams are request params for market-cap rank API.

type MasterSymbol

type MasterSymbol struct {
	Symbol          string
	Market          string
	Name            string
	NameEn          string
	Exchange        string
	Currency        string
	Country         string
	ProductType     string
	ProductTypeCode string
	SecurityGroup   string
	IsListed        bool
}

MasterSymbol is a parsed symbol record from KIS master files (.mst/.cod).

func LookupMasterSymbol

func LookupMasterSymbol(market, symbol string) (MasterSymbol, bool)

LookupMasterSymbol returns a symbol record from preloaded master files.

type OHLCVResponse

type OHLCVResponse struct {
	RetCode string `json:"rt_cd"`
	MsgCode string `json:"msg_cd"`
	Msg1    string `json:"msg1"`
	Output  []struct {
		StckBsopDate string `json:"stck_bsop_date"` // 영업일자
		StckOprc     string `json:"stck_oprc"`      // 시가
		StckHgpr     string `json:"stck_hgpr"`      // 고가
		StckLwpr     string `json:"stck_lwpr"`      // 저가
		StckClpr     string `json:"stck_clpr"`      // 종가
		AccTrVol     string `json:"acml_vol"`       // 누적거래량
	} `json:"output"`
}

OHLCVResponse represents KIS OHLCV response

type OrderRequest

type OrderRequest struct {
	CANO         string `json:"CANO"`
	ACNT_PRDT_CD string `json:"ACNT_PRDT_CD"`
	PDNO         string `json:"PDNO"`
	ORD_DVSN     string `json:"ORD_DVSN"`
	ORD_QTY      string `json:"ORD_QTY"`
	ORD_UNPR     string `json:"ORD_UNPR"`
	EXCG_ID_DVSN string `json:"EXCG_ID_DVSN_CD,omitempty"`
	SLL_TYPE     string `json:"SLL_TYPE,omitempty"`
	CNDT_PRIC    string `json:"CNDT_PRIC,omitempty"`
}

OrderRequest represents KIS order request body

type OrderResponse

type OrderResponse struct {
	RetCode string `json:"rt_cd"`
	MsgCode string `json:"msg_cd"`
	Msg1    string `json:"msg1"`
	Output  struct {
		KrxFwdOrdOrgno string `json:"KRX_FWDG_ORD_ORGNO"` // 주문조직번호
		OrdNo          string `json:"ODNO"`               // 주문번호
		OrdTmd         string `json:"ORD_TMD"`            // 주문시각
	} `json:"output"`
}

OrderResponse represents KIS order response

type OrderRvseCnclRequest

type OrderRvseCnclRequest struct {
	CANO           string `json:"CANO"`
	ACNT_PRDT_CD   string `json:"ACNT_PRDT_CD"`
	KRXFwdOrdOrgNo string `json:"KRX_FWDG_ORD_ORGNO"`
	OrgnODNo       string `json:"ORGN_ODNO"`
	OrdDvsn        string `json:"ORD_DVSN"`
	RvseCnclDvsnCD string `json:"RVSE_CNCL_DVSN_CD"`
	OrdQty         string `json:"ORD_QTY"`
	OrdUNPR        string `json:"ORD_UNPR"`
	QtyAllOrdYN    string `json:"QTY_ALL_ORD_YN"`
	ExcgIDDvsnCD   string `json:"EXCG_ID_DVSN_CD,omitempty"`
	CndtPric       string `json:"CNDT_PRIC,omitempty"`
}

OrderRvseCnclRequest represents KIS order revise/cancel request body.

type OverseasCcnlItem

type OverseasCcnlItem struct {
	OrdDt         string `json:"ord_dt"`
	OrdTmd        string `json:"ord_tmd"`
	OrdGnoBrno    string `json:"ord_gno_brno"`
	ODNo          string `json:"odno"`
	OrgnODNo      string `json:"orgn_odno"`
	SllBuyDvsnCD  string `json:"sll_buy_dvsn_cd"`
	RvseCnclDvsn  string `json:"rvse_cncl_dvsn"`
	PdNo          string `json:"pdno"`
	PrdtName      string `json:"prdt_name"`
	FtOrdQty      string `json:"ft_ord_qty"`
	FtOrdUNPR3    string `json:"ft_ord_unpr3"`
	FtCcldQty     string `json:"ft_ccld_qty"`
	FtCcldUNPR3   string `json:"ft_ccld_unpr3"`
	FtCcldAmt3    string `json:"ft_ccld_amt3"`
	NccsQty       string `json:"nccs_qty"`
	PrcsStatName  string `json:"prcs_stat_name"`
	RjctRson      string `json:"rjct_rson"`
	RjctRsonName  string `json:"rjct_rson_name"`
	OvrsExcgCD    string `json:"ovrs_excg_cd"`
	TrCrcyCD      string `json:"tr_crcy_cd"`
	UsaAmkExtsYN  string `json:"usa_amk_exts_rqst_yn"`
	SpltBuyAttrNm string `json:"splt_buy_attr_name"`
}

OverseasCcnlItem represents one overseas order row.

type OverseasCcnlResponse

type OverseasCcnlResponse struct {
	RtCD         string             `json:"rt_cd"`
	MsgCD        string             `json:"msg_cd"`
	Msg1         string             `json:"msg1"`
	CtxAreaFK200 string             `json:"ctx_area_fk200"`
	CtxAreaNK200 string             `json:"ctx_area_nk200"`
	Output       []OverseasCcnlItem `json:"output"`
}

OverseasCcnlResponse represents overseas order/fill inquiry response.

func (*OverseasCcnlResponse) IsSuccess

func (r *OverseasCcnlResponse) IsSuccess() bool

type OverseasOrderRequest

type OverseasOrderRequest struct {
	CANO            string `json:"CANO"`
	ACNT_PRDT_CD    string `json:"ACNT_PRDT_CD"`
	OVRS_EXCG_CD    string `json:"OVRS_EXCG_CD"`
	PDNO            string `json:"PDNO"`
	ORD_QTY         string `json:"ORD_QTY"`
	OVRS_ORD_UNPR   string `json:"OVRS_ORD_UNPR"`
	CTAC_TLNO       string `json:"CTAC_TLNO,omitempty"`
	MGCO_APTM_ODNO  string `json:"MGCO_APTM_ODNO,omitempty"`
	SLL_TYPE        string `json:"SLL_TYPE,omitempty"`
	ORD_SVR_DVSN_CD string `json:"ORD_SVR_DVSN_CD,omitempty"`
	ORD_DVSN        string `json:"ORD_DVSN"`
}

OverseasOrderRequest represents KIS overseas stock order request body.

type OverseasOrderRvseCnclRequest

type OverseasOrderRvseCnclRequest struct {
	CANO              string `json:"CANO"`
	ACNT_PRDT_CD      string `json:"ACNT_PRDT_CD"`
	OVRS_EXCG_CD      string `json:"OVRS_EXCG_CD"`
	PDNO              string `json:"PDNO"`
	ORGN_ODNO         string `json:"ORGN_ODNO"`
	RVSE_CNCL_DVSN_CD string `json:"RVSE_CNCL_DVSN_CD"`
	ORD_QTY           string `json:"ORD_QTY"`
	OVRS_ORD_UNPR     string `json:"OVRS_ORD_UNPR"`
	MGCO_APTM_ODNO    string `json:"MGCO_APTM_ODNO,omitempty"`
	ORD_SVR_DVSN_CD   string `json:"ORD_SVR_DVSN_CD,omitempty"`
}

OverseasOrderRvseCnclRequest represents KIS overseas stock revise/cancel request body.

type OverseasPriceOutput

type OverseasPriceOutput struct {
	RsymStr      string `json:"rsym"`           // 실시간종목코드
	SymbDesc     string `json:"symb_desc"`      // 종목명
	Last         string `json:"last"`           // 현재가
	Open         string `json:"open"`           // 시가
	High         string `json:"high"`           // 고가
	Low          string `json:"low"`            // 저가
	PrdyVrss     string `json:"prdy_vrss"`      // 전일대비
	PrdyVrssSign string `json:"prdy_vrss_sign"` // 전일대비부호
	AccrTrVol    string `json:"t_xvol"`         // 누적거래량
}

OverseasPriceOutput represents overseas stock price data

type OverseasPriceResponse

type OverseasPriceResponse struct {
	RtCD   string              `json:"rt_cd"`
	MsgCD  string              `json:"msg_cd"`
	Msg1   string              `json:"msg1"`
	Output OverseasPriceOutput `json:"output"`
}

OverseasPriceResponse represents overseas stock price response

func (*OverseasPriceResponse) IsSuccess

func (r *OverseasPriceResponse) IsSuccess() bool

IsSuccess checks if response is successful

type OverseasProductBasicInfoOutput

type OverseasProductBasicInfoOutput struct {
	StdPdNo                string `json:"std_pdno"`
	PrdtName               string `json:"prdt_name"`
	PrdtEngName            string `json:"prdt_eng_name"`
	OvrsItemName           string `json:"ovrs_item_name"`
	PrdtClsfCD             string `json:"prdt_clsf_cd"`
	PrdtClsfName           string `json:"prdt_clsf_name"`
	NatnCD                 string `json:"natn_cd"`
	NatnName               string `json:"natn_name"`
	TrMketCD               string `json:"tr_mket_cd"`
	TrMketName             string `json:"tr_mket_name"`
	OvrsExcgCD             string `json:"ovrs_excg_cd"`
	OvrsExcgName           string `json:"ovrs_excg_name"`
	TrCrcyCD               string `json:"tr_crcy_cd"`
	CrcyName               string `json:"crcy_name"`
	OvrsStckDvsnCD         string `json:"ovrs_stck_dvsn_cd"`
	LstgYN                 string `json:"lstg_yn"`
	LstgDt                 string `json:"lstg_dt"`
	LstgAbolItemYN         string `json:"lstg_abol_item_yn"`
	LstgAbolDt             string `json:"lstg_abol_dt"`
	OvrsStckTrStopDvsnCD   string `json:"ovrs_stck_tr_stop_dvsn_cd"`
	OvrsStckStopRsonCD     string `json:"ovrs_stck_stop_rson_cd"`
	DtmTrPsblYN            string `json:"dtm_tr_psbl_yn"`
	MemoText1              string `json:"memo_text1"`
	OvrsNowPric1           string `json:"ovrs_now_pric1"`
	LastRcvgDtime          string `json:"last_rcvg_dtime"`
	MiniStkTrStatDvsnCD    string `json:"mini_stk_tr_stat_dvsn_cd"`
	MintDcptTradPsblYN     string `json:"mint_dcpt_trad_psbl_yn"`
	MintFnumTradPsblYN     string `json:"mint_fnum_trad_psbl_yn"`
	PtpItemYN              string `json:"ptp_item_yn"`
	PtpItemTrfxExmtYN      string `json:"ptp_item_trfx_exmt_yn"`
	PtpItemTrfxExmtStrtDt  string `json:"ptp_item_trfx_exmt_strt_dt"`
	PtpItemTrfxExmtEndDt   string `json:"ptp_item_trfx_exmt_end_dt"`
	SdrfStopEclsYN         string `json:"sdrf_stop_ecls_yn"`
	SdrfStopEclsErlmDt     string `json:"sdrf_stop_ecls_erlm_dt"`
	PrdtTypeCD2            string `json:"prdt_type_cd_2"`
	OvrsStckPrdtGrpNo      string `json:"ovrs_stck_prdt_grp_no"`
	OvrsStckErlmRosnCD     string `json:"ovrs_stck_erlm_rosn_cd"`
	OvrsStckHistRghtDvsnCD string `json:"ovrs_stck_hist_rght_dvsn_cd"`
}

OverseasProductBasicInfoOutput represents overseas product basic info payload.

type OverseasProductBasicInfoResponse

type OverseasProductBasicInfoResponse struct {
	RtCD   string                         `json:"rt_cd"`
	MsgCD  string                         `json:"msg_cd"`
	Msg1   string                         `json:"msg1"`
	Output OverseasProductBasicInfoOutput `json:"output"`
}

OverseasProductBasicInfoResponse represents overseas product basic info response.

func (*OverseasProductBasicInfoResponse) IsSuccess

func (r *OverseasProductBasicInfoResponse) IsSuccess() bool

type ProductBasicInfoOutput

type ProductBasicInfoOutput struct {
	PdNo               string `json:"pdno"`
	PrdtTypeCD         string `json:"prdt_type_cd"`
	PrdtName           string `json:"prdt_name"`
	PrdtName120        string `json:"prdt_name120"`
	PrdtAbrvName       string `json:"prdt_abrv_name"`
	PrdtEngName        string `json:"prdt_eng_name"`
	PrdtEngName120     string `json:"prdt_eng_name120"`
	PrdtEngAbrvName    string `json:"prdt_eng_abrv_name"`
	StdPdNo            string `json:"std_pdno"`
	ShtnPdNo           string `json:"shtn_pdno"`
	PrdtSaleStatCD     string `json:"prdt_sale_stat_cd"`
	PrdtRiskGradCD     string `json:"prdt_risk_grad_cd"`
	PrdtClsfCD         string `json:"prdt_clsf_cd"`
	PrdtClsfName       string `json:"prdt_clsf_name"`
	SaleStrtDt         string `json:"sale_strt_dt"`
	SaleEndDt          string `json:"sale_end_dt"`
	WrapAsstTypeCD     string `json:"wrap_asst_type_cd"`
	IvstPrdtTypeCD     string `json:"ivst_prdt_type_cd"`
	IvstPrdtTypeCDName string `json:"ivst_prdt_type_cd_name"`
	FrstErlmDt         string `json:"frst_erlm_dt"`
}

ProductBasicInfoOutput represents generic product basic info payload.

type ProductBasicInfoResponse

type ProductBasicInfoResponse struct {
	RtCD   string                 `json:"rt_cd"`
	MsgCD  string                 `json:"msg_cd"`
	Msg1   string                 `json:"msg1"`
	Output ProductBasicInfoOutput `json:"output"`
}

ProductBasicInfoResponse represents product basic info response (search-info).

func (*ProductBasicInfoResponse) IsSuccess

func (r *ProductBasicInfoResponse) IsSuccess() bool

type QuoteResponse

type QuoteResponse struct {
	RetCode string `json:"rt_cd"`
	MsgCode string `json:"msg_cd"`
	Msg1    string `json:"msg1"`
	Output  struct {
		StockCode      string `json:"stck_shrn_iscd"` // 종목코드
		PrdyVrss       string `json:"prdy_vrss"`      // 전일대비
		PrdyVrssSign   string `json:"prdy_vrss_sign"` // 전일대비부호
		PrdyCtrt       string `json:"prdy_ctrt"`      // 전일대비율
		StckPrpr       string `json:"stck_prpr"`      // 현재가
		StckOprc       string `json:"stck_oprc"`      // 시가
		StckHgpr       string `json:"stck_hgpr"`      // 고가
		StckLwpr       string `json:"stck_lwpr"`      // 저가
		StckMxpr       string `json:"stck_mxpr"`      // 상한가
		StckLlam       string `json:"stck_llam"`      // 하한가
		AccTrVol       string `json:"acml_vol"`       // 누적거래량
		AccTrPbmn      string `json:"acml_tr_pbmn"`   // 누적거래대금
		StckSdpr       string `json:"stck_sdpr"`      // 기준가
		PrdyVol        string `json:"prdy_vol"`       // 전일거래량
		StckFcam       string `json:"stck_fcam"`      // 액면가
		AscnLmtPriceRt string `json:"ascn_lmt_price"` // 상승제한가
		DscnLmtPriceRt string `json:"dscn_lmt_price"` // 하락제한가
		HtsKorIsnm     string `json:"hts_kor_isnm"`   // 종목명
	} `json:"output"`
}

QuoteResponse represents KIS quote response

type RawResponse added in v0.6.0

type RawResponse struct {
	RtCD         string      `json:"rt_cd"`
	MsgCD        string      `json:"msg_cd"`
	Msg1         string      `json:"msg1"`
	Output       interface{} `json:"output,omitempty"`
	Output1      interface{} `json:"output1,omitempty"`
	Output2      interface{} `json:"output2,omitempty"`
	CtxAreaFK100 string      `json:"ctx_area_fk100,omitempty"`
	CtxAreaNK100 string      `json:"ctx_area_nk100,omitempty"`
	CtxAreaFK200 string      `json:"ctx_area_fk200,omitempty"`
	CtxAreaNK200 string      `json:"ctx_area_nk200,omitempty"`
	Keyb         string      `json:"keyb,omitempty"`
}

RawResponse is a flexible envelope for KIS APIs that return varying output schemas.

func (*RawResponse) IsSuccess added in v0.6.0

func (r *RawResponse) IsSuccess() bool

type StockBalanceOutput

type StockBalanceOutput struct {
	PdNo         string `json:"pdno"`           // 종목코드
	PrdtName     string `json:"prdt_name"`      // 상품명
	HldgQty      string `json:"hldg_qty"`       // 보유수량
	OrdPsblQty   string `json:"ord_psbl_qty"`   // 주문가능수량
	PchmAvgPric  string `json:"pchs_avg_pric"`  // 매입평균가격
	Prpr         string `json:"prpr"`           // 현재가
	PrprTprt     string `json:"prpr_tprt"`      // 현재가 구분
	EvluPflsAmt  string `json:"evlu_pfls_amt"`  // 평가손익금액
	EvluPflsRt   string `json:"evlu_pfls_rt"`   // 평가손익율
	EvluAmt      string `json:"evlu_amt"`       // 평가금액
	PchmAmt      string `json:"pchm_amt"`       // 매입금액
	HldgQtyRatio string `json:"hldg_qty_ratio"` // 보유비중
}

StockBalanceOutput represents a single stock position

type StockBalanceResponse

type StockBalanceResponse struct {
	RtCD    string                `json:"rt_cd"`
	MsgCD   string                `json:"msg_cd"`
	Msg1    string                `json:"msg1"`
	Output1 []StockBalanceOutput  `json:"output1"` // 보유 종목 리스트
	Output2 []StockBalanceSummary `json:"output2"` // 계좌 요약
}

StockBalanceResponse represents KIS stock balance inquiry response

func (*StockBalanceResponse) IsSuccess

func (r *StockBalanceResponse) IsSuccess() bool

type StockBalanceSummary

type StockBalanceSummary struct {
	DnpspCblAmt  string `json:"dnca_tot_amt"`       // 예수금총액
	NxdyExccAmt  string `json:"nxdy_excc_amt"`      // 익일정산금액
	PrvsRcdlExcc string `json:"prvs_rcdl_excc"`     // 가수도정산금액
	CmaEvluAmt   string `json:"cma_evlu_amt"`       // CMA평가금액
	BfmBnysTotAm string `json:"bfdy_buy_amt"`       // 전일매수금액
	ThdtBuyAmt   string `json:"thdt_buy_amt"`       // 금일매수금액
	NxdySellAmt  string `json:"nxdy_auto_rdpt_amt"` // 익일자동상환금액
	DpsplTotAmt  string `json:"tot_evlu_amt"`       // 총평가금액
	PchsAmtSmtl  string `json:"pchs_amt_smtl_amt"`  // 매입금액합계금액
	EvluAmtSmtl  string `json:"evlu_amt_smtl_amt"`  // 평가금액합계금액
	EvluPflsSm   string `json:"evlu_pfls_smtl_amt"` // 평가손익합계금액
	TotEvluPfls  string `json:"tot_evlu_pfls_amt"`  // 총평가손익금액
	TotStlnSlCa  string `json:"tot_stln_slng_chgs"` // 총대출금액
	EvluErngRt   string `json:"evlu_erng_rt"`       // 평가수익율
}

StockBalanceSummary represents account balance summary

type StockBasicInfoOutput

type StockBasicInfoOutput struct {
	PdNo                 string `json:"pdno"`
	PrdtTypeCD           string `json:"prdt_type_cd"`
	MketIDCD             string `json:"mket_id_cd"`
	SctyGrpIDCD          string `json:"scty_grp_id_cd"`
	ExcgDvsnCD           string `json:"excg_dvsn_cd"`
	PrdtName             string `json:"prdt_name"`
	PrdtName120          string `json:"prdt_name120"`
	PrdtAbrvName         string `json:"prdt_abrv_name"`
	PrdtEngName          string `json:"prdt_eng_name"`
	PrdtEngName120       string `json:"prdt_eng_name120"`
	PrdtEngAbrvName      string `json:"prdt_eng_abrv_name"`
	StdPdNo              string `json:"std_pdno"`
	PrdtClsfCD           string `json:"prdt_clsf_cd"`
	PrdtClsfName         string `json:"prdt_clsf_name"`
	StdIdstClsfCDName    string `json:"std_idst_clsf_cd_name"`
	IdxBztpLclsCDName    string `json:"idx_bztp_lcls_cd_name"`
	IdxBztpMclsCDName    string `json:"idx_bztp_mcls_cd_name"`
	IdxBztpSclsCDName    string `json:"idx_bztp_scls_cd_name"`
	TrStopYN             string `json:"tr_stop_yn"`
	LstgAbolDt           string `json:"lstg_abol_dt"`
	SctsMketLstgDt       string `json:"scts_mket_lstg_dt"`
	KosdaqMketLstgDt     string `json:"kosdaq_mket_lstg_dt"`
	CpttTradTrPsblYN     string `json:"cptt_trad_tr_psbl_yn"`
	NxtTrStopYN          string `json:"nxt_tr_stop_yn"`
	StdPdNoShort         string `json:"shtn_pdno"`
	PrdtSaleStatCD       string `json:"prdt_sale_stat_cd"`
	PrdtRiskGradCD       string `json:"prdt_risk_grad_cd"`
	StdIdstClsfCD        string `json:"std_idst_clsf_cd"`
	LstgStqt             string `json:"lstg_stqt"`
	ThdtClpr             string `json:"thdt_clpr"`
	BfdyClpr             string `json:"bfdy_clpr"`
	FrbdMketLstgDt       string `json:"frbd_mket_lstg_dt"`
	FrbdMketLstgAbolDt   string `json:"frbd_mket_lstg_abol_dt"`
	SctsMketLstgAbolDt   string `json:"scts_mket_lstg_abol_dt"`
	KosdaqMketLstgAbolDt string `json:"kosdaq_mket_lstg_abol_dt"`
}

StockBasicInfoOutput represents domestic stock basic info payload.

type StockBasicInfoResponse

type StockBasicInfoResponse struct {
	RtCD   string               `json:"rt_cd"`
	MsgCD  string               `json:"msg_cd"`
	Msg1   string               `json:"msg1"`
	Output StockBasicInfoOutput `json:"output"`
}

StockBasicInfoResponse represents domestic stock basic info response (search-stock-info).

func (*StockBasicInfoResponse) IsSuccess

func (r *StockBasicInfoResponse) IsSuccess() bool

type StockDailyPriceOutput

type StockDailyPriceOutput struct {
	StckBsopDate string `json:"stck_bsop_date"` // 주식 영업 일자
	StckClpr     string `json:"stck_clpr"`      // 주식 종가
	StckOprc     string `json:"stck_oprc"`      // 주식 시가
	StckHgpr     string `json:"stck_hgpr"`      // 주식 최고가
	StckLwpr     string `json:"stck_lwpr"`      // 주식 최저가
	AcmlVol      string `json:"acml_vol"`       // 누적 거래량
	AcmlTrPbmn   string `json:"acml_tr_pbmn"`   // 누적 거래 대금
	PrdyVrss     string `json:"prdy_vrss"`      // 전일 대비
	PrdyVrssSign string `json:"prdy_vrss_sign"` // 전일 대비 부호
}

StockDailyPriceOutput represents daily OHLCV data

type StockDailyPriceResponse

type StockDailyPriceResponse struct {
	RtCD    string                  `json:"rt_cd"`
	MsgCD   string                  `json:"msg_cd"`
	Msg1    string                  `json:"msg1"`
	Output  []StockDailyPriceOutput `json:"output,omitempty"`
	Output1 []StockDailyPriceOutput `json:"output1,omitempty"`
	Output2 map[string]string       `json:"output2,omitempty"`
}

StockDailyPriceResponse represents KIS daily price inquiry response

func (*StockDailyPriceResponse) IsSuccess

func (r *StockDailyPriceResponse) IsSuccess() bool

func (*StockDailyPriceResponse) Rows added in v0.6.0

Rows returns normalized daily rows regardless of output/output1 variant.

type StockPriceOutput

type StockPriceOutput struct {
	StckPrpr     string `json:"stck_prpr"`      // 주식 현재가
	PrdyVrss     string `json:"prdy_vrss"`      // 전일 대비
	PrdyVrssSign string `json:"prdy_vrss_sign"` // 전일 대비 부호
	PrdyCtrt     string `json:"prdy_ctrt"`      // 전일 대비율
	AcmlVol      string `json:"acml_vol"`       // 누적 거래량
	AcmlTrPbmn   string `json:"acml_tr_pbmn"`   // 누적 거래 대금
	StckOprc     string `json:"stck_oprc"`      // 주식 시가
	StckHgpr     string `json:"stck_hgpr"`      // 주식 최고가
	StckLwpr     string `json:"stck_lwpr"`      // 주식 최저가
	StckMxpr     string `json:"stck_mxpr"`      // 주식 상한가
	StckLlam     string `json:"stck_llam"`      // 주식 하한가
	PrdyVol      string `json:"prdy_vol"`       // 전일 거래량
}

StockPriceOutput represents stock price data

type StockPriceResponse

type StockPriceResponse struct {
	RtCD    string           `json:"rt_cd"`   // 성공 실패 여부 (0: 성공)
	MsgCD   string           `json:"msg_cd"`  // 응답코드
	Msg1    string           `json:"msg1"`    // 응답메세지
	Output  StockPriceOutput `json:"output"`  // 응답상세
	Output1 StockPriceOutput `json:"output1"` // 응답상세 (일부 API는 output1 사용)
}

StockPriceResponse represents KIS stock price inquiry response

func (*StockPriceResponse) IsSuccess

func (r *StockPriceResponse) IsSuccess() bool

IsSuccess checks if response is successful

type StockRvseCnclCandidate

type StockRvseCnclCandidate struct {
	ODNo         string `json:"odno"`
	OrgnODNo     string `json:"orgn_odno"`
	OrdGnoBrno   string `json:"ord_gno_brno"`
	OrdDvsn      string `json:"ord_dvsn"`
	OrdQty       string `json:"ord_qty"`
	OrdUNPR      string `json:"ord_unpr"`
	PsblQty      string `json:"psbl_qty"`
	ExcgIDDvsnCD string `json:"excg_id_dvsn_cd"`
}

StockRvseCnclCandidate represents one modifiable/cancellable order row.

type StockRvseCnclResponse

type StockRvseCnclResponse struct {
	RtCD         string                   `json:"rt_cd"`
	MsgCD        string                   `json:"msg_cd"`
	Msg1         string                   `json:"msg1"`
	Output       []StockRvseCnclCandidate `json:"output"`
	CtxAreaFK100 string                   `json:"ctx_area_fk100"`
	CtxAreaNK100 string                   `json:"ctx_area_nk100"`
}

StockRvseCnclResponse represents KIS response for inquire-psbl-rvsecncl.

func (*StockRvseCnclResponse) IsSuccess

func (r *StockRvseCnclResponse) IsSuccess() bool

type TokenManager

type TokenManager interface {
	GetToken(appKey string) (string, time.Time, bool)
	SetToken(appKey, token string, expiresAt time.Time) error
	WaitForAuth(appKey string)
}

TokenManager defines token cache and token-issuance throttling behavior. Custom implementations can be injected into Client/Adapter constructors.

func GetTokenManager

func GetTokenManager() TokenManager

GetTokenManager returns the global token manager. The default implementation is file-backed.

type TokenResponse

type TokenResponse struct {
	AccessToken           string `json:"access_token"`
	AccessTokenExpired    string `json:"access_token_token_expired"`
	TokenType             string `json:"token_type"`
	ExpiresIn             int    `json:"expires_in"`
	AccessTokenExpiresStr string `json:"access_token_expires"`
}

TokenResponse represents the KIS token response

type VolumeRankParams added in v0.6.0

type VolumeRankParams struct {
	MarketDiv       string
	ScreenDiv       string
	InputISCD       string
	DivClsCode      string
	BlngClsCode     string
	TrgtClsCode     string
	TrgtExlsClsCode string
	InputPrice1     string
	InputPrice2     string
	VolCnt          string
	InputDate1      string
}

VolumeRankParams are request params for domestic volume rank API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL