Back to Projects
Trading BotLive

Automated RSI Trading Strategy

Algorithmic trading bot using RSI indicators for optimal entry and exit signals

Hero Summary

What

This automated trading system uses the Relative Strength Index (RSI) to identify potential trading opportunities in volatile stocks. The bot monitors market conditions in real-time and executes trades based on predefined RSI thresholds, ensuring consistent application of the strategy without emotional bias.

Why

The strategy enters long positions when RSI drops below 30 (oversold condition) and exits when RSI rises above 70 (overbought condition). Risk management is implemented through stop-loss orders at 5% below entry price and position sizing based on account equity. The system includes filters to avoid trading during low-volume periods and market gaps.

Result

annual Return

9.15%

win Rate

84.3%

sharpe Ratio

0.73

profit Factor

3.88

System Overview

How It Works

The strategy enters long positions when RSI drops below 30 (oversold condition) and exits when RSI rises above 70 (overbought condition). Risk management is implemented through stop-loss orders at 5% below entry price and position sizing based on account equity. The system includes filters to avoid trading during low-volume periods and market gaps.

Technologies Used

PythonPandasBacktraderNumPyMatplotlib

Technical Implementation

Built using Python with the Backtrader framework for backtesting and live trading capabilities. Data is sourced from Interactive Brokers API with real-time price feeds. The system uses Pandas for data manipulation, NumPy for calculations, and Matplotlib for performance visualization. Trade execution is handled through the broker's API with proper error handling and logging.

Performance & Risk Metrics

10-Stock Portfolio

AAPL · AMZN · GOOGL · JPM · META · MSFT · NVDA · TSLA · UNH · V — $1,000 each

Test Period

Jan 2015 – Dec 2024

83 trades

Initial Capital

$10,000.00

Final Value

$23,958.35

Net Profit

$13,958.35

Annual Return

9.15%

Risk-Adjusted Metrics

Sharpe Ratio

0.73

Risk-adjusted return

Sortino Ratio

0.83

Downside risk focus

Calmar Ratio

0.35

Return vs drawdown

Trading Performance

Win Rate

84.34%

Profit Factor

3.88

Max Drawdown

-26.21%

Avg Trade

$168.17

Expectancy / Trade

+11.84%

Avg Hold

138.0 days

Trade Examples & Visualizations

Interactive backtests showing every buy and sell signal against price and RSI. Drag across a chart to zoom in, double-click to reset.

Open full screen
Loading AAPL chart…

Limitations & Failure Modes

Every strategy has weaknesses. Here are the known limitations and scenarios where this system struggles.

⚠

Handling API rate limits during backtesting

⚠

Optimizing RSI parameters without overfitting

⚠

Managing execution latency in live trading

Key Learnings

The most important lesson was the impact of transaction costs on profitability. Initial backtests showed higher returns, but realistic commission and slippage assumptions brought returns down significantly. I also learned the importance of testing across different market conditions - the strategy performs well in trending markets but struggles in choppy, sideways markets. Future versions will include market regime detection.

Future Improvements

Planned enhancements and next steps for this project.

→

Add machine learning for dynamic RSI threshold adjustment

→

Implement multi-timeframe analysis

→

Create web dashboard for monitoring performance

→

Add support for multiple assets simultaneously

Quick Info

Category

Trading Bot

Status

Live

Tech Stack

PythonPandasBacktraderNumPyMatplotlib