{"id":37429,"date":"2024-11-01T09:57:31","date_gmt":"2024-11-01T09:57:31","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37429"},"modified":"2024-11-01T11:50:51","modified_gmt":"2024-11-01T11:50:51","slug":"python-automated-trading-development-kiwoom-securities-api-getting-stock-codes-and-korean-stock-names","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37429\/","title":{"rendered":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names"},"content":{"rendered":"<p><body><\/p>\n<p>Recently, algorithmic trading has become increasingly popular in the financial markets. In particular, many investors are interested in developing automated trading systems using Python. This course will explain in detail how to retrieve stock codes and Korean stock names using the Kiwoom Securities API.<\/p>\n<h2>1. What is an Automated Trading System?<\/h2>\n<p>An automated trading system is a system that automatically executes stock trades according to a specific algorithm. This system combines advanced analytical tools with automated trading functions, allowing trading to be conducted in the market without human intervention. Python is a very useful language for building such systems, as it supports a variety of libraries and APIs.<\/p>\n<h2>2. Introduction to the Kiwoom Securities API<\/h2>\n<p>The Kiwoom Securities API is a Java-based API provided by Kiwoom Securities, which can be integrated for use with various languages, such as Python. Through this API, you can query real-time stock information and execute trading orders. Additionally, it allows you to retrieve codes and names of specific stocks, making it easier to obtain the information necessary for investing.<\/p>\n<h3>2.1 Installing the Kiwoom Securities API<\/h3>\n<p>To use the Kiwoom Securities API, you first need to open a Kiwoom Securities account and apply for the API. After opening the account, download and install the API from the Kiwoom Securities website. Once the installation is complete, you can connect to the Kiwoom Securities API using Python.<\/p>\n<h3>2.2 Preparing to Use the Kiwoom API in Python<\/h3>\n<p>To use the Kiwoom API in Python, you need to install the <code>pyqt5<\/code> and <code>comtypes<\/code> packages. Use the command below to install the packages.<\/p>\n<pre><code>pip install pyqt5 comtypes<\/code><\/pre>\n<h2>3. Retrieving Stock Codes and Korean Stock Names<\/h2>\n<p>The process of retrieving stock codes and Korean stock names using the Kiwoom Securities API is as follows. First, you need to connect to the API and then request the information for the desired stock.<\/p>\n<h3>3.1 Setting Up Connection with the API<\/h3>\n<p>First, write the code to set up the connection with the Kiwoom Securities API. Refer to the example code below to set up the connection.<\/p>\n<pre><code>\nimport sys\nfrom PyQt5.QtWidgets import QApplication\nfrom PyQt5.QtCore import pyqtSlot, QObject\nimport win32com.client\n\nclass KiwoomAPI(QObject):\n    def __init__(self):\n        super().__init__()\n        self.kiwoom = win32com.client.Dispatch(\"KHOPENAPI.KHOpenAPICtrl.1\")\n        self.kiwoom.OnEventConnect.connect(self.connected)\n\n    @pyqtSlot(int)\n    def connected(self, err_code):\n        print(f\"Connected with error code: {err_code}\")\n\nif __name__ == \"__main__\":\n    app = QApplication(sys.argv)\n    kiwoom_api = KiwoomAPI()\n    kiwoom_api.kiwoom.CommConnect()\n    app.exec_()\n<\/code><\/pre>\n<h3>3.2 Retrieving Stock Codes and Korean Stock Names<\/h3>\n<p>After connecting to the server, write the code to retrieve stock codes and Korean stock names. Use the <code>CommGetData<\/code> function to request the data.<\/p>\n<pre><code>\ndef get_stock_info(self, stock_code):\n    data = self.kiwoom.CommGetData(\"\", \"OPT10001\", 0, \"0\", stock_code)\n    stock_name = data.split(';')[0]\n    return stock_name\n\nstock_code = \"005930\"  # Samsung Electronics\nstock_name = kiwoom_api.get_stock_info(stock_code)\nprint(f\"Stock Code: {stock_code}, Stock Name: {stock_name}\")\n<\/code><\/pre>\n<h4>3.3 Retrieving the List of All Stocks<\/h4>\n<p>There is also a method to retrieve a list of all stocks. Kiwoom Securities can return the entire stock list for a specific data code.<\/p>\n<pre><code>\ndef get_all_stocks(self):\n    stock_list = []\n    for i in range(0, 1000):  # Example: Looping through 1000 stocks\n        stock_code = self.kiwoom.CommGetData(\"\", \"OPT10001\", i, \"0\", \"\")\n        if stock_code == \"\":\n            break\n        stock_list.append(stock_code)\n\n    return stock_list\n\nall_stocks = kiwoom_api.get_all_stocks()\nfor stock in all_stocks:\n    print(stock)  # Print each stock code\n<\/code><\/pre>\n<h2>4. Conclusion<\/h2>\n<p>In this course, we examined how to retrieve stock codes and Korean stock names using the Kiwoom Securities API with Python. Based on this functionality, various automated trading systems can be built, which can be utilized for real-time data analysis and the establishment of trading strategies. Each investor will acquire the ability to respond to the market more efficiently through this.<\/p>\n<h2>5. References<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.kiwoom.com\" target=\"_blank\" rel=\"noopener\">Official Kiwoom Securities Website<\/a><\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/pyqt5\" target=\"_blank\" rel=\"noopener\">PyQt5 Documentation<\/a><\/li>\n<li><a href=\"https:\/\/pypi.org\/project\/comtypes\/\" target=\"_blank\" rel=\"noopener\">comtypes Documentation<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, algorithmic trading has become increasingly popular in the financial markets. In particular, many investors are interested in developing automated trading systems using Python. This course will explain in detail how to retrieve stock codes and Korean stock names using the Kiwoom Securities API. 1. What is an Automated Trading System? An automated trading system &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37429\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[147],"tags":[],"class_list":["post-37429","post","type-post","status-publish","format-standard","hentry","category-python-auto-trading"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37429\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Recently, algorithmic trading has become increasingly popular in the financial markets. In particular, many investors are interested in developing automated trading systems using Python. This course will explain in detail how to retrieve stock codes and Korean stock names using the Kiwoom Securities API. 1. What is an Automated Trading System? An automated trading system &hellip; \ub354 \ubcf4\uae30 &quot;python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37429\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:57:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:50:51+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names\",\"datePublished\":\"2024-11-01T09:57:31+00:00\",\"dateModified\":\"2024-11-01T11:50:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/\"},\"wordCount\":475,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Python Auto Trading\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37429\/\",\"name\":\"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:57:31+00:00\",\"dateModified\":\"2024-11-01T11:50:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37429\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37429\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37429\/","og_locale":"ko_KR","og_type":"article","og_title":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Recently, algorithmic trading has become increasingly popular in the financial markets. In particular, many investors are interested in developing automated trading systems using Python. This course will explain in detail how to retrieve stock codes and Korean stock names using the Kiwoom Securities API. 1. What is an Automated Trading System? An automated trading system &hellip; \ub354 \ubcf4\uae30 \"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names\"","og_url":"https:\/\/atmokpo.com\/w\/37429\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:57:31+00:00","article_modified_time":"2024-11-01T11:50:51+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37429\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37429\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names","datePublished":"2024-11-01T09:57:31+00:00","dateModified":"2024-11-01T11:50:51+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37429\/"},"wordCount":475,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Python Auto Trading"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37429\/","url":"https:\/\/atmokpo.com\/w\/37429\/","name":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:57:31+00:00","dateModified":"2024-11-01T11:50:51+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37429\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37429\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37429\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"python automated trading development, Kiwoom Securities API, getting stock codes and Korean stock names"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37429"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37429\/revisions"}],"predecessor-version":[{"id":37430,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37429\/revisions\/37430"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}