inquery-stock-info
Retrieve daily stock price data from Korea Investment & Securities for specified symbols and date ranges to analyze market trends.
Instructions
Get daily stock price information from Korea Investment & Securities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| start_date | Yes | ||
| end_date | Yes |
Implementation Reference
- server.py:517-557 (handler)The main asynchronous handler function for the 'inquery-stock-info' tool. It fetches daily stock price information from the Korea Investment & Securities (KIS) API using the provided stock symbol, start date, and end date. Uses httpx for API calls, retrieves auth token, prepares params, and returns the JSON response.async def inquery_stock_info(symbol: str, start_date: str, end_date: str): """ Get daily stock price information from Korea Investment & Securities Args: symbol: Stock symbol (e.g. "005930") start_date: Start date (YYYYMMDD) end_date: End date (YYYYMMDD) Returns: Dictionary containing daily stock price information """ async with httpx.AsyncClient() as client: token = await get_access_token(client) # Prepare request data request_data = { "FID_COND_MRKT_DIV_CODE": "J", # 시장구분 "FID_INPUT_ISCD": symbol, # 종목코드 "FID_INPUT_DATE_1": start_date, # 시작일자 "FID_INPUT_DATE_2": end_date, # 종료일자 "FID_PERIOD_DIV_CODE": "D", # 기간분류코드 "FID_ORG_ADJ_PRC": "0", # 수정주가원구분 } response = await client.get( f"{TrIdManager.get_domain('stock_info')}{STOCK_INFO_PATH}", headers={ "content-type": CONTENT_TYPE, "authorization": f"{AUTH_TYPE} {token}", "appkey": os.environ["KIS_APP_KEY"], "appsecret": os.environ["KIS_APP_SECRET"], "tr_id": TrIdManager.get_tr_id("stock_info") }, params=request_data ) if response.status_code != 200: raise Exception(f"Failed to get stock info: {response.text}") return response.json()
- server.py:513-516 (registration)The @mcp.tool decorator that registers the 'inquery-stock-info' tool with FastMCP, specifying its name and description.@mcp.tool( name="inquery-stock-info", description="Get daily stock price information from Korea Investment & Securities", )
- server.py:41-41 (helper)API endpoint path constant used by the tool for daily stock price inquiry.STOCK_INFO_PATH = "/uapi/domestic-stock/v1/quotations/inquire-daily-price" # 일별주가조회
- server.py:80-80 (helper)Transaction ID (TR_ID) for the stock_info operation in the real account TrIdManager."stock_info": "FHKST01010400", # 일별주가조회