LLM Trading Agents

We introduce an experimental platform for trading agent systems based on Large Language Models (LLMs), with a focus on cost-efficient and small-scale profitable implementation. With many retail investors already using LLMs for decision-making, we are taking it one step further by creating fully automated trading models that use available LLMs. However, we still do not trust our own models, so we simulate an environment as close as possible to real-world conditions. To achieve this, we intend to display all model conditions and actions via our dashboard; however, we are unable to provide you with all our raw data due to legal restrictions.

Single LLM Agent Model

The Trading Agent combines an LLM with real-time market data to perform automated trading decisions on stocks of the S&P 500. It is designed with a clear focus on using only free resources, such as APIs, to mimic the behavior of a retail investor with limited resources. By integrating news analysis, historical context, and portfolio management, the agent makes informed decisions based on continuous information processing and analysis. Further, it aims to be profitable on a relatively small balance.

LLM Model (Gemini 2.5 Flash)

As the primary component, we utilize the Gemini 2.5 Flash model, which is accessible via the Google AI Studio API. It is responsible for orchestrating the entire Agent setup. Therefore, if available, the model is passed new news every 60 seconds. If a news item is passed, the model is told to perform the following six steps before passing the information to the vector model and database for later usage:

  1. Extraction of key messages – summary of relevant key points
  2. Sentiment analysis – classification as positive, negative, or neutral
  3. Entity recognition – identification of companies mentioned
  4. Categorisation – classification into market, company, or economic news
  5. Historical contextualisation – comparison with similar news items from the vector database, taking into account previous trading decisions
  6. Relevance assessment – assignment of an importance score (high/medium/standard)

Further, the LLM has full access to the portfolio at all times and can make independent buying and selling decisions based on all past messages, decisions, and market data. Currently, only long positions are permitted (i.e., only positive shareholdings are allowed).
Based on the limited free prompts, the model only rethinks its portfolio structure every minute by requesting an update to its portfolio composition. Furthermore, for each decision, the model outputs its decision reasons, which are stored in the database for future reference, allowing users to track the trades. However, during test runs, the LLM only made changes to fundamental information, but not to pure performance-related information.
Furthermore, the Agent is not limited to any specific trading hours. It therefore only runs during combined European and US trading hours. This results in some complications with stock price information, as the APIs only provide stock prices during their listing trading hours. This, however, is a problem that can be overcome with a planned workaround for the future.

News

The agent receives economic news every minute from leading sources. This continuous flow of information enables the system to react immediately (as quickly as possible, free of charge) to market events and identify time-sensitive trading opportunities.
Following this, each news item undergoes the complete LLM analysis process, as described earlier. This gives the Agent the possibility not only to process current information but also to attempt to recognize historical patterns.

Market data

The market data currently is limited to real-time and historical chart data. Therefore, the agent uses three different free APIs (Yahoo Finance, Finnhub, Alpha Vantage) for real-time price data. We use a redundant architecture, which ensures continuous data supply: If one API reaches its rate limit, the system automatically switches to the next available source.
This strategy enables reliable market access without costly premium subscriptions. This, however, is also limited and leads to delayed stock prices when the limitations of all three APIs are reached.

Database memory

The database memory is split into two distinct tables with vector embeddings forming the memory of the trading agent. The first table holds the processed news, and the second table has the portfolio decisions. Each stored information is transformed into a high-dimensional vector using the all-MiniLM-L6-v2 model. This embedding vector is crucial for enabling the model to identify similar historical events. This architecture allows the LLM/Agent to learn from past market reactions and make more informed decisions.

Portfolio

The portfolio module visualizes all of the agent’s buy/sell/hold decisions in real-time. The LLM has permanent read access to the current portfolio structure and takes this into account in every trading decision.
Portfolio characteristics:

  • Exclusively S&P 500 shares
  • Only long positions (no short sales)
  • Complete transparency of transaction history

Due to the integration with the LLM, portfolio management takes into account the overall context of news, market data, and historical patterns.