In the world of finance, the stock market has always been a captivating arena, with its potential for profit and intrigue. For me, the journey into the realm of artificial intelligence (AI) and stock trading began during my high school years, specifically when I was in computer science class. I was driven by a strong desire to understand the transformative power of AI, even when it wasn’t part of my formal computer science curriculum. This is the story of how I ventured into the world of AI-driven stock trading and my relentless pursuit to make it work.
Exploring The Untold Potential of AI
The absence of AI in my computer science class curriculum didn’t deter my curiosity. I began to explore AI independently, dedicating my own time to learn the fundamental building blocks that make AI tick. I knew that AI could be applied to a wide array of tasks, but I was particularly drawn to the stock market due to its wealth of data, making it an ideal playground for AI experimentation.
Early Attempts
My journey began with the development of an LSTM (Long Short-Term Memory) model, an algorithm well-suited for time series data, which stock prices undoubtedly are. While my initial attempts were promising in predicting stock prices one step ahead, the model struggled to provide consistent results beyond that. It was clear that this version of the algorithm, though academically sound, was not yet capable of making profitable stock trades.
How LSTMs Work:
Enter Reinforcement Learning
Determined to find a more effective approach, I delved deeper into AI research and stumbled upon Reinforcement Learning (RL). The concept of RL fascinated me, as it could enable the AI model to not just predict but learn to trade autonomously. I embarked on rewriting my code from scratch, leading to a substantial increase in its complexity and size. The key to success in RL models lies in designing effective reward functions. I experimented with various reward functions, with two main approaches standing out:
1. Rewarding buying or selling actions based on the volume by which the price went up or down, respectively.
2. Rewarding actions based on net worth, subtracting the initial balance.
Each approach had its advantages and drawbacks, and I found myself continuously fine-tuning these functions to optimize the AI’s performance. As my project progressed, I encountered significant computational challenges. Initially, I conducted model training on my personal computer with 32GB of RAM, an AMD Ryzen 7 2700X, and an RTX 2060 Super. However, as the model grew in complexity and computational demands increased, my system struggled to cope. Eventually, the program began crashing, rendering further training impossible.
How Reinforcement Learning Works
Reinforcement Learning (RL) is a powerful paradigm within the field of artificial intelligence that focuses on training intelligent agents to make sequential decisions in an environment to maximize cumulative rewards. RL models are particularly well-suited for tasks that involve decision-making over time, making them a natural fit for stock trading.
01
Agent
The AI model or agent is the entity that interacts with the environment and makes decisions. In the context of stock trading, the agent decides when to buy or sell stocks.
02
Environment
The environment represents the external system with which the agent interacts. In stock trading, the environment includes the stock market itself, where prices fluctuate based on various factors.
03
State
A state is a representation of the current situation or condition of the environment. In stock trading, the state can include information about stock prices, volume, indicators, and other relevant data.
04
Action
An action is a decision made by the agent to interact with the environment. For stock trading, actions typically involve buying, selling, or holding stocks.
05
Reward
A reward is a numeric value that the agent receives from the environment after taking an action. The goal of the agent is to maximize the cumulative reward over time. In stock trading, rewards can be based on the profitability of the trade.
The Road Ahead
Though my journey had to be paused due to hardware limitations, I remain dedicated to refining my AI stock trading algorithm. I am actively exploring strategies to make it more resource-efficient, ensuring it can run on lower-grade hardware. Additionally, I am considering alternate approaches and optimizations to bring my vision of a working AI stock trading bot to life. My journey into building an AI stock trading algorithm has been a rollercoaster of challenges and discoveries. While I may have encountered roadblocks along the way, my passion for AI and the stock market remains undiminished. As I continue to work on this project, I look forward to the day when I can share a fully functional AI stock trading bot with the world, harnessing the untold potential of artificial intelligence in the realm of finance.
Stay tuned for updates on this exciting journey!