Skip to content

kaigora/basic-bot

Repository files navigation

AI-Powered Swing Trading Pipeline

A Python-based algorithmic trading assistant that combines quantitative technical analysis with Google's Gemini LLM to generate high-probability swing trading signals, featuring a secure, human-in-the-loop manual execution terminal.

License: MIT Python


Table of Contents


Features

  • Technical Analysis Engine: Automatically calculates key indicators (VWMA, Bollinger Bands, Volume, 5-Day Trajectory) from local historical data.
  • LLM Signal Generation: Feeds quantitative data into Gemini to analyze momentum and volatility, outputting strict JSON BUY, SELL, or HOLD decisions with confidence scores.
  • Human-in-the-Loop Execution: A secure trade.py terminal that allows users to review AI reasoning before dispatching formatted market orders to the Kaigora API.
  • Modular Watchlists: Easy-to-manage JSON configuration files to segment your portfolio (e.g., Mining, Tech) and respect API rate limits.
  • Dry-Run Mode: Safely generate text files of AI decisions without risking real capital.

Prerequisites

Before you begin, ensure you have the following:

  • Python 3.9+ installed on your machine.
  • A Google Gemini API Key (for signal generation).
  • A Polygon API Key (for stock data, free tier is OK).
  • A Kaigora API Key (for trade execution).

Installation

Follow these steps to set up your local trading environment:

  1. Clone the repository

    git clone https://github.com/kaigora/basic-bot.git
    cd basic-bot
  2. Install dependencies

    pip install -r requirements.txt
  3. Set up enviroment variables Copy the template environment file to creat your local .env file:

    cp .env.example .env

    Note: For MacOS the .env.example and/or .env file may be hidden in Finder, press CMD + Shift + . to show hidden files in Finder.

    Open the newly created .env file and securely paste your API keys and modify your local data path if you prefer.


Project Structure

├── configs/ # JSON watchlists and indicator parameters
├── data/ # Local CSV files for historical stock data
├── outputs/ # AI generated prompts and response text files
├── utils/
│ ├── data/
│ │ ├── DataFetcher.py # Handles data ingestion
│ └── utils.py # Scripts to create/modify watchlists
├── analytics/
│ └── MarketAnalyst.py # TA calculations and LLM prompt generation
├── main.py # Core engine: runs TA and generates AI signals
├── trade.py # Execution terminal: sends orders to Kaigora API
└── .env.example # Template for environment variables


Usage Workflow

(Detailed instructions are included in corresponding python files: watchlist.py, main.py, trade.py)

This pipeline is designed for a 3-step daily workflow: Configure, Analyze, and Execute.

Step 1: Manage Watchlists Use the configuration script to create or modify your target assets. Open your configuration file and adjust the STOCK_LIST array (e.g., ["AAPL", "TSLA"]) to set the stocks you want to evaluate.

python watchlist.py

Step 2: Generate Signals Run the main engine. It will pull the data for your watchlists, run the technical analysis, query Gemini, and save the reasoning to the outputs/ folder.

python main.py

Note: Ensure AUTO_TRADE = False in main.py to keep the system in safe/manual mode.

Step 3: Review and Execute Trades Open the generated text files in outputs/ to review the AI's logic. If you agree with the trade setups, open trade.py and enter your orders in the PENDING_TRADES array using the easy-string format: (e.g. And order to Buy $10,000 worth of Apple stock, 500 shares of Amazon stock, and Sell 500 shares of Tesla stocks)

# Inside trade.py
PENDING_TRADES = [
    "AAPL BUY AMT 10000",
    "AMZN BUY SHR 100",
    "TSLA SELL SHR 500"
]

Then, execute the trades to the Kaigora API:

python trade.py

⚠️⚠️⚠️ Disclaimer ⚠️⚠️⚠️

Not Financial Advice. This software is provided for educational and research purposes only. Algorithmic trading involves significant risk of loss. The developers of this tool are not responsible for any financial losses incurred from its use. Always backtest strategies, start with paper trading, and review AI-generated signals manually before risking real capital.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages