get_orders
Retrieve order history from Upbit cryptocurrency exchange. Filter orders by market, status, and pagination to manage trading activities.
Instructions
업비트에서 주문 내역을 조회합니다.
Args:
market (str, optional): 마켓 코드 (예: KRW-BTC)
state (str): 주문 상태 - wait(대기), done(완료), cancel(취소)
page (int): 페이지 번호
limit (int): 페이지당 주문 개수 (최대 100)
Returns:
list[dict]: 주문 내역
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market | No | ||
| state | No | wait | |
| page | No | ||
| limit | No |
Implementation Reference
- tools/get_orders.py:6-57 (handler)The main asynchronous handler function for the 'get_orders' tool. It fetches order history from the Upbit API using provided parameters like market, state, page, and limit. Includes input validation via type hints, error handling, and logging via context.async def get_orders( market: Optional[str] = None, state: Literal["wait", "done", "cancel"] = "wait", page: int = 1, limit: int = 100, ctx: Context = None ) -> list[dict]: """ 업비트에서 주문 내역을 조회합니다. Args: market (str, optional): 마켓 코드 (예: KRW-BTC) state (str): 주문 상태 - wait(대기), done(완료), cancel(취소) page (int): 페이지 번호 limit (int): 페이지당 주문 개수 (최대 100) Returns: list[dict]: 주문 내역 """ if not UPBIT_ACCESS_KEY: if ctx: ctx.error("API 키가 설정되지 않았습니다. .env 파일에 UPBIT_ACCESS_KEY와 UPBIT_SECRET_KEY를 설정해주세요.") return [{"error": "API 키가 설정되지 않았습니다."}] url = f"{API_BASE}/orders" query_params = { 'state': state, 'page': str(page), 'limit': str(limit) } if market: query_params['market'] = market headers = { "Authorization": f"Bearer {generate_upbit_token(query_params)}" } if ctx: ctx.info(f"주문 내역 조회 중: 상태={state}") async with httpx.AsyncClient() as client: try: res = await client.get(url, params=query_params, headers=headers) if res.status_code != 200: if ctx: ctx.error(f"업비트 API 오류: {res.status_code} - {res.text}") return [{"error": f"업비트 API 오류: {res.status_code}"}] return res.json() except Exception as e: if ctx: ctx.error(f"API 호출 중 오류 발생: {str(e)}") return [{"error": f"API 호출 중 오류 발생: {str(e)}"}]
- main.py:47-47 (registration)Registers the get_orders function as an MCP tool using the FastMCP tool decorator.mcp.tool()(get_orders)
- main.py:11-11 (registration)Imports the get_orders handler function for registration.from tools.get_orders import get_orders