Skip to main content

My First Algorithmic Trading Experience

·878 words·5 mins· loading
Table of Contents

Intro
#

I’d heard plenty of stories about people making enough money from stocks to quit their jobs, but everyone around me seemed to have lost money, so I never had much interest in investing. Then I heard that Toss Securities was opening up its API, and for fun, I decided to build a news-based trading program.


Why News-Based Trading?
#

There were two reasons.

  • When people talk about algorithmic trading, it’s usually something like the 20-day moving average crossing the 60-day moving average, an RSI below 30 suggesting the stock might be oversold, something about order blocks, and so on…. Basically, combining technical indicators like these using a computer. But all I knew about trading was “buy low, sell high” so I chose a different approach.
  • The strategies above may be easier to execute with a computer, but they’re still things a human can do, even if a little more slowly. News-based trading, on the other hand, is all about reacting to good news ad placing an order even 1s faster, I figured this way where using a computer would give me the biggest advantage.

Architecture
#

The architecture is pretty simple - it doesn’t even have a DB

  1. Fetch news from various source whenever their CDN cashes refresh, then filter out anything that can be handled with code. (like using regex to exclude foreign companies, law firm lawsuit ads, and other irrelevant articles.)
  2. Send the filtered news to the AI along with the current market conditions, and have it return a Structured Output.
  3. If the AI decides to buy, place the order through the brokerage API and send a Telegram notification at the same time.

Decision Prompt
#

I used a prompt similar to the folowing:

You are a cold and rational trading analyst. The news we just received was available to Wall Street firms using paid APIs about two minutes earlier, but most retail traders have not seen it yet.

Over the last N minutes, the stock price moved from around $I to $J. During the same period, the Nasdaq, Dow, and other major indices moved by approximately ???%.

Above all else, avoiding losses is the highest priority. Protecting my capital matters more than chasing profits.

Tell me whether this looks like a trade with a reasonable chance of making money without getting caught in a pump-and-dump.

news-content

(Basically: losing money is the one thing I want to avoid, and since there are people who get the news about two minutes before I do, the stock may already have pumped by the time I see it. Decide whether it's still worth entering.)

The response came back as JSON containing a Korean summary of the news, an entry price, position size, take-profit level, stop loss level, and so on. forwarded that directly to Telegram and also used it to place the actual order. (i ignored the suggested position size, though, and hardcoded it to buy just one share.)

Results
#

In the end, I didn’t lose money, but were still too many unstable parts for me to put a significant amount of capital into it. Here are few examples.

The AI Got It Right, and the Stock Surged
#

Cuprina Holdings CUPR surged by around 500% after announcing FDA clearance on the 15th at around 10 PM. This is exactly the kind of move news-based trading is trying to catch. On top of the buying triggered by the positive news itself, short-term traders pile into the sudden spike, and money basically starts printing itself.

news

The AI Got It Right, but Then I Got Screwed
#

SaverOne 2014 SVRE initially surged on positive news, but shortly afterward, news of an equity offering came out and the stock ended up falling as much as 22%.

Even when the original news is genuinely good, the whole market can turn against you-or one comment from Trump can send everything crashing.

The AI Got It Wrong
#

Sometimes the news wasn’t particularly meaningful, or the AI interpreted bad news as good news. In those cases, you’re basically jumping onto a falling knife from the very top, and there’s no telling how much you could lose.

Spero Therapeutics SPRO announced that it had secured $105 million in non-dilutive financing. The AI latched onto the phrase Non-Dilutive and immediately decided it was a buy.

In reality, the company had received that money in exchange for giving up part of its future growth potential, and the stock ended up plunging.


Final
#

At this point, this is more of a fun project than a serious attempt to make money from stocks. But I don’t plan to stop here. I want improve it further and eventually let it trade with around KRW 1 million of real money.

One thing I noticed while testing it is that there are a lot of people thinking the same way I am. Within a minute of market-moving news being released, buying or selling pressure almost always starts moving heavily. The stock market may not be a zero-sum game, but at the very least, I need to be able to outperform those people.

3-Point
#

  1. I tried trading stocks with a computer.
  2. Just like in software development, blindly trusting AI is a stupid idea.
  3. Making easy money is hard.