kiwoom

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseURLReal is Kiwoom production REST domain.
	BaseURLReal = "https://api.kiwoom.com"
	// BaseURLSandbox is Kiwoom mock REST domain.
	BaseURLSandbox = "https://mockapi.kiwoom.com"
)
View Source
const (
	PathPrefixAPI      = "/api"
	PathPrefixAPISlash = "/api/"
)

Kiwoom REST path prefixes.

View Source
const (
	PathStockInfo   = "/api/dostk/stkinfo"
	PathMarketCond  = "/api/dostk/mrkcond"
	PathForeignInst = "/api/dostk/frgnistt"
	PathRankingInfo = "/api/dostk/rkinfo"
	PathSector      = "/api/dostk/sect"
	PathELW         = "/api/dostk/elw"
	PathETF         = "/api/dostk/etf"
	PathTheme       = "/api/dostk/thme"
	PathSLB         = "/api/dostk/slb"
	PathShortSell   = "/api/dostk/shsa"
	PathAccount     = "/api/dostk/acnt"
	PathChart       = "/api/dostk/chart"
	PathOrder       = "/api/dostk/ordr"
	PathCreditOrder = "/api/dostk/crdordr" //nolint:gosec // G101: URL path constant, not a credential
	PathWebSocket   = "/api/dostk/websocket"
)

Kiwoom endpoint paths.

Variables

This section is empty.

Functions

func CaptureEndpointPage added in v0.28.0

func CaptureEndpointPage(ctx context.Context, continuation kiwoomspecs.Continuation, call func(context.Context) (any, error)) (*kiwoomspecs.EndpointPage, error)

CaptureEndpointPage preserves the existing typed endpoint preparation and validation while collecting the headers from its single HTTP request. The capture belongs to this invocation and is never stored on the shared client.

func GetTokenManager

func GetTokenManager() tokencache.Manager

GetTokenManager returns the global token manager.

Types

type Client

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

Client is a Kiwoom HTTP client with token caching and API-id routing.

func NewClientWithTokenManager

func NewClientWithTokenManager(sandbox bool, tm tokencache.Manager) *Client

NewClientWithTokenManager creates a client with injected token manager.

func (*Client) Authenticate

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

Authenticate issues or reuses an OAuth token.

func (*Client) CallDocumentedEndpoint added in v0.8.0

func (c *Client) CallDocumentedEndpoint(
	ctx context.Context,
	apiID, path string,
	body any,
	allowedCodes ...int,
) (any, error)

CallDocumentedEndpoint executes a documented Kiwoom REST endpoint. It returns generated response type for known documented path/api_id.

func (*Client) CancelStockOrder

CancelStockOrder cancels order through kt10003.

func (*Client) InquireBalance

func (c *Client) InquireBalance(ctx context.Context, exchange string) (*kiwoomspecs.KiwoomApiDostkAcntKt00005Response, error)

InquireBalance fetches kt00005.

func (*Client) InquireBalanceByRequest added in v0.10.0

InquireBalanceByRequest fetches kt00005.

func (*Client) InquireBondPositions added in v0.6.0

func (c *Client) InquireBondPositions(ctx context.Context, exchange string) (*kiwoomspecs.KiwoomApiDostkAcntKt00018Response, error)

InquireBondPositions is a convenience wrapper for bond holdings.

func (*Client) InquireChangeRateRank added in v0.6.0

InquireChangeRateRank fetches ka10027.

func (*Client) InquireDailyPrice

func (c *Client) InquireDailyPrice(
	ctx context.Context,
	symbol, baseDate string,
) (*kiwoomspecs.KiwoomApiDostkChartKa10081Response, error)

InquireDailyPrice fetches daily candles from ka10081.

func (*Client) InquireDailyPriceByRequest added in v0.10.0

InquireDailyPriceByRequest fetches daily candles from ka10081.

func (*Client) InquireExecutionInfo added in v0.6.0

InquireExecutionInfo fetches ka10003.

func (*Client) InquireInstrumentInfo

func (c *Client) InquireInstrumentInfo(
	ctx context.Context,
	symbol string,
) (*kiwoomspecs.KiwoomApiDostkStkinfoKa10100Response, error)

InquireInstrumentInfo fetches ka10100.

func (*Client) InquireInstrumentInfoByRequest added in v0.10.0

InquireInstrumentInfoByRequest fetches ka10100.

func (*Client) InquireInvestorByStock added in v0.6.0

InquireInvestorByStock fetches ka10059.

func (*Client) InquireInvestorByStockChart added in v0.6.0

InquireInvestorByStockChart fetches investor trend chart via ka10060.

func (*Client) InquireMonthlyPrice

func (c *Client) InquireMonthlyPrice(
	ctx context.Context,
	symbol, baseDate string,
) (*kiwoomspecs.KiwoomApiDostkChartKa10083Response, error)

InquireMonthlyPrice fetches monthly candles from ka10083.

func (*Client) InquireMonthlyPriceByRequest added in v0.10.0

InquireMonthlyPriceByRequest fetches monthly candles from ka10083.

func (*Client) InquireOrderBook added in v0.6.0

InquireOrderBook fetches ka10004.

func (*Client) InquireOrderExecutionDetail added in v0.6.0

InquireOrderExecutionDetail fetches kt00007.

func (*Client) InquireOrderExecutionStatus added in v0.6.0

InquireOrderExecutionStatus fetches kt00009.

func (*Client) InquireOrderExecutions

func (c *Client) InquireOrderExecutions(ctx context.Context, symbol string) (*kiwoomspecs.KiwoomApiDostkAcntKa10076Response, error)

InquireOrderExecutions fetches ka10076.

func (*Client) InquireOrderExecutionsByExchange added in v0.6.0

func (c *Client) InquireOrderExecutionsByExchange(
	ctx context.Context,
	symbol, exchangeType string,
) (*kiwoomspecs.KiwoomApiDostkAcntKa10076Response, error)

InquireOrderExecutionsByExchange fetches execution rows with explicit exchange scope.

func (*Client) InquireOrderExecutionsByRequest added in v0.10.0

InquireOrderExecutionsByRequest fetches ka10076.

func (*Client) InquireOrderableWithdrawable added in v0.6.0

InquireOrderableWithdrawable fetches kt00010.

func (*Client) InquirePositions

func (c *Client) InquirePositions(ctx context.Context, queryType, exchange string) (*kiwoomspecs.KiwoomApiDostkAcntKt00018Response, error)

InquirePositions fetches kt00018.

func (*Client) InquirePositionsByAsset added in v0.6.0

func (c *Client) InquirePositionsByAsset(
	ctx context.Context,
	queryType, exchange, stockBondType string,
) (*kiwoomspecs.KiwoomApiDostkAcntKt00018Response, error)

InquirePositionsByAsset fetches positions with optional stock/bond filter (e.g. 1=stock, 2=bond).

func (*Client) InquirePositionsByRequest added in v0.10.0

InquirePositionsByRequest fetches kt00018.

func (*Client) InquirePrice

InquirePrice fetches ka10001 and returns typed quote fields.

func (*Client) InquirePriceByRequest added in v0.10.0

InquirePriceByRequest fetches ka10001 and returns typed quote fields.

func (*Client) InquireSectorByPrice added in v0.6.0

InquireSectorByPrice fetches ka20002.

func (*Client) InquireSectorCurrent added in v0.6.0

InquireSectorCurrent fetches ka20001.

func (*Client) InquireTickChart added in v0.6.0

func (c *Client) InquireTickChart(
	ctx context.Context,
	symbol, baseDate string,
) (*kiwoomspecs.KiwoomApiDostkChartKa10079Response, error)

InquireTickChart fetches domestic tick chart via ka10079.

func (*Client) InquireTickChartByRequest added in v0.10.0

InquireTickChartByRequest fetches domestic tick chart via ka10079.

func (*Client) InquireUnsettledOrders

func (c *Client) InquireUnsettledOrders(ctx context.Context, symbol string) (*kiwoomspecs.KiwoomApiDostkAcntKa10075Response, error)

InquireUnsettledOrders fetches ka10075.

func (*Client) InquireUnsettledOrdersByExchange added in v0.6.0

func (c *Client) InquireUnsettledOrdersByExchange(
	ctx context.Context,
	symbol, exchangeType string,
) (*kiwoomspecs.KiwoomApiDostkAcntKa10075Response, error)

InquireUnsettledOrdersByExchange fetches unsettled orders with explicit exchange scope.

func (*Client) InquireUnsettledOrdersByRequest added in v0.10.0

InquireUnsettledOrdersByRequest fetches ka10075.

func (*Client) InquireVolumeRank added in v0.6.0

InquireVolumeRank fetches ka10030.

func (*Client) InquireWeeklyPrice

func (c *Client) InquireWeeklyPrice(
	ctx context.Context,
	symbol, baseDate string,
) (*kiwoomspecs.KiwoomApiDostkChartKa10082Response, error)

InquireWeeklyPrice fetches weekly candles from ka10082.

func (*Client) InquireWeeklyPriceByRequest added in v0.10.0

InquireWeeklyPriceByRequest fetches weekly candles from ka10082.

func (*Client) ModifyStockOrder

ModifyStockOrder modifies order through kt10002.

func (*Client) Name

func (c *Client) Name() string

Name returns broker name.

func (*Client) PlaceBuyOrder added in v0.10.0

PlaceBuyOrder places kt10000.

func (*Client) PlaceSellOrder added in v0.10.0

PlaceSellOrder places kt10001.

func (*Client) PlaceStockOrder

PlaceStockOrder places kt10000 (buy) or kt10001 (sell).

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string)

SetBaseURL overrides the API base URL. Primarily useful for tests or private/proxy deployments.

func (*Client) SetCredentials

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

SetCredentials sets app credentials on this client.

func (*Client) SetLogger added in v0.13.0

func (c *Client) SetLogger(l *slog.Logger)

SetLogger sets the logger for the client.

type FileTokenManager

type FileTokenManager struct {
	*filetoken.Manager
}

FileTokenManager stores tokens in memory and on 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 manager with optional fixed directory.

type StockOrderSide

type StockOrderSide string

StockOrderSide indicates buy/sell for order placement.

const (
	StockOrderSideBuy  StockOrderSide = "buy"
	StockOrderSideSell StockOrderSide = "sell"
)

type TokenResponse

type TokenResponse struct {
	ExpiresDT  string `json:"expires_dt"`
	TokenType  string `json:"token_type"`
	Token      string `json:"token"`
	ReturnCode any    `json:"return_code"`
	ReturnMsg  string `json:"return_msg"`
}

TokenResponse is Kiwoom OAuth token response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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