Press enter or click to view image in full size
Lately, I’ve been feeling some serious AI fatigue. I’m getting tired of the constant stream of Twitter posts insisting I’m missing out by not jumping on the latest AI tools, which, more often than not, are just overpriced, slop-generating services. Honestly, it’s starting to feel like a bubble about to pop. It reminds me of the dot-com era, when just having a landing page could net you a $200M valuation. Today, we’re seeing startups with no real product getting valuations in the billions, it’s the same playbook, just inflated numbers.
But is AI only used for generating slop? Can it have some real use cases in, let’s say, stock picking? To find that out, I built an LLM-based agent that can trade small and mid-cap US stocks.
Before we dive in, if you prefer to watch an engaging clip rather than read, I released a YouTube video where I show how to set up the agent and what are its main functions.
The setup is pretty straightforward. First, it uses Perplexity’s API to scan the web for promising small/mid-cap stocks listed in the US. Then it pulls financial data — like the latest quarterly report, EPS, EBITDA, etc. from QuantiQ.live (a SaaS analytics platform). Finally, it feeds everything into GPT-4o, which “reasons” whether a given stock is worth buying. The agent doesn’t short; it can only buy or sell stocks it already holds. The agent can place real trades through the Alpaca API platform and it logs all transactions via YFinance into a CSV to track portfolio performance.
I also added a Streamlit GUI on top for a better user experience. The whole thing’s written in Python and super simple to run; the repo includes full instructions.
When I first ran it (about three weeks ago), it bought two stocks: Rocket Labs (RKLB) and Horizon Technology Finance Corporation (HRZN). RKLB is currently up 25%, HRZN about 4%. That might sound impressive, but with the market generally trending up, it’s too early to draw conclusions.
Here’s a screenshot from the Streamlit UI showing the portfolio’s evolution.
Press enter or click to view image in full size
I’m planning to update this story every week with the performance of the agent’s portfolio. I’ll be running it weekly and posting updates on what it decided to invest in. Stay tuned.
Updates
It’s been a full week. I reran the agent again and it decided to invest in CRDO, a company delivering high-speed connectivity solutions. The reason why it decided to invest was that Perplexity found it interested in the context of rapid expansion of data center in the US.
I also added a step to hedge your investments. Hedging can be done through any assset: ETF, commodity, crypto, bonds, REIT, or volatility indexes. The agent also bought VIXY when I asked to hedge the current portfolio. The reason for that is because if stocks fall, VIXY grows, being inversely correlated.
Here’s a snippet of the portfolio performance. Since I added two new tickers, the performance dropped, but it’s still positive.
Press enter or click to view image in full size
22–08–2025: Alpaca Integration
In the latest update I pushed to the Git repo you can find an integration with Alpaca to buy and sell stocks. Alpaca is an API platform that allows you to trade different financial instruments, from stocks to crypto.
Since the agent is quite profitable, I decided to give it access to my Alpaca account and trade on my behalf.
Important to mention is that it uses the “paper” API by default, meaning it’s trading virtual money. However, you can set the ALPACA_PAPER env variable to False in your .env config to switch to the real API.
Here’s the first trade the agent did with Alpaca:
Press enter or click to view image in full size
25–08–2025: Congress Trades
I have integrated a new option to get more information about particular stocks. By asking the agent the following `check house and senate trades for {ticker}`, it will call the QuantiQ.live API to get the latest Congress trades on that particular stock. Here’s an example with NVIDIA:
Press enter or click to view image in full size
30–08–2025: Technical Indicators
I have added the capability to show the most important technical indicators in fancy graphs.
To get the technical indicators for any stock, just type get technicals {ticker} and you’ll get something like this:
Press enter or click to view image in full size
Optionally, you can also supply the technicals to the analyze method, but I do not recommend that. Doing this will overload GPT-5 with so much data, that the results will most probably be influenced by hallucinations due to context overload, but it will also increase your costs quite a lot.
The best way to use this method is to do analysis yourself and check a stock by yourself before buying/selling.
16–09–2025: Google Trends, Backtesting, Portfolio Concentration and Risk Management
Huge update for our AI trading agent!
I just added the following functionalities:
- Google Trends: getting Google keywords related to a stock and find how they are trending on the search engine. This is done through GPT-5, and the trends are retrieved using pytrends library. Just type
get trends <stock>in the chat interface and you’ll get the performance of the most relevant 5 queries.
Why is this important? Because we want to predict market movements that are not priced in yet. Seeing a surge in people searching for “how to return leased cars” might mean bad news for banks or car manufacturers.
- Backtesting: Before you buy a stock, you can now backtest using historical data. See how your investment would have performed throughout time and get the Sharpe ratio and potential return as well. Here’s how it looks like for AAPL:
Press enter or click to view image in full size
- Portfolio Concentration: In the Portfolio Performance screen I have added a heatmap showing the portfolio concentration by sector:
Press enter or click to view image in full size
- Risk Management: When buying a stock, you have the ability to set stop-loss and take-profit orders. Those orders are automatically created in Alpaca.
25–09–2025: Auto-pilot, Event Calendar, Macros, News, Social Sentiment
Major update just rolled out. Let’s break each feature one by one:
- Auto-pilot: You can now give the agent total liberty to book trades on your behalf. Just type `enable auto-pilot` and it will start working. It finds first 10 small & mid-cap stocks to buy, analyzes them using the QuantiQ API, searches for congress trades for the stocks it finds, checks the news and sentiment on Reddit (specifically on r/wallstreetbets) and decides if it trades or not. Here’s a screenshot of what it did for me:
Press enter or click to view image in full size
- Event Calendar: As an investor you know how important market events are. On this tab you can see the calendar for the earning dates for each stock you have in your portfolio. You can also check economic events, such as Fed Rate Decision meetings, but you would need a premium account FMP account.
Press enter or click to view image in full size
- Macro Indicators: You probably observed in the above screenshot the new button called Macro Indicators. This is the place where you can check figures like real GDP, unemployment figures, CPI, consumer sentiment index, housing starts. To enable this in your local environment, you need to create a free account with FRED.
Press enter or click to view image in full size
- News: Since I am trying to transform this into an intelligent investment platform, I had to add news as well. Just type `get news {ticker}` and you will get the latest news for that stock. You just need to create a free account on News API.
Press enter or click to view image in full size
- Social Sentiment: News are great, but traditional news media outlets might not capture information that can move the markets in the near future. That is why I have added an integration with Reddit to scour subs like r/stocks, r/investing, r/wallstreetbets for tips about specific stocks. Just type
get social sentiment {ticker}and you will get the latest posts about that stock. Reddit integration is a bit more complex, but here’s what you need to do: - Go to https://www.reddit.com/prefs/apps
- Create a new application (select “script” type)
- Replace the placeholder credentials in the `.env` file with your actual credentials
Press enter or click to view image in full size
03–11–2025: SaaS Launched!
I’ve been busy lately brushing things up, adding Stripe integration and user management. Yep, you guessed it, I launched a SaaS based on this product, so you can use it without creating so many accounts, for just $15 per month.
You can access it here: the best investment AI agent.
You have 3 free actions once you validate your account. Auto-pilot does not work on free trial, but anything else does.
Btw, if you encounter issues, want to propose a new feature to the bot, or just want to get in touch with me, you can join my discord server: https://discord.gg/tZktXAHkev.
19–12–2025: More Asset Classes Added
I have added the possibility to trade not only stocks, but commodities, crypto and other asset classes such as bonds, ETFs or REITs, basically anything that is exchange-traded and is available in Alpaca.
When it comes to performance, as of 21st of December I have the following positions:
- RKLB -> probably the best-performing stock. It’s up 110% since the agent last bought it in June.
- IONS -> 9.41%
- EBMT -> 14.82%
- GIL -> 11.92%
- OVLY -> 5.32%
- TSBK -> 5.41%
- RGCO -> 0.92%
- ADNT -> -14.5%
- BBWI -> -23.05%
This is the latest snapshot of the agent’s portfolio. Although it has two unprofitable positions, the rest of them were good picks, especially Rocket Labs, which has doubled since the first time it bought the stock. I am expecting it to sell the worst-performing positions, however it still believes in those due to the good financial figures reported by these companies.
02–01–2026 First Run in 2026
Welcome to 2026! I sincerely wish you a great and productive year!
I just wanted to make everyone aware of the auto-pilot functionality. If you have Alpaca (test or prod) connected to your account, type `enable auto-pilot` and the agent will start exploring asset classes, search QuantiQ, Reddit, Polymarket, Google Trends, macro indicators or news to determine if the found assets should be bought. The agent also iterates through your positions and decides to sell or keep the positions.
At the end, you get a summary of all the activity. Here’s such an example to see the reasoning behind the decisions:
Auto-pilot analysis completed:
USAU: SELL — With no relevant Google or prediction‑market signals and negative earnings for a volatile small-cap gold developer, the risk profile outweighs the upside.
CLW: SELL — absent Polymarket signals and despite some EBITDA upticks, CLW has negative EPS, trades well below its 200-day with a -41% 1Y return and no dividend, while news highlights ongoing losses and industry oversupply/price pressure, making the risk/reward unattractive.
AVIR: SELL: Required Polymarket data are unavailable and AVIR remains a loss-making, thinly traded clinical-stage biotech with distant Phase 3 catalysts (mid–late 2026), making the near-term risk/reward unfavorable despite positive search/news momentum.
XPER: SELL — Despite a few upbeat mentions in recent search results, XPER sits near 52-week lows below its 50/200-day averages with an elevated ~37x P/E and reported revenue headwinds/slashed FY25 outlook, pointing to weak momentum and unfavorable risk/reward.
TBCH: SELL — per the stated criteria, Polymarket data is unavailable and shares show weak recent momentum (below 50-day average and negative 3–6 month returns) despite improving fundamentals and buybacks.
MYFW: SELL — after a 41% 1-year rally to near 52-week highs, MYFW trades at ~21x earnings with declining net interest margin (~2.54%), no dividend, and thin liquidity, skewing the risk/reward to the downside.
TCX: SELL — despite positive Google-sourced updates on revenue and EBITDA, TCX remains loss-making (EPS -8.74; negative P/E) with very thin liquidity and strategic uncertainty, and with no Polymarket data available under your criteria it does not qualify as a buy.
VGZ: SELL — per your criteria the absence of Polymarket data precludes a buy, and VGZ remains pre-revenue with negative EPS and a sharp 1-year run-up that elevates downside risk despite favorable Mt Todd feasibility headlines.
CIA: SELL — No relevant Google/Polymarket signals and weak near-term technicals (price below 50-day, -9% 1m) alongside a relatively rich 23x P/E and no dividend make the risk/reward unattractive.
ELMD[1][2][3][4]: SELL — Key inputs are missing (failed financials scrape, no Polymarket data, and no social sentiment), so despite positive Google-sourced headlines on growth and buybacks, your criteria preclude a buy.
BBWI: BUY: At ~6x TTM earnings with a ~4% dividend yield and the stock trading well below its 200-day average, BBWI appears undervalued with income support despite recent underperformance.
EBMT: BUY — At ~11x TTM EPS with a ~2.9% dividend yield and trading above its 50/200-day averages, EBMT’s pullback offers a reasonable entry despite thin small-cap liquidity.
GIL: BUY: GIL trades above its 50/200-day averages with strong 6–12 month momentum, a reasonable ~20x P/E on $3.11 EPS, and a 1.4% dividend yield, leaving room to retest its 52-week high.
OVLY: BUY — At ~10.6x TTM EPS with a ~2% dividend and trading above its 50/200-day averages near a 52-week high, OVLY offers reasonable value with positive momentum, albeit with low liquidity.
RGCO: BUY — At ~16.5x P/E with a ~3.9% dividend yield and trading slightly below its 50/200-day averages, RGCO offers reasonable income and valuation appeal despite thin liquidity.
TII: SELL — After an ~850% 1-year surge and ~300% 6-month jump, TII’s ~23x P/E, no dividend, and thin liquidity suggest elevated downside risk and unfavorable risk/reward at current levels.
TSBK: BUY: At ~9.7x P/E with a ~2.9% dividend yield and trading above its 50/200-day averages, TSBK offers value with positive momentum, albeit with micro-cap liquidity risk.
09–01–2026 More Features Added in the SaaS Platform
I have added some really useful features into the SaaS platform of this product, AIvestor.tech. Let’s break them down:
- Added situation monitor — a place where you can see conflict information in realtime, escalations, government policy information, Polymarket data, patterns identified by doing a deep research on the data sources. To get it, click on the Generic Situation on the navigation from the left-hand side. Here are some screenshots:
Press enter or click to view image in full size
Press enter or click to view image in full size
You can also create your own monitors
Press enter or click to view image in full size
- Weather monitor through Windy — excellent for monitoring extreme weather events that can impact the market:
Press enter or click to view image in full size
- Air traffic monitor — showing military airplanes to spot potential invasions before they show up in the news, emergencies, corporate planes or even all airplanes flying at one point in time:
Press enter or click to view image in full size
Press enter or click to view image in full size
- Pizza tracker — monitoring the pizza orders around Pentagon. Usually when the activity is high, they work overtime, therefore something is bound to happen (either an attack, invasion or some other military operation). Unfortunately they do not allow iframes, so I added just a link which opens in a new browser tab.
Press enter or click to view image in full size
- Bond tracker — simple table showing how many treasuries countries hold per day:
Press enter or click to view image in full size
All these new sources are plugged into the underlying LLM when taking a decision whether to invest in an asset or not.
Let me know if you have ideas on what to add and I will add the respective feature.
27–01–2026 New Backtesting Engine
Great news! I have totally revamped the backtesting engine.
Now you can set up trading strategies, setting up buy & sell triggers based on SMA and RSI indicators for any stock. You can test your strategy against historical data.
Here are some screenshots:
Some updates regarding the trades the agent did in the last month:
- Sold the whole portfolio at the beginning of the year.
- Bought TSBK which is 1% up.
- Bought NAMM due to news related to the Trump admin focusing on minerals and precious metals. It is up 31% since the agent bought it.
15–03–2026 New Situation Monitor for Shipping
We all know what happened in the last few weeks. Iran got attacked by a coalition between Israel and USA, and since then volatility skyrocketed, especially for oil.
Since AIVestor does have realtime access todata from news API, Reddit or X, you can use it to trade commodities such as oil, gold or silver. The caveat is that news are not really “realtime”, therefore to fix that, I have added OpenWater, an open-source project that feeds information about vessels traversing the strait of Hormuz to AIVestor. The objective is to anticipate a disruption in an industry by monitoring how prime materials are shipped through the conflict area.
But it’s not limited only to the strait of Hormuz. You get the same type of information from all the major chokepoints across the globe.
Here are some screenshots from this project:
Press enter or click to view image in full size
Press enter or click to view image in full size
The flow is like this:
- You ask AIVestor to analyze a certain stock, let’s say NKT A/S.
- The agent finds out that NKT needs Aluminum and Copper to make wires.
- It gets information that certain vessels carrying these prime materials are stuck since a few hours in the strait of Hormuz.
- Calculates the probability for this to become a major disruption for the supply chain of these materials and determines if the stock is a BUY or not.
I was surprised how this calculation was done when I asked AIVestor about evaluating software companies, which do not use raw materials directly. It looked at oil shipments and prices to determine the economic shock and future demand for the services provided by the companies behind these stocks.
Will keep you up-to-date with other findings about this new feature.
19–03–2026 Hedging Strategies & Portfolio Update
I have rolled out a new update on the hedging function of AIVestor.
Running hedge portfolio will have a deep look on the positions you have in Alpaca and will create new positions to hedge your exposure.
My current portfolio consists of the following stocks:
- $NKT.CO — up 10%
- $RYCEY — up 3%
- $RHM.DE— down 5%
- $BE — up 6%
- Sandisk — up 25%
I ran the command to hedge my portfolio and I got the following explanation from AIVestor:
Based on your current portfolio positioning, and in light of recent geopolitical
developments—most notably the disruption to global energy markets following
Qatar’s suspension of LNG production—I recommend implementing a tactical hedge.Recent attacks on Qatar’s energy infrastructure have removed approximately
17% of global LNG export capacity, with repair timelines potentially
extending up to five years. This has already led to sharp increases in
global gas and energy prices, contributing to renewed inflationary pressures
and heightened macroeconomic uncertainty.
In parallel, central banks are expected to maintain or even tighten monetary
policy in response to this energy-driven inflation shock, increasing
downside risks for equity markets broadly.
Given your exposure to cyclical and defense-related equities such as
Rheinmetall—which may benefit from elevated geopolitical tensions but remain
exposed to broader market drawdowns—I propose adding a short-term hedge to
reduce portfolio volatility.
Specifically, I recommend allocating approximately 10% of your portfolio to
the following inverse ETF trackers:
- Xtrackers S&P 500 Inverse Daily Swap UCITS ETF (1C)
- WisdomTree DAX 3x Daily Short
These instruments are designed to provide inverse (and in the case of the DAX
product, leveraged inverse) exposure to major equity indices, thereby
offering protection in the event of a broader market correction driven by:
- Persistent energy price shocks
- Inflation surprises and interest rate repricing
- Escalation of geopolitical risks in the Middle East
This allocation should be viewed as tactical and short-term, given the path
dependency and compounding effects associated with daily reset leveraged and
inverse ETFs.
I was surprised to see the model suggesting a leveraged tracker that shorts the DAX index, but it makes sense. Since 30% of the gas consumed by the German industries comes from Qatar, if Qatar does not deliver anymore, the model expects an acute squeeze of the German index.
I will update you with the status of the portfolio soon. Today, the 3x daily short tracker was up 7%, so it seems to be working.
Btw, if you encounter issues, want to propose a new feature to the bot, or just want to get in touch with me, you can join my discord server: https://discord.gg/tZktXAHkev. We really created a cool community there, so don’t hesitate to join the fun.