(로또 사는 아빠) 살림 하는 엄마

Building an Automated Trading Program using Korea Investment & Securities API

Created: 2024-04-22

Created: 2024-04-22 23:44

I recently had to develop an API for Korea Investment & Securities. With the recent strong recovery of overseas stocks, especially US stocks, I've become more interested in automated trading through programming. I've been focused on Kiwoom Securities' automated trading program, so I hadn't paid much attention to Korea Investment & Securities until I had to help a friend. This experience prompted me to take a closer look, and I'm writing a short review of my findings.


Advantages of the Korea Investment & Securities API

Building an Automated Trading Program using Korea Investment & Securities API

Explanation of the Korea Investment & Securities KIS Developers Structure


First, let's look at the advantages of the Korea Investment & Securities API as described on Wikidocs.

Building an Automated Trading Program using Korea Investment & Securities API

Comparative Explanation of APIs


If you're not a programmer, would you understand the comparison table and think, "Ah, that's why the Korea Investment & Securities (New) Open API is good!"? Since Wikidocs is written assuming the reader is a programmer, it feels more like an explanation for developers.

Next, here's a screenshot from Jocoding's YouTube channel.


Building an Automated Trading Program using Korea Investment & Securities API

Excerpt from Jocoding's YouTube content - Advantages of Korea Investment & Securities API

  • Only domestic API that uses REST API and Websocket methods
    • No program installation required
    • Development environment agnostic - Windows, Mac, Linux, etc.
  • Only domestic API that allows for overseas stock investment
    • No currency exchange needed when using Integrated Securities Account
  • Provides detailed KIS Developer guidelines and sample code

These are the advantages they listed. The most noteworthy advantage is that it's the only domestic API that allows for overseas stock investment. While other securities firms will likely offer APIs for overseas stock investment in the future, Korea Investment & Securities is undoubtedly a pioneer in this space. I've been automating US stock trading since 2021, but I've been doing it not through an API but by handling Kiwoom Securities' HTS with RPA. Since it operates like a human interacting with the interface, there's a difference between the current price when it checks the current price and when it attempts to trade. (A 2-3 second delay occurs). I've always wished that the logic I've come up with could execute more precisely. The availability of an API for overseas stock investment means I can implement my trading strategy more accurately.

Furthermore, the fact that it's the only domestic API using REST API and Websocket methods is a huge advantage. I also use the Kiwoom Securities domestic API, but I have to install Kiwoom Securities' program to develop the API and can only develop in 32-bit Python. Naturally, development and operation have to be done in a Windows environment. When you compare it like this, the Kiwoom Securities domestic API might seem quite restrictive, but since most securities firms are in a similar situation, it doesn't feel like a major constraint. In that sense, the Korea Investment & Securities API has a significant advantage.


  • I can easily run the program I created on a different PC.
  • It can run on Linux, allowing for more stable operation.
    (Windows environments are prone to unexpected issues like random restarts and updates...)


The logic I've developed since 2021 is still working well, but I wish it could execute more accurately and be less impacted by the PC environment. The Korea Investment & Securities API seems like a potential solution. These two reasons alone are enough for me to consider switching, but the current obstacle is the commission fees.

Building an Automated Trading Program using Korea Investment & Securities API

Korea Investment & Securities US Overseas Stock Trading Commission


Kiwoom Securities' commission fee is 0.07%, making Korea Investment & Securities appealing from a fee perspective. However, I'm currently benefiting from a 0.044% commission rate at Kiwoom Securities. Other securities companies also offer frequent commission fee promotions. ㅠ_ㅠ (My trading strategy makes switching too difficult.) Regardless, even considering all of these factors, the Korea Investment & Securities API is still incredibly attractive to those who develop and use automated trading programs like me.


Conclusion

We've explored the advantages of the Korea Investment & Securities API and considered potentially modifying my existing logic. However, my immediate reason for developing the Korea Investment & Securities API is to help a friend. Out of many securities firms, they chose Korea Investment & Securities, so I'll learn how to automate their desired trading logic using the API and develop it. The next step is to gather information about developing the Korea Investment & Securities API. Let's go!

Comments0