Skip to content

umerdawood23/Opening-Range-Breakout-Strategy-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Here's a comprehensive README.md file for your GitHub repository that explains the ORB Strategy Backtester:

markdown

ORB (Opening Range Breakout) Strategy Backtester

Python License

A complete backtesting system for the Opening Range Breakout (ORB) trading strategy, featuring:

  • Data fetching from Yahoo Finance
  • Strategy implementation with customizable parameters
  • Performance metrics and visualization
  • Trade logging and analysis

Features

  • Flexible Data Source: Uses Yahoo Finance API for market data
  • Customizable Strategy:
    • Adjustable opening range period (1-30 minutes)
    • Configurable risk management (stop loss, profit targets)
    • Variable position sizing
  • Comprehensive Analytics:
    • Sharpe ratio, CAGR, max drawdown
    • Monthly performance breakdown
    • Equity curve visualization
  • Trade Logging: Detailed record of every trade executed

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/orb-strategy-backtester.git
cd orb-strategy-backtester
Install dependencies:

bash
pip install -r requirements.txt
Configuration
Edit the config.py file to set your parameters:

python
# Trading parameters
TICKER = "TQQQ"            # Stock/ETF symbol
START_DATE = "2020-01-01"  # Backtest start date
END_DATE = "2023-12-31"    # Backtest end date

# Strategy parameters
ORB_PERIOD = 5             # Opening range period in minutes
RISK_PER_TRADE = 0.01      # Risk per trade (1% of capital)
MAX_LEVERAGE = 4           # Maximum position leverage
COMMISSION = 0.0005        # Per-trade commission

# Backtest parameters
INITIAL_CAPITAL = 25000    # Starting account balance
Usage
Run the backtester:

bash
python orb_backtester.py
Outputs:

{TICKER}_unadjusted.csv: Processed market data

trade_details.csv: Complete trade log

Performance metrics in console

Equity curve visualization

Example Output
Performance Summary
Metric	Value
Total Return (%)	148.72%
CAGR (%)	35.41%
Volatility (%)	42.18%
Sharpe Ratio	1.24
Max Drawdown (%)	-28.76%
Equity Curve
https://equity_curve_example.png

Customization
Modify these strategy components in strategies.py:

python
def calculate_position_size(current_capital, risk_pct, entry_price, stop_price):
    """Custom position sizing logic"""
    risk_amount = current_capital * risk_pct
    risk_per_share = abs(entry_price - stop_price)
    return min(risk_amount / risk_per_share, 
              current_capital * MAX_LEVERAGE / entry_price)
Limitations
Yahoo Finance data limitations:

1-minute data only available for last 30 days

5-minute data available for longer histories

Assumes perfect order execution

Doesn't account for slippage

License
MIT License - See LICENSE for details.

Contributing
Contributions welcome! Please open an issue or pull request for any:

Bug fixes

Feature additions

Performance improvements

text

Key sections included:

1. **Project badges** for quick visibility
2. **Clear installation instructions**
3. **Configuration options** with examples
4. **Usage examples** with expected outputs
5. **Customization guide** for strategy modifications
6. **Honest limitations** section
7. **License and contribution** information

The README is designed to:
- Help new users get started quickly
- Provide experienced users with customization options
- Set proper expectations about capabilities
- Encourage community contributions

Would you like me to add any additional sections such as:
- Detailed strategy explanation
- Backtest results from different markets
- Implementation roadmap
- FAQ section?

About

Opening Range Breakout Strategy in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published