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

Challenges in Developing the Korea Investment & Securities API

Created: 2024-04-23

Created: 2024-04-23 00:00

I've ended up writing less about Korean Investment Securities API development than I initially thought. While the content I wrote earlier was general and fundamental, the content I'm writing now details the difficulties and trial-and-error I encountered during the process and how I resolved them. Shall we start with the difficulties first?

Challenges in Developing the Korea Investment & Securities API

Stock trading is difficult, and developing a program to automate it is even more challenging..


Opening a Korean Investment Securities Account

The first challenge I faced after deciding to develop was likely a problem specific to me. ㅠ_ㅠ It was opening a Korean Investment Securities account. About two weeks prior, I opened a Hana Securities account for a similar reason, and as a result, I couldn't immediately create a non-face-to-face account. I had forgotten about the 20-day restriction period. However, I still needed to open an account, so I searched for nearby Korean Investment Securities branches and fortunately found one about 40 minutes away (?) and was able to open an account there.


ISA Account Transfer Failure Case +_+

Actually, I first attempted to open a non-face-to-face account. It was written that if I transferred my ISA account from another bank, it would somehow be processed immediately. I should have checked carefully, but I was in a hurry to open an account and just agreed to it. The account was easily created, the API application was successful, and I was happy to see that the domestic API test was working well, but...

I discovered that overseas stock trading required a separate application. I thought it would be automatic since the account was created, hahaha. I found out that I couldn't trade overseas stocks with an ISA account. Apparently, it's natural due to the nature of ISA accounts, but I didn't know much about them, and I still don't. I learned about the fact that overseas stock trading isn't possible with an ISA account for real this time.
Anyway, I visited a branch to open an account, and the ISA account was returned to the previous bank. (The previous bank? also called me and said that if I didn't agree, it would be returned. Anyway, the ISA account seemed to be a special account.)

Anyway, stock trading is always easy, but the process of opening an account, installing HTS and MTS, and setting them up to actually trade is quite difficult. But I did it, and through it, I was able to proceed with development.


Mock Trading Not Supported

The REST API was really easy to use because there were Postman examples. It was possible to immediately check the data request and receipt, and it could be directly converted to Python code through Postman. However, there were quite a few features that did not support mock trading. While they weren't critical features, it was inconvenient that I had to check them using a real trading account. Checking them in a real trading account wouldn't be a problem if I wasn't actually trading, but I felt psychologically pressured and the situation was inconvenient. I hope that Korean Investment Securities will improve these aspects in the future.


Websockets - Receiving Real-time Data

The next challenging part was receiving real-time data through websockets.
In this part, the logic for continuous reception is being executed, and I felt that I needed to modify it so that it wouldn't be affected and I could additionally send commands, but I couldn't find a way. This seems to be due to my lack of understanding of websockets, but also my overall lack of understanding of programming languages. If I find a solution later, I'll update it again.

Challenges in Developing the Korea Investment & Securities API

I don't understand websockets... Is it an infinite loop...? How do I properly connect events... and threads... Argh...


Trading Methodology - I Don't Know?!

Finally, understanding the trading methodology desired by the user was difficult. My trading methodology, the grid trading method, doesn't involve any buy/sell techniques. This is because it executes buy/sell orders based on values I've set. However, typical trading methods are designed to move according to various situations, so they need to make buy/sell decisions based on conditional values. They gather minute data, place moving averages, and use ranges like Bollinger Bands as criteria for buy/sell decisions. Technically, calculating conditional values is possible because the formula is set, but I have a fundamental question about why people trade using this method. And it's not fully resolved yet. It seems that the more I study stocks, the more difficult it becomes. ^^;; (It should be 50/50 when it goes up and down, but why am I always on the downside?!!!)

Challenges in Developing the Korea Investment & Securities API

I don't understand... why it goes up and down... when should I buy and sell...


There were probably many other difficulties besides these. But isn't it life to roll around and somehow find and solve problems? Next, I'll write about the trial-and-error process and alternatives for these difficulties. Fighting!!

Comments0