Published: 2025-09-02
Recently I've been playing around with agents and tool calling from LLMs. Check out my blog post about Spectre to see more about how I've been building my own coding agent. I've been working on my rails app, and have it setup to connect to OpenAI and Vector Databases. I really wanted to see how agents could work in a rails app. It's not something I had done previously, and it turns out to be pretty straightforward.
The rails app I have it setup in has nothing to do with stocks. It's just quicker to throw this stock prediction into this app, instead of spinning up a whole new server. I like to move quick when I have an idea, and setting up servers and databases is mind numbing work to me.
The idea I had was to build a very aggressive agent that ingests economic news and then presents a couple "plays" to do in the stock market. Aggressive is the key here, I want to see if it can make >100% gains in a short amount of time.
Finding a data source for news was difficult, lots of places require you to pay lots of money and don't allow filtering. What I ended up finding was Alpha Vantage, they work closely with YCombinator. They are only focused on economic news, and allow you to filter based on a handful of economic categories.
Now Alpha Vantage is great, but they only allow 25 requests per day, not great for building a database of all stocks, I wanted to allow the agent to search stocks based on a news article. Their base plan is something like $50/mo, so I subscribed to that. This allows 75 requests per minute, still not amazing for pulling in stocks, but workable. The idea is to pull in all stocks, their names, and descriptions of the company, then vectorize the entire thing, and have the agent search this database to find stocks.
Why not use elastic search you may ask. Well, I had vectors already set up in my database since I was allowing recruiters to search developers to hire. I didn't need to go through the process of setting up elastic search. Again, we're going for speed of implementation, not the most greatest solution in the world. The search functionality is not the most important thing since articles often include stock symbols that the agent can act upon.
The agent needs data to work off of. We want it to read news articles and process them into a play on the stock market. To do this I setup a simple cron that calls a rake task to pull the most recent 3 articles from a subset of the categories available. This cron runs every hour. It could probably be optimized to only run during trading hours, but again, moving fast and not focusing on small things. Only doing 3 allows me to not spend too much on OpenAI. Plus, since it's every hour, not many articles are written in that time, so it doesn't really miss any articles.
The steps for the agent:
This is still fairly early days, but I've seen some decent results from it. Some plays die, but there's been a couple that have had >100%. The plays still require my own research, but it sets up a good base for me to work off of. What I've found is small stocks do not result in good plays.
I'm currently looking for work, if you have a role that you think I'd be a good fit for feel free to reach out to me on LinkedIn.