Open Trading API

v1.0.0Finance & Fintechstable

Korea Investment & Securities Open API Github

ai-tradingapi-samplesautotradechatgptclaude
Share:
1,407
Stars
0
Downloads
0
Weekly
0/5

What is Open Trading API?

Open Trading API is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to korea investment & securities open api github

Korea Investment & Securities Open API Github

This server falls under the Finance & Fintech category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Korea Investment & Securities Open API Github

Use Cases

Korea Investment securities trading API
Automated trading and investment operations
koreainvestment

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx open-trading-api

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Open Trading API

The Korea Investment & Securities Open Trading API repository provides official Python sample code and an MCP-based AI trading toolkit for developers integrating with the KIS (Korea Investment & Securities) Open API. It covers REST and WebSocket access for domestic stocks, bonds, futures/options, overseas stocks, ETFs, and ELWs — with LLM-optimized single-function samples in examples_llm/ and full integration examples in examples_user/. Quantitative developers and automated trading engineers use it to build AI-driven Korean market trading bots, backtest strategies with QuantConnect Lean, and let LLM agents directly call trading APIs via the included MCP server.

Prerequisites

  • Python 3.11 or later
  • uv package manager (recommended) or pip
  • A Korea Investment & Securities account with Open API service activated at apiportal.koreainvestment.com
  • An App Key and App Secret from the KIS Developer portal (separate keys for paper trading and live trading)
  • An MCP-compatible AI client such as Claude Desktop or Claude Code for the MCP integration
1

Apply for KIS Open API access

You must have a KIS brokerage account and apply for Open API access at the KIS Developer Portal. After approval, generate your App Key and App Secret for both paper trading (모의투자) and live trading (실전투자) environments.

# Visit: https://apiportal.koreainvestment.com/about-howto
2

Clone the repository and install dependencies

Clone the open-trading-api repository and install Python dependencies using uv. The uv sync command reads pyproject.toml and installs everything in one step.

git clone https://github.com/koreainvestment/open-trading-api
cd open-trading-api

# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install project dependencies
uv sync
3

Configure kis_devlp.yaml with your API credentials

Edit the kis_devlp.yaml configuration file in the project root. Fill in your App Key, App Secret, account number, and whether you are using paper trading or live trading mode. This file is read by the shared kis_auth.py authentication module.

# Edit kis_devlp.yaml:
# app_key: your-app-key-here
# app_secret: your-app-secret-here
# account_no: your-account-number
# is_paper_trading: true  # set false for live trading
4

Test authentication and token generation

Run the authentication example to verify your credentials and generate an access token. The token is cached and reused for subsequent API calls.

# Using uv
uv run python examples_llm/kis_auth.py

# Or: python examples_llm/kis_auth.py (with venv activated)
5

Run a sample API call

Try an LLM-optimized single-function sample to verify end-to-end connectivity. For example, query the current price of a domestic stock.

# Domestic stock price inquiry
uv run python examples_llm/domestic_stock/inquire_price/inquire_price.py
6

Connect the MCP server to your AI client

The MCP/ directory contains the KIS Code Assistant and Trading MCP server. Add it to your MCP client configuration to allow an LLM agent to call trading APIs and query market data directly.

Open Trading API Examples

Client configuration

Add the KIS Open Trading API MCP server to Claude Desktop. Your App Key, App Secret, and account number are passed as environment variables.

{
  "mcpServers": {
    "open-trading-api": {
      "command": "npx",
      "args": ["open-trading-api"],
      "env": {
        "KIS_APP_KEY": "your-app-key-here",
        "KIS_APP_SECRET": "your-app-secret-here",
        "KIS_ACCOUNT_NO": "your-account-number",
        "KIS_IS_PAPER_TRADING": "true"
      }
    }
  }
}

Prompts to try

These prompts work with an LLM agent connected to the KIS Open Trading API MCP server.

- "Fetch the current price and trading volume for Samsung Electronics (005930) on the KRX."
- "Place a paper-trading buy order for 10 shares of Kakao (035720) at the current market price."
- "Get my current portfolio balance and show unrealized gains and losses for each position."
- "Stream real-time price ticks for KOSPI 200 index futures via WebSocket for the next 60 seconds."
- "Query the overseas stock price for Apple (AAPL) on the NASDAQ using the KIS overseas API."

Troubleshooting Open Trading API

Access token generation fails with an authentication error

Verify that your App Key and App Secret in kis_devlp.yaml exactly match what is shown in the KIS Developer Portal. Also confirm that the Open API service is activated on your account — there is sometimes a delay of several hours after initial application before access is granted.

API calls succeed in paper trading but fail with errors in live trading

Paper trading (모의투자) and live trading (실전투자) use different App Keys. Ensure you have generated a separate App Key for live trading and have set 'is_paper_trading: false' in kis_devlp.yaml. Some API endpoints also differ between the two environments.

WebSocket connection disconnects after a short period

KIS WebSocket connections require periodic keep-alive messages (PINGPONG). The examples_user/*_functions_ws.py files include the correct keep-alive handling. If you are building a custom WebSocket client, implement the PINGPONG response as documented in the KIS API portal's WebSocket guide.

Frequently Asked Questions about Open Trading API

What is Open Trading API?

Open Trading API is a Model Context Protocol (MCP) server that korea investment & securities open api github It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Open Trading API?

Follow the installation instructions on the Open Trading API GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Open Trading API?

Open Trading API works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Open Trading API free to use?

Yes, Open Trading API is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Finance & Fintech MCP Servers

Explore all finance & fintech servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "open-trading-api": { "command": "npx", "args": ["-y", "open-trading-api"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Open Trading API?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides