Skip to content

Latest commit

ย 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ Quant Trading Gym

A Robotic Playground for Algorithmic Trading Strategies ๐Ÿค–โžก๏ธ๐Ÿ“Šโžก๏ธ๐Ÿ’ฐ

Python Streamlit License

๐Ÿ† Hackathon-ready project for quantitative finance strategy development and testing

Quant Trading Gym Dashboard


โœจ Features

  • Three Trading Robots

    • SMA Crossover Robot: Buys when fast SMA crosses above slow SMA
    • RSI Mean Reversion Robot: Buys when oversold, sells when overbought
    • Market Mood Robot: Pairs trading using z-score between two assets
  • Professional Tools

    • Interactive web dashboard (Streamlit)
    • Real-time performance metrics (Sharpe Ratio, Drawdown, Returns)
    • Customizable parameters for each strategy
    • Multi-asset support (Stocks, ETFs, Crypto)
    • Clear visualizations and comparison charts

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/uniquepratham/quant-trading-gym.git
cd quant-trading-gym

# Install dependencies
pip install -r requirements.txt

Run the Web App

streamlit run app.py

Open http://localhost:8501 in your browser.

Run Command Line Version

python main.py

๐Ÿ“Š Example Strategy Performance

Strategy Total Return Sharpe Ratio Max Drawdown
SMA Crossover -17.4% -0.85 -19.8%
RSI Mean Reversion +5.3% +0.89 -1.6%
Market Mood Customizable Customizable Customizable

๐ŸŽฎ How to Use

  1. Open the Web App: streamlit run app.py

  2. Choose Your Robots: Select strategies to test

  3. Set the Rules: Adjust parameters such as:

    • SMA periods (e.g., 20 vs 50 days)
    • RSI thresholds (e.g., 30 oversold, 70 overbought)
    • Z-score entry/exit levels (e.g., 2.0 entry, 0.5 exit)
  4. Pick Your Assets: Backtest on QQQ, SPY, BTC-USD, etc.

  5. Launch Backtest: Watch your robots trade.

  6. Analyze Results: Compare performance metrics and identify the best strategy.


๐Ÿ—๏ธ Project Structure

quant-trading-gym/
โ”œโ”€โ”€ app.py                 # ๐ŸŽช Streamlit dashboard
โ”œโ”€โ”€ main.py                # โšก CLI testing version
โ”œโ”€โ”€ backtester.py          # ๐Ÿค– Trading simulation engine
โ”œโ”€โ”€ utils.py               # ๐Ÿ“ฆ Data handling & utilities
โ”œโ”€โ”€ strategies/            # ๐ŸŽฏ Trading robots
โ”‚   โ”œโ”€โ”€ sma_crossover.py   # ๐Ÿ“Š SMA crossover strategy
โ”‚   โ”œโ”€โ”€ rsi_meanrev.py     # ๐Ÿ“ˆ RSI mean reversion
โ”‚   โ””โ”€โ”€ market_mood.py     # ๐ŸŒ Pairs trading strategy
โ”œโ”€โ”€ outputs/               # ๐Ÿ“ธ Charts & results
โ””โ”€โ”€ requirements.txt       # ๐Ÿ“‹ Dependencies

๐Ÿ† Hackathon Achievements

Requirement Status
Quantitative Strategies โœ… 3+ Implemented
Backtesting Framework โœ… Metrics & engine
Multiple Timeframes โœ… Daily + customizable
Transaction Cost Modeling โœ… Commission parameter
Risk Management โœ… Position sizing
Performance Metrics โœ… Sharpe, Drawdown
Parameter Optimization โœ… Interactive tuning
Python Implementation โœ… Complete
Documentation โœ… README + comments

๐Ÿง  Technical Details

  • Data Source: Yahoo Finance API (real market data)
  • Assets: Stocks (QQQ, SPY), Crypto (BTC-USD)
  • Algorithms: SMA Crossover, RSI Mean Reversion, Z-Score Pairs Trading
  • Metrics: Total Return, Annualized Return, Sharpe Ratio, Volatility, Max Drawdown, Calmar Ratio

๐Ÿ”ฎ Future Enhancements

  • Live trading integration (Alpaca API, Binance API)
  • Machine learning strategies (LSTM, Reinforcement Learning)
  • Advanced risk management (Stop-loss, position sizing)
  • Multi-asset portfolio optimization
  • Real-time WebSocket market data

๐Ÿ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.


๐Ÿ™‹ Need Help?

Open an issue or reach out at gargpratham71@gmail.com

โญ Star this repo if you found it useful for your hackathon!

โ€œThe only way to win at trading is to have a better strategy โ€” and this helps you find it.โ€


About

A Robotic Playground for Algorithmic Trading Strategies ๐Ÿค–โžก๏ธ๐Ÿ“Šโžก๏ธ๐Ÿ’ฐ

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages