Skip to content

afsarali273/TradingBot_AI

Repository files navigation

TradingBot — AI-Enhanced Crypto Trading Assistant

Lightweight trading assistant combining AI-driven signal discovery with Freqtrade execution and a small FastAPI dashboard. This repository is an experimental, developer-focused sandbox for building and testing algorithmic ideas in paper (simulated) or live mode.

What's new (2026-03-08)

  • Added an "autonomous" meta-strategy: the engine can evaluate multiple candidate strategies per pair and automatically pick the best-fitting setup each cycle. Configure it in user_data/trading_strategies.json and enable it via the dashboard or API.
  • Signal engine and strategy manager updates: ai_engine/signal_engine.py and ai_engine/strategy_manager.py now support autonomous candidate evaluation, scoring, and metadata tagging so analytics and TP/SL resolution remain accurate.
  • UI improvements: ui_server/main.py and ui_server/templates/index.html now expose autonomous metadata, use cache-busting for strategy lists, and force server-side strategy reloads to avoid stale in-process config.
  • Trade risk resolution: paper trades and recorded positions use the selected underlying strategy's TP/SL via logic in ui_server/main.py.
  • MCP helper tools: mcp_server/server.py exposes useful MCP tools (portfolio, signal scan, paper trade helpers) for remote inspection and integrations.
  • Added a repository .gitignore (ignores venvs, logs, user_data/, DB files, caches, and common editor files).

If you updated files manually, double-check user_data/trading_strategies.json to confirm the autonomous profile and candidate list.

Quickstart — install & run

Prerequisites

  • Python 3.10+ (some optional components such as the mcp package require Python >=3.10)
  • Git
  • Optional: Docker (if you containerize freqtrade) and freqtrade installed for live/backtest execution
  1. Clone and prepare a virtual environment
git clone <your-repo-url> TradingBot
cd TradingBot
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
  1. Optional: install freqtrade (needed to run the full trading stack)
pip install "freqtrade[all]"
  1. Optional: install the MCP package to run mcp_server HTTP transport
pip install mcp
  1. Initialize example data and config
python scripts/apply_env_to_config.py
python scripts/bootstrap_files.py
  1. Configure secrets and API keys
  • Copy .env.example to .env and set required environment variables (COINBASE, GitHub OAuth, optional OPENAI keys, etc.). The UI GitHub OAuth callback defaults to http://127.0.0.1:8090/auth/github/callback.
  • Check user_data/config.json for dry_run mode, pair whitelist, and Freqtrade config values.
  1. Start services
  • Run the full stack (AI scheduler + Freqtrade + optional UI):
python scripts/run_stack.py --mode paper --with-ui
  • Run the UI only (FastAPI dashboard on :8090):
.venv/bin/python -m ui_server.main
# or background
nohup .venv/bin/python -m ui_server.main >> logs/ui_stdout.log 2>&1 &
  • Run the AI scheduler only:
.venv/bin/python -m ai_engine
# (module entrypoint runs the scheduler)
  • Run the MCP server (optional HTTP transport):
.venv/bin/python -m mcp_server.server --transport http --port 8091
  1. Dashboard

Open the dashboard at: http://127.0.0.1:8090

  1. Enabling the autonomous strategy
  • Edit user_data/trading_strategies.json to review the autonomous profile and candidate list.
  • Switch active strategy via the dashboard or the API (example):
curl -X POST -H "Content-Type: application/json" -d '{"strategy":"autonomous"}' http://127.0.0.1:8090/api/strategy/switch

Note: UI fetches are cache-busted by default, and the server reloads strategy config on relevant endpoints to avoid stale results.

Logs & troubleshooting

  • UI stdout / errors: logs/ui_stdout.log
  • AI engine & scan logs: logs/ai_engine.log
  • Agent scheduler activity: logs/agent_activity.log

If you see mismatched or missing strategy entries in the UI, try a hard reload (clear browser cache) or append a timestamp query param to the request. If an endpoint returns HTTP 500 (e.g., /api/autonomous/run), check the logs above for the full stack trace.

Important files to review

  • Config & strategies: user_data/trading_strategies.json, user_data/config.json
  • Core AI engine: ai_engine/signal_engine.py, ai_engine/strategy_manager.py, ai_engine/scheduler.py
  • Dashboard: ui_server/main.py, ui_server/templates/index.html
  • MCP tools: mcp_server/server.py

Notes and safety

This project is an experimental educational tool and not financial advice. Use paper mode for testing. Review and verify any live trading configuration before enabling real funds.

Contributing

Please open PRs against the main branch. Run the stack locally and include logs or a reproducible test when submitting behavior changes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors