Autonomous Algorithmic Trading Agent
AI quant agent combining LSTM sequence modeling with FinBERT NLP sentiment to predict stock & crypto asset price movements and execute automated trades.
This project is an Autonomous Algorithmic Trading Agent that integrates LSTM sequence modeling with FinBERT NLP sentiment analysis to predict stock and crypto asset price movements, generating automated buy/sell signals to maximize returns while maintaining strict risk controls.
Specifically, I engineered a dual-stream quantitative pipeline targeting four high-liquidity market leaders: Apple (AAPL), Microsoft (MSFT), Nvidia (NVDA), and Tesla (TSLA).
I trained a LSTM network using a 60-day rolling lookback window. The model used 18 feature-engineered attributes, including core technical indicators used in quantitative finance like RSI, MACD, and Bollinger Bands. The model was trained to do binary classifcation to predict whether an asset will hit a short-term 5-day price increase of at least 1.5%.
On the qualtative side, I used SERPAPI to scrape the top 20 news articles for each ticker every week. It feeds them into a pre-trained ProsusAI/FinBERT transformer model fine-tuned on financial language to classify sentiment. I also used a custom 40% consensus rule to count and establish the dominant market sentiment for each ticker every week.
To combine both the quantitatie and qualitative pipelines to produce a final trading decision for each of the assets, I built a custom Decision Fusion Module and a strict AND logic gate. The Agent will only execute a trade if the LSTM model predicts a probability of >0.5 AND the FinBERT model predicts a non-negative sentiment for a given ticker.
The entire codebase was hosted on a Microsoft Azure Linux Virtual Machine and was managed via tmux. The code was also scheduled to run daily at 20:00 using GitHub Actions for complete autonomy. To interact with the system, I built an interactive Streamlit dashboard featuring:
- A live trading executor page
- An on-demand backtesting page
- A results viewer to download trades and portfolio logs
Lastly, I also built a custom backtesting engine to evaluate the performance across different bullish and bearish market periods from 2016-2023, and the system returned a cumulative return of 1,305.23% over the an 8 year period. The true highlight was the agent's defense mechanism during the 2022 market creash. While the S&P500 index fund bore a -19.44% loss, my agent only had a minor decline of -6.00%. The performance of the agent was backtested across many more market conditions and to explore the entire mathematical methodology, detailed backtesting evaluations, and the complete system architecture with diagrams, check out my complete capstone thesis book embedded directly below!