I coded a stock trading Ai. Here's how much money I made.
Education
Introduction
I’ve always positioned myself as a long-term “Buy and Hold” investor, but the rise of automated trading and technical analysis intrigued me. Seeing everyone tapping into these methodologies, I decided to explore how I could leverage my coding skills to build a stock trading bot. My goal is to use the latest advancements in generative AI to outperform the market. Rather than simply asking ChatGPT for investment advice, I aimed to construct an algorithm capable of analyzing stock chart patterns and making investment decisions based on them.
Enter Gemini Pro
To achieve this, I aimed to utilize Google's Gemini Pro Vision model, which is one of the most advanced generative AI tools currently available. Gemini is more than just a language model; it has the capability to understand various forms of data, such as music, code, and even video. Importantly, recent updates to Gemini allow it to analyze images, which is crucial for my plan of using it to interpret stock charts.
Initial Tests
To kick things off, I ran some trials to evaluate Gemini's ability to recognize images accurately. First, I tested a simple image, and then I moved on to a stock chart of Apple's stock price. It not only recognized the chart but also provided specific data, noting that the price had risen from $ 125 in January 2023 to $ 168 in October 2023. I was impressed by its detailed understanding, so I decided to challenge it further. I provided a more complex stock chart, asking it to identify the company, the trend, and the moment of most rapid price drop. Astonishingly, it accurately identified Snowflake as the company and indicated the price drop.
Building the Bot
This experience sparked my excitement, leading me to find a better way to gather stock chart images than through tedious screenshots. After some browsing, I found an unsecured URL offering stock charts that I could adjust in my code. With my investment set at $ 1,000 on Robinhood, I began crafting the wireframe and importing essential libraries for my bot.
I wanted the AI to look for significant patterns on the stock charts. However, I soon realized the complexity of using numerical data for trading, which day traders commonly employ. But I wanted this to be fun, so I stuck to visual patterns.
The Challenge
After putting considerable effort into researching day trading patterns, I narrowed it down to six distinct chart patterns that I would like the AI to recognize. The challenge was training the AI to interpret these specific patterns, which became a massive undertaking that took about a week. I typically battled through many coding hurdles but managed to get the AI to recognize at least the bullish flag pattern upon testing.
Recognizing the need for proper data examples, I eventually gathered a comprehensive dataset for training. The goal was to efficiently classify stock chart patterns and predict price movements.
Trading Strategy
To evaluate the bot's performance over mine—rooted in fundamental analysis—I set up a competition. The bot would operate for one week and trade among a selected pool of ten stocks. The performance of the bot would be compared to my own hand-picked selections based on solid business principles.
Launching the Bot
On the first Monday of trading, the bot made its initial recommendations, suggesting a series of bullish flags for stocks such as Tesla, Nvidia, Microsoft, and ExxonMobil. After executing over $ 350 worth of these trades, I anxiously awaited the results.
At the end of day one, my portfolio was ahead with a 2.96% increase, while the bot made only $ 3. Over the next few days, my portfolio saw mixed performance. Meanwhile, the bot oscillated between trades, enduring glitches and debugging sessions.
As I approached day five, both the bot and I saw some gains, but ultimately, it was a close finish. By the week’s end, the bot managed to earn $ 62.65 from its trading. Although technically it won, the stress of daily trading weighed heavily on me compared to my peaceful long-term strategy.
Conclusion
In retrospect, while the AI trading experiment did yield some profits, I concluded that a hands-off investment strategy provided greater peace of mind and suited my investing philosophy. The exploration into AI trading was an exciting venture, but it made me appreciate the simplicity and reassurance of sticking with traditional investment methods.
Keyword
- Stock Trading Bot
- AI
- Google Gemini
- Stock Patterns
- Algorithm
- Investment
- Automated Trading
- Technical Analysis
FAQ
Q1: What is a stock trading bot? A stock trading bot is an automated software program that executes trades based on predefined criteria and strategies, often utilizing technical analysis.
Q2: How did you train the AI to recognize stock chart patterns? I collected data on specific stock chart patterns and utilized training techniques such as few-shot prompting and classification to teach the AI to identify them.
Q3: What were the results of using the bot versus your handpicked portfolio? Over the course of one week, the bot made $ 62.65, while my handpicked portfolio increased considerably due to a few significant trades.
Q4: Why did you choose to use Google's Gemini Pro for your project? Gemini Pro is one of the most advanced generative AI tools available, capable of understanding and interpreting various forms of data, including images necessary for stock chart analysis.
Q5: Would you continue using the AI trading bot? While the AI produced profits, I found that the stress of monitoring trades daily was not worth the outcome, and I preferred my traditional investing approach for long-term success.