Skip to content

Shridipa/AI-Trading-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Trading Bot Terminal

An AI-powered automated trading bot with a professional Tkinter GUI dashboard, Alpaca brokerage integration, and OpenAI GPT portfolio analysis.

Features

  • Automated DCA Strategy: Implements a Dollar Cost Averaging (DCA) laddering system with Martingale position sizing.
  • AI Portfolio Manager: Chat with a GPT-4 powered assistant that analyzes your real-time risk, exposure, and PnL.
  • Real-time Dashboard: Monitor positions, buying power, and total unrealized PnL in a dark-themed trading terminal.
  • Persistent Configuration: Manage your target equities through a local JSON persistence system.
  • Background Engine: Multi-threaded architecture ensures the UI remains responsive while the bot monitors markets.

Project Structure

ai_trading_bot/
│
├── bot.py                  # Main entry point
├── equities.json           # Persistent equity settings
├── .env                    # API Keys (Git ignored)
├── requirements.txt        # Dependencies
│
├── core/                   # Business Logic
│   ├── alpaca_client.py    # Alpaca API wrapper
│   ├── trading_engine.py   # DCA/Martingale logic
│   ├── order_manager.py    # Order tracking
│   ├── portfolio_manager.py# Data aggregation
│   ├── ai_manager.py       # OpenAI integration
│   ├── persistence.py      # JSON handler
│   └── refresh_engine.py   # Threading logic
│
├── gui/                    # UI Components
│   ├── main_window.py      # Terminal assembly
│   ├── portfolio_frame.py  # Stats & Table
│   ├── chat_frame.py       # AI interaction
│   ├── controls_frame.py   # CRUD operations
│   └── logs_frame.py       # System logs
│
└── notebooks/              # API Testing
    ├── alpaca.ipynb
    └── openai.ipynb

Setup Instructions

  1. Clone the repository:

    git clone <repo-url>
    cd ai_trading_bot
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Configure API Keys: Create a .env file in the root directory (template provided):

    ALPACA_API_KEY=your_key
    ALPACA_SECRET_KEY=your_secret
    OPENAI_API_KEY=your_openai_key
    BASE_URL=https://paper-api.alpaca.markets
    
  4. Run the Bot:

    python bot.py

Trading Logic (DCA/Martingale)

When a symbol is added and enabled:

  1. The bot checks for existing positions.
  2. If none, it places an initial market order.
  3. It then generates a "ladder" of limit buy orders at specific drawdown percentages (e.g., 2%, 4%, 6% below entry).
  4. Each level increases the order size (Martingale) to lower the average cost basis.

Risk Disclaimer

This bot is for educational purposes only. Automated trading involves significant risk of loss. Always use Paper Trading (Sandbox) environments before considering live capital.

Credits

Architecture based on the trading systems tutorial by Roman Paolucci.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors