Hacker News new | ask | show | jobs
Show HN: I made a LLM trade Stocks (github.com)
2 points by Adeeb0123 701 days ago
Hi HN! I made this as a side project, but astonishingly, it actually turned out to be profitable for me (Paper Trading).

In short, the algorithm works in the following way: 1. It discovers trending and profitable stocks provided by the Alpha Vantage API through news sentiment analysis.

2. Now, having a list of good stock options, it cherry-picks those stocks that it considers to be from "evergreen companies" that just can't go bankrupt and will result in profit in the long term.

3. It sets limit orders for the stocks by analyzing the past 7 days of their prices (all by using LLMs).

4. The stop-loss price is calculated as 95% of the current price to mitigate risks.

5. It then buys the largest amount of stocks that have the greatest spread (limit price - current price) out of the chosen stocks through a position-sizing algorithm.

6. It constantly monitors the positions and buys more stocks when the existing ones are sold off.

3 comments

I’ll be really curious if it’s still profitable for you in a month, a year, and over say 5 years.

My guess is passive investment in an index fund will beat this out by a wide margin, but I could be wrong.

Using AI, specifically Large Language Models (LLMs), for stock trading is a terrible idea for several reasons. Firstly, LLMs are not designed for real-time data analysis. Stock trading requires immediate response to market trends, news, and financial indicators, which LLMs are not equipped to handle. They excel at processing and generating human language but lack the capability for the rapid and continuous data analysis needed in stock trading.

Secondly, LLMs lack predictive accuracy. Stock trading relies on complex financial models and quantitative analysis that consider a multitude of factors like economic indicators, political events, and market sentiment. LLMs are trained on historical data and textual information, and they do not adapt well to new, unforeseen events that can significantly impact stock prices. Moreover, stock trading algorithms must ensure compliance with strict financial regulations, which LLMs cannot guarantee. Therefore, more specialized AI models are necessary for effective and reliable stock trading.

Interested in how it performed vs basic index funds?